diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md index 522e77c0b7b..bddacd1f2fc 100644 --- a/.github/ISSUE_TEMPLATE/Feature_request.md +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -32,8 +32,8 @@ What shortcomings exist with current approaches? ## Checklist My suggestion meets these guidelines: - [ ] This wouldn't be a breaking change in existing TypeScript / JavaScript code - [ ] This wouldn't change the runtime behavior of existing JavaScript code - [ ] This could be implemented without emitting different JS based on the types of the expressions - [ ] This isn't a runtime feature (e.g. new expression-level syntax) +* [ ] This wouldn't be a breaking change in existing TypeScript / JavaScript code +* [ ] This wouldn't change the runtime behavior of existing JavaScript code +* [ ] This could be implemented without emitting different JS based on the types of the expressions +* [ ] This isn't a runtime feature (e.g. new expression-level syntax) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 9c74ff2d6e8..daec1666314 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,15 +2,16 @@ Thank you for submitting a pull request! Here's a checklist you might find useful. -[ ] There is an associated issue that is labeled +* [ ] There is an associated issue that is labeled 'Bug' or 'help wanted' or is in the Community milestone -[ ] Code is up-to-date with the `master` branch -[ ] You've successfully run `jake runtests` locally -[ ] You've signed the CLA -[ ] There are new or updated unit tests validating the change +* [ ] Code is up-to-date with the `master` branch +* [ ] You've successfully run `jake runtests` locally +* [ ] You've signed the CLA +* [ ] There are new or updated unit tests validating the change Refer to CONTRIBUTING.MD for more details. https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md --> Fixes # + diff --git a/.gitignore b/.gitignore index 2e90e788faa..1b218945a18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ +.node_modules/ built/* tests/cases/rwc/* tests/cases/test262/* @@ -40,6 +41,7 @@ scripts/buildProtocol.js scripts/ior.js scripts/authors.js scripts/configurePrerelease.js +scripts/open-user-pr.js scripts/processDiagnosticMessages.d.ts scripts/processDiagnosticMessages.js scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js diff --git a/.mailmap b/.mailmap index 8ca4efe110e..2be2abbdfd2 100644 --- a/.mailmap +++ b/.mailmap @@ -308,7 +308,7 @@ Remo H. Jansen Sean Barag Sharon Rolel Stanislav Iliev -Wenlu Wang <805037171@163.com> wenlu.wang <805037171@163.com> kingwl <805037171@163.com> +Wenlu Wang <805037171@163.com> wenlu.wang <805037171@163.com> kingwl <805037171@163.com> 王文璐 王文璐 Wilson Hobbs Yuval Greenfield Daniel # @nieltg @@ -321,4 +321,23 @@ AdityaDaflapurkar # Aditya Daflapurkar Eric Grube Martyn Janes Ricardo N Feliciano -Sergii Bezliudnyi \ No newline at end of file +Sergii Bezliudnyi +Adrien Gibrat +Alex Ryan +Alexader Alexander T # Alexander Tarasyuk +Andrew Faulkner +Artem Tyurin +Brandon Slade +Derek P Sifford +Dhruv Rajvanshi +Holger Jeromin +Jordi Oliveras Rovira +Joscha Feth Joscha Feth +Ken703 # Bowden Kenny +Kevin Donnelly +Maarten Sijm +Paul Koerbitz +EcoleKeine # Ecole Keine +Khải +rhysd # @rhysd +Zen <843968788@qq.com> Zzzen <843968788@qq.com> # @Zzzen \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 8ec2411cea9..d7610ed7603 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ branches: - master - release-2.7 - release-2.8 + - release-2.9 install: - npm uninstall typescript --no-save diff --git a/AUTHORS.md b/AUTHORS.md index 679261876c8..8ffe4b73c29 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -6,14 +6,17 @@ TypeScript is authored by: * Aditya Daflapurkar * Adnan Chowdhury * Adrian Leonhard +* Adrien Gibrat * Ahmad Farid * Akshar Patel * Alan Agius * Alex Chugaev * Alex Eagle * Alex Khomchenko +* Alex Ryan * Alexander Kuvaev * Alexander Rusakov +* Alexander Tarasyuk * Ali Sabzevari * Aliaksandr Radzivanovich * Aluan Haddad @@ -22,6 +25,7 @@ TypeScript is authored by: * Andreas Martin * Andrej Baran * Andrew Casey +* Andrew Faulkner * Andrew Ochsner * Andrew Stegmaier * Andrew Z Allen @@ -34,6 +38,7 @@ TypeScript is authored by: * Armando Aguirre * Arnaud Tournier * Arnav Singh +* Artem Tyurin * Arthur Ozga * Asad Saeeduddin * Avery Morin @@ -49,6 +54,8 @@ TypeScript is authored by: * Blake Embrey * @bootstraponline * Bowden Kelly +* Bowden Kenny +* Brandon Slade * Brett Mayen * Bryan Forbes * Caitlin Potter @@ -76,6 +83,8 @@ TypeScript is authored by: * David Sheldrick * David Souther * Denis Nedelyaev +* Derek P Sifford +* Dhruv Rajvanshi * Dick van den Brink * Diogo Franco (Kovensky) * Dirk Bäumer @@ -84,6 +93,7 @@ TypeScript is authored by: * Donald Pipowitch * Doug Ilijev * @e-cloud +* Ecole Keine * Elisée Maurer * Emilio García-Pumarino * Eric Grube @@ -118,6 +128,7 @@ TypeScript is authored by: * Hendrik Liebau * Henry Mercer * Herrington Darkholme +* Holger Jeromin * Homa Wong * Iain Monro * @IdeaHunter @@ -155,6 +166,8 @@ TypeScript is authored by: * Jonathan Toland * Jonathan Turner * Jonathon Smith +* Jordi Oliveras Rovira +* Joscha Feth * Josh Abernathy * Josh Goldberg * Josh Kalderimis @@ -170,7 +183,9 @@ TypeScript is authored by: * Keith Mashinter * Ken Howard * Kenji Imamula +* Kevin Donnelly * Kevin Lang +* Khải * Kitson Kelly * Klaus Meinhardt * Kris Zyp @@ -179,6 +194,7 @@ TypeScript is authored by: * Lorant Pinter * Lucien Greathouse * Lukas Elmer +* Maarten Sijm * Magnus Hiie * Magnus Kulke * Manish Giri @@ -223,6 +239,7 @@ TypeScript is authored by: * Oussama Ben Brahim * Patrick Zhong * Paul Jolly +* Paul Koerbitz * Paul van Brenk * @pcbro * Pedro Maltez @@ -240,6 +257,7 @@ TypeScript is authored by: * Raj Dosanjh * Reiner Dolp * Remo H. Jansen +* @rhysd * Ricardo N Feliciano * Richard Karmazín * Richard Knoll @@ -309,4 +327,5 @@ TypeScript is authored by: * Yuval Greenfield * Zeeshan Ahmed * Zev Spitz -* Zhengbo Li \ No newline at end of file +* Zhengbo Li +* @Zzzen \ No newline at end of file diff --git a/Gulpfile.js b/Gulpfile.js index 9a082bb4479..b6f1f0fcb02 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -54,7 +54,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), { debug: process.env.debug || process.env["debug-brk"] || process.env.d, inspect: process.env.inspect || process.env["inspect-brk"] || process.env.i, host: process.env.TYPESCRIPT_HOST || process.env.host || "node", - browser: process.env.browser || process.env.b || "IE", + browser: process.env.browser || process.env.b || (os.platform() === "win32" ? "edge" : "chrome"), timeout: process.env.timeout || 40000, tests: process.env.test || process.env.tests || process.env.t, runners: process.env.runners || process.env.runner || process.env.ru, @@ -160,7 +160,7 @@ const generatedLCGFile = path.join(builtLocalDirectory, "enu", "diagnosticMessag * 2. 'src\compiler\diagnosticMessages.generated.json' => 'built\local\ENU\diagnosticMessages.generated.json.lcg' * generate the lcg file (source of messages to localize) from the diagnosticMessages.generated.json */ -const localizationTargets = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-BR", "ru", "tr", "zh-CN", "zh-TW"] +const localizationTargets = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"] .map(f => path.join(builtLocalDirectory, f, "diagnosticMessages.generated.json")) .concat(generatedLCGFile); diff --git a/Jakefile.js b/Jakefile.js index 2eeccdd7a4f..5d85a4e74f3 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -131,7 +131,7 @@ var generatedLCGFile = path.join(builtLocalDirectory, "enu", "diagnosticMessages * 2. 'src\compiler\diagnosticMessages.generated.json' => 'built\local\ENU\diagnosticMessages.generated.json.lcg' * generate the lcg file (source of messages to localize) from the diagnosticMessages.generated.json */ -var localizationTargets = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-BR", "ru", "tr", "zh-CN", "zh-TW"].map(function (f) { +var localizationTargets = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"].map(function (f) { return path.join(builtLocalDirectory, f); }).concat(path.dirname(generatedLCGFile)); @@ -922,7 +922,7 @@ desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is task("runtests-browser", ["browserify", nodeServerOutFile], function () { cleanTestDirs(); host = "node"; - var browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE"); + var browser = process.env.browser || process.env.b || (os.platform() === "win32" ? "edge" : "chrome"); var runners = process.env.runners || process.env.runner || process.env.ru; var tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; diff --git a/ThirdPartyNoticeText.txt b/ThirdPartyNoticeText.txt index a9ffbddbd89..b82f2497a6c 100644 --- a/ThirdPartyNoticeText.txt +++ b/ThirdPartyNoticeText.txt @@ -1,35 +1,96 @@ /*!----------------- TypeScript ThirdPartyNotices ------------------------------------------------------- -The TypeScript software is based on or incorporates material and code from the projects listed below -(collectively "Third Party Code"). Microsoft is not the original author of the -Third Party Code. The original copyright notice and the license, under which -Microsoft received such Third Party Code, are set forth below. Such license and -notices are provided for informational purposes only. Microsoft licenses the Third +The TypeScript software is based on or incorporates material and code from the projects listed below +(collectively "Third Party Code"). Microsoft is not the original author of the +Third Party Code. The original copyright notice and the license, under which +Microsoft received such Third Party Code, are set forth below. Such license and +notices are provided for informational purposes only. Microsoft licenses the Third Party Code to you under the terms of the Apache 2.0 License. -All Third Party Code licensed by Microsoft 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 +All Third Party Code licensed by Microsoft 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. +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 +See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. --------------------------------------------- Third Party Code Components -------------------------------------------- ------------------- DefinitelyTyped -------------------- -This file is based on or incorporates material from the projects listed below (collectively "Third Party Code"). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise. +This file is based on or incorporates material from the projects listed below (collectively "Third Party Code"). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise. DefinitelyTyped This project is licensed under the MIT license. Copyrights are respective of each contributor listed at the beginning of each definition file. Provided for Informational Purposes Only - -MIT License -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +MIT License +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------------- + +------------------- Unicode -------------------- +UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE + +Unicode Data Files include all data files under the directories +http://www.unicode.org/Public/, http://www.unicode.org/reports/, +http://www.unicode.org/cldr/data/, http://source.icu-project.org/repos/icu/, and +http://www.unicode.org/utility/trac/browser/. + +Unicode Data Files do not include PDF online code charts under the +directory http://www.unicode.org/Public/. + +Software includes any source code published in the Unicode Standard +or under the directories +http://www.unicode.org/Public/, http://www.unicode.org/reports/, +http://www.unicode.org/cldr/data/, http://source.icu-project.org/repos/icu/, and +http://www.unicode.org/utility/trac/browser/. + +NOTICE TO USER: Carefully read the following legal agreement. +BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S +DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), +YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE +TERMS AND CONDITIONS OF THIS AGREEMENT. +IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE +THE DATA FILES OR SOFTWARE. + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1991-2017 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in http://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. +-------------------------------------------------------------------------------------- + ------------- End of ThirdPartyNotices --------------------------------------------------- */ diff --git a/lib/lib.es2018.regexp.d.ts b/lib/lib.es2018.regexp.d.ts index 0c3358ef6af..a0017f21438 100644 --- a/lib/lib.es2018.regexp.d.ts +++ b/lib/lib.es2018.regexp.d.ts @@ -28,4 +28,9 @@ interface RegExpExecArray { groups?: { [key: string]: string } -} \ No newline at end of file +} + +interface RegExp { + /** Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression. Default is false. Read-only. */ + readonly dotAll: boolean; +} diff --git a/package-lock.json b/package-lock.json index 43128f91636..d60ec3b7545 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,11 +10,11 @@ "integrity": "sha1-z6I7xYQPkQTOMqZedNt+epdLvuE=", "dev": true, "requires": { - "acorn": "^5.0.3", - "css": "^2.2.1", - "normalize-path": "^2.1.1", - "source-map": "^0.5.6", - "through2": "^2.0.3" + "acorn": "5.5.3", + "css": "2.2.1", + "normalize-path": "2.1.1", + "source-map": "0.5.7", + "through2": "2.0.3" }, "dependencies": { "acorn": { @@ -31,8 +31,41 @@ "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=", "dev": true, "requires": { - "normalize-path": "^2.0.1", - "through2": "^2.0.3" + "normalize-path": "2.1.1", + "through2": "2.0.3" + } + }, + "@octokit/rest": { + "version": "15.4.0", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-15.4.0.tgz", + "integrity": "sha512-cmDdt71Kufz0AZt/EPlJbce9NDhoc9ggJm9P7h6Y+WOds19Q6vBJAPApKTIpN4VpnvwB1XHEOdmqP7gZdPCNKw==", + "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" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "dev": true + } } }, "@types/browserify": { @@ -41,8 +74,8 @@ "integrity": "sha512-mY6dYfq1Ns3Xqz/JFUcyoWaXtm0XDoNhkU1vCwM/ULM5zqNL+SbtacJhce/JCgPeCdbqdVqq77tJ4HwdtypSxg==", "dev": true, "requires": { - "@types/insert-module-globals": "*", - "@types/node": "*" + "@types/insert-module-globals": "7.0.0", + "@types/node": "8.5.5" } }, "@types/chai": { @@ -63,7 +96,7 @@ "integrity": "sha512-y6qRq6raBuu965clKgx6FHuiPu3oHdtmzMPXi8Uahsjdq1L6DL5fS/aY5/s71YwM7k6K1QIWvem5vNwlnNGIkQ==", "dev": true, "requires": { - "@types/glob": "*" + "@types/glob": "5.0.35" } }, "@types/events": { @@ -78,9 +111,9 @@ "integrity": "sha512-wc+VveszMLyMWFvXLkloixT4n0harUIVZjnpzztaZ0nKLuul7Z32iMt2fUFGAaZ4y1XWjFRMtCI5ewvyh4aIeg==", "dev": true, "requires": { - "@types/events": "*", - "@types/minimatch": "*", - "@types/node": "*" + "@types/events": "1.2.0", + "@types/minimatch": "3.0.3", + "@types/node": "8.5.5" } }, "@types/gulp": { @@ -89,9 +122,9 @@ "integrity": "sha512-u6/zWPzYRNPAtvyFJ3/RSXjmBaBM1dVs5kW22/jU6J786ZGLfSndhLoNOpFI6FGQvqTA+QzFHjSMhpkAN+wxcQ==", "dev": true, "requires": { - "@types/node": "*", - "@types/orchestrator": "*", - "@types/vinyl": "*" + "@types/node": "8.5.5", + "@types/orchestrator": "0.3.2", + "@types/vinyl": "2.0.2" } }, "@types/gulp-concat": { @@ -100,7 +133,7 @@ "integrity": "sha512-CUCFADlITzzBfBa2bdGzhKtvBr4eFh+evb+4igVbvPoO5RyPfHifmyQlZl6lM7q19+OKncRlFXDU7B4X9Ayo2g==", "dev": true, "requires": { - "@types/node": "*" + "@types/node": "8.5.5" } }, "@types/gulp-help": { @@ -109,9 +142,9 @@ "integrity": "sha512-MkW7psZznxxJg2MBk2P2qHE+T8jEZVFz3FG/qGjUYazkyJt7hBJWx5Nuewmay5RVNtUvSWPrdZLr/WTXY3T/6A==", "dev": true, "requires": { - "@types/gulp": "*", - "@types/node": "*", - "@types/orchestrator": "*" + "@types/gulp": "3.8.36", + "@types/node": "8.5.5", + "@types/orchestrator": "0.3.2" } }, "@types/gulp-newer": { @@ -120,7 +153,7 @@ "integrity": "sha512-e7J/Zv5Wd7CC0WpuA2syWVitgwrkG0u221e41w7r07XUR6hMH6kHPkq9tUrusHkbeW8QbuLbis5fODOwQCyggQ==", "dev": true, "requires": { - "@types/node": "*" + "@types/node": "8.5.5" } }, "@types/gulp-sourcemaps": { @@ -129,7 +162,7 @@ "integrity": "sha512-+7BAmptW2bxyJnJcCEuie7vLoop3FwWgCdBMzyv7MYXED/HeNMeQuX7uPCkp4vfU1TTu4CYFH0IckNPvo0VePA==", "dev": true, "requires": { - "@types/node": "*" + "@types/node": "8.5.5" } }, "@types/insert-module-globals": { @@ -138,7 +171,7 @@ "integrity": "sha512-zudCJPwluh1VUDB6Gl/OQdRp+fYy3+47huJB/JMQubMS2p+sH18MCVK4WUz3FqaWLB12yh5ELxVR/+tqwlm/qA==", "dev": true, "requires": { - "@types/node": "*" + "@types/node": "8.5.5" } }, "@types/merge2": { @@ -147,7 +180,7 @@ "integrity": "sha512-GjaXY4OultxbaOOk7lCLO7xvEcFpdjExC605YmfI6X29vhHKpJfMWKCDZd3x+BITrZaXKg97DgV/SdGVSwdzxA==", "dev": true, "requires": { - "@types/node": "*" + "@types/node": "8.5.5" } }, "@types/minimatch": { @@ -168,7 +201,7 @@ "integrity": "sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg==", "dev": true, "requires": { - "@types/node": "*" + "@types/node": "8.5.5" } }, "@types/mocha": { @@ -189,8 +222,8 @@ "integrity": "sha512-cKB4yTX0wGaRCSkdHDX2fkGQbMAA8UOshC2U7DQky1CE5o+5q2iQQ8VkbPbE/88uaTtsusvBPMcCX7dgmjxBhQ==", "dev": true, "requires": { - "@types/node": "*", - "@types/q": "*" + "@types/node": "8.5.5", + "@types/q": "1.5.0" } }, "@types/q": { @@ -205,8 +238,8 @@ "integrity": "sha512-XwGr1b4yCGUILKeBkzmeWcxmGHQ0vFFFpA6D6y1yLO6gKmYorF+PHqdU5KG+nWt38OvtrkDptmrSmlHX/XtpLw==", "dev": true, "requires": { - "@types/gulp": "*", - "@types/node": "*" + "@types/gulp": "3.8.36", + "@types/node": "8.5.5" } }, "@types/through2": { @@ -215,7 +248,7 @@ "integrity": "sha1-H/LoihAN+1sUDnu5h5HxGUQA0TE=", "dev": true, "requires": { - "@types/node": "*" + "@types/node": "8.5.5" } }, "@types/travis-fold": { @@ -230,7 +263,7 @@ "integrity": "sha512-2iYpNuOl98SrLPBZfEN9Mh2JCJ2EI9HU35SfgBEb51DcmaHkhp8cKMblYeBqMQiwXMgAD3W60DbQ4i/UdLiXhw==", "dev": true, "requires": { - "@types/node": "*" + "@types/node": "8.5.5" } }, "@types/xml2js": { @@ -239,17 +272,7 @@ "integrity": "sha512-8aKUBSj3oGcnuiBmDLm3BIk09RYg01mz9HlQ2u4aS17oJ25DxjQrEUVGFSBVNOfM45pQW4OjcBPplq6r/exJdA==", "dev": true, "requires": { - "@types/node": "*" - } - }, - "JSONStream": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", - "integrity": "sha1-wQI3G27Dp887hHygDCC7D85Mbeo=", - "dev": true, - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" + "@types/node": "8.5.5" } }, "abbrev": { @@ -270,8 +293,8 @@ "integrity": "sha512-efP54n3d1aLfjL2UMdaXa6DsswwzJeI5rqhbFvXMrKiJ6eJFpf+7R0zN7t8IC+XKn2YOAFAv6xbBNgHUkoHWLw==", "dev": true, "requires": { - "acorn": "^5.4.1", - "xtend": "^4.0.1" + "acorn": "5.5.3", + "xtend": "4.0.1" }, "dependencies": { "acorn": { @@ -282,15 +305,24 @@ } } }, + "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==", + "dev": true, + "requires": { + "es6-promisify": "5.0.0" + } + }, "align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, "requires": { - "kind-of": "^3.0.2", - "longest": "^1.0.1", - "repeat-string": "^1.5.2" + "kind-of": "3.2.2", + "longest": "1.0.1", + "repeat-string": "1.6.1" }, "dependencies": { "kind-of": { @@ -299,7 +331,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -316,7 +348,7 @@ "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", "dev": true, "requires": { - "ansi-wrap": "^0.1.0" + "ansi-wrap": "0.1.0" } }, "ansi-cyan": { @@ -358,7 +390,7 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "^1.9.0" + "color-convert": "1.9.1" } }, "ansi-wrap": { @@ -373,7 +405,7 @@ "integrity": "sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE=", "dev": true, "requires": { - "buffer-equal": "^1.0.0" + "buffer-equal": "1.0.0" } }, "archy": { @@ -388,7 +420,7 @@ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { - "sprintf-js": "~1.0.2" + "sprintf-js": "1.0.3" } }, "arr-diff": { @@ -451,7 +483,7 @@ "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, "requires": { - "array-uniq": "^1.0.1" + "array-uniq": "1.0.3" } }, "array-uniq": { @@ -472,9 +504,9 @@ "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, "requires": { - "bn.js": "^4.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" + "bn.js": "4.11.8", + "inherits": "2.0.3", + "minimalistic-assert": "1.0.1" } }, "assert": { @@ -504,7 +536,7 @@ "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", "dev": true, "requires": { - "acorn": "^4.0.3" + "acorn": "4.0.13" } }, "async": { @@ -525,9 +557,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": { @@ -542,11 +574,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "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" + "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" } }, "supports-color": { @@ -569,13 +601,13 @@ "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "define-property": { @@ -584,7 +616,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "^1.0.0" + "is-descriptor": "1.0.2" } }, "is-accessor-descriptor": { @@ -593,7 +625,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-data-descriptor": { @@ -602,7 +634,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-descriptor": { @@ -611,9 +643,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" } } } @@ -630,6 +662,12 @@ "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", "dev": true }, + "before-after-hook": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-1.1.0.tgz", + "integrity": "sha512-VOMDtYPwLbIncTxNoSzRyvaMxtXmLWLUqr8k5AfC1BzLk34HvBXaQX8snOwQZ4c0aX8aSERqtJSiI9/m2u5kuA==", + "dev": true + }, "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", @@ -642,7 +680,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "^1.0.0", + "balanced-match": "1.0.0", "concat-map": "0.0.1" } }, @@ -652,16 +690,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.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" + "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" }, "dependencies": { "extend-shallow": { @@ -670,7 +708,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -687,12 +725,12 @@ "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, "requires": { - "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" + "combine-source-map": "0.8.0", + "defined": "1.0.0", + "JSONStream": "1.3.2", + "safe-buffer": "5.1.2", + "through2": "2.0.3", + "umd": "3.0.3" } }, "browser-resolve": { @@ -716,54 +754,54 @@ "integrity": "sha512-yotdAkp/ZbgDesHQBYU37zjc29JDH4iXT8hjzM1fdUVWogjARX0S1cKeX24Ci6zZ+jG+ADmCTRt6xvtmJnI+BQ==", "dev": true, "requires": { - "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", + "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.0.0", + "glob": "7.1.2", + "has": "1.0.1", + "htmlescape": "1.1.1", + "https-browserify": "1.0.0", + "inherits": "2.0.3", + "insert-module-globals": "7.0.6", + "JSONStream": "1.3.2", + "labeled-stream-splicer": "2.0.1", + "mkdirp": "0.5.1", + "module-deps": "6.0.2", + "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.1", + "string_decoder": "1.1.1", + "subarg": "1.0.0", + "syntax-error": "1.4.0", + "through2": "2.0.3", + "timers-browserify": "1.4.2", "tty-browserify": "0.0.1", - "url": "~0.11.0", - "util": "~0.10.1", - "vm-browserify": "^1.0.0", - "xtend": "^4.0.0" + "url": "0.11.0", + "util": "0.10.3", + "vm-browserify": "1.0.1", + "xtend": "4.0.1" } }, "browserify-aes": { @@ -772,12 +810,12 @@ "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { - "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" + "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" } }, "browserify-cipher": { @@ -786,9 +824,9 @@ "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, "requires": { - "browserify-aes": "^1.0.4", - "browserify-des": "^1.0.0", - "evp_bytestokey": "^1.0.0" + "browserify-aes": "1.2.0", + "browserify-des": "1.0.1", + "evp_bytestokey": "1.0.3" } }, "browserify-des": { @@ -797,9 +835,9 @@ "integrity": "sha512-zy0Cobe3hhgpiOM32Tj7KQ3Vl91m0njwsjzZQK1L+JDf11dzP9qIvjreVinsvXrgfjhStXwUWAEpB9D7Gwmayw==", "dev": true, "requires": { - "cipher-base": "^1.0.1", - "des.js": "^1.0.0", - "inherits": "^2.0.1" + "cipher-base": "1.0.4", + "des.js": "1.0.0", + "inherits": "2.0.3" } }, "browserify-rsa": { @@ -808,8 +846,8 @@ "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", "dev": true, "requires": { - "bn.js": "^4.1.0", - "randombytes": "^2.0.1" + "bn.js": "4.11.8", + "randombytes": "2.0.6" } }, "browserify-sign": { @@ -818,13 +856,13 @@ "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", "dev": true, "requires": { - "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" + "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" } }, "browserify-zlib": { @@ -833,17 +871,23 @@ "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, "requires": { - "pako": "~1.0.5" + "pako": "1.0.6" } }, + "btoa-lite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", + "integrity": "sha1-M3dm2hWAEhD92VbCLpxokaudAzc=", + "dev": true + }, "buffer": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.1.0.tgz", "integrity": "sha512-YkIRgwsZwJWTnyQrsBTWefizHh+8GYj3kbL1BTiAQ/9pwpino0G7B2gp5tx/FUBqUlvtxV85KNR3mwfAtv15Yw==", "dev": true, "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" + "base64-js": "1.3.0", + "ieee754": "1.1.11" } }, "buffer-crc32": { @@ -888,15 +932,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": { @@ -919,8 +963,8 @@ "dev": true, "optional": true, "requires": { - "align-text": "^0.1.3", - "lazy-cache": "^1.0.3" + "align-text": "0.1.4", + "lazy-cache": "1.0.4" } }, "chai": { @@ -929,12 +973,12 @@ "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", "dev": true, "requires": { - "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" + "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" } }, "chalk": { @@ -943,9 +987,9 @@ "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.4.0" } }, "check-error": { @@ -960,8 +1004,8 @@ "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" + "inherits": "2.0.3", + "safe-buffer": "5.1.2" } }, "class-utils": { @@ -970,10 +1014,10 @@ "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" + "arr-union": "3.1.0", + "define-property": "0.2.5", + "isobject": "3.0.1", + "static-extend": "0.1.2" }, "dependencies": { "define-property": { @@ -982,7 +1026,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } } } @@ -994,8 +1038,8 @@ "dev": true, "optional": true, "requires": { - "center-align": "^0.1.1", - "right-align": "^0.1.1", + "center-align": "0.1.3", + "right-align": "0.1.3", "wordwrap": "0.0.2" }, "dependencies": { @@ -1032,9 +1076,9 @@ "integrity": "sha512-Bq6+4t+lbM8vhTs/Bef5c5AdEMtapp/iFb6+s4/Hh9MVTt8OLKH7ZOOZSCT+Ys7hsHvqv0GuMPJ1lnQJVHvxpg==", "dev": true, "requires": { - "inherits": "^2.0.1", - "process-nextick-args": "^2.0.0", - "readable-stream": "^2.3.5" + "inherits": "2.0.3", + "process-nextick-args": "2.0.0", + "readable-stream": "2.3.6" } }, "collection-visit": { @@ -1043,8 +1087,8 @@ "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" + "map-visit": "1.0.0", + "object-visit": "1.0.1" } }, "color-convert": { @@ -1053,7 +1097,7 @@ "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { - "color-name": "^1.1.1" + "color-name": "1.1.3" } }, "color-name": { @@ -1074,10 +1118,10 @@ "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", "dev": true, "requires": { - "convert-source-map": "~1.1.0", - "inline-source-map": "~0.6.0", - "lodash.memoize": "~3.0.3", - "source-map": "~0.5.3" + "convert-source-map": "1.1.3", + "inline-source-map": "0.6.2", + "lodash.memoize": "3.0.4", + "source-map": "0.5.7" }, "dependencies": { "convert-source-map": { @@ -1112,10 +1156,10 @@ "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" + "buffer-from": "1.0.0", + "inherits": "2.0.3", + "readable-stream": "2.3.6", + "typedarray": "0.0.6" } }, "concat-with-sourcemaps": { @@ -1124,7 +1168,7 @@ "integrity": "sha512-5i4Spc9NNvVXzkR77x2kjcYCDZMNPLzP7ZBzJMNKZjXzk+E6tRVL/lPlYw60VM3hb7gf+iBQn2x1T8TpMN0SEw==", "dev": true, "requires": { - "source-map": "^0.6.1" + "source-map": "0.6.1" }, "dependencies": { "source-map": { @@ -1141,7 +1185,7 @@ "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", "dev": true, "requires": { - "date-now": "^0.1.4" + "date-now": "0.1.4" } }, "constants-browserify": { @@ -1174,8 +1218,8 @@ "integrity": "sha512-iZvCCg8XqHQZ1ioNBTzXS/cQSkqkqcPs8xSX4upNB+DAk9Ht3uzQf2J32uAHNCne8LDmKr29AgZrEs4oIrwLuQ==", "dev": true, "requires": { - "bn.js": "^4.1.0", - "elliptic": "^6.0.0" + "bn.js": "4.11.8", + "elliptic": "6.4.0" } }, "create-hash": { @@ -1184,11 +1228,11 @@ "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { - "cipher-base": "^1.0.1", - "inherits": "^2.0.1", - "md5.js": "^1.3.4", - "ripemd160": "^2.0.1", - "sha.js": "^2.4.0" + "cipher-base": "1.0.4", + "inherits": "2.0.3", + "md5.js": "1.3.4", + "ripemd160": "2.0.2", + "sha.js": "2.4.11" } }, "create-hmac": { @@ -1197,12 +1241,12 @@ "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { - "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" + "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" } }, "crypto-browserify": { @@ -1211,17 +1255,17 @@ "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { - "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" + "browserify-cipher": "1.0.1", + "browserify-sign": "4.0.4", + "create-ecdh": "4.0.1", + "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" } }, "css": { @@ -1230,10 +1274,10 @@ "integrity": "sha1-c6TIHehdtmTU7mdPfUcIXjstVdw=", "dev": true, "requires": { - "inherits": "^2.0.1", - "source-map": "^0.1.38", - "source-map-resolve": "^0.3.0", - "urix": "^0.1.0" + "inherits": "2.0.3", + "source-map": "0.1.43", + "source-map-resolve": "0.3.1", + "urix": "0.1.0" }, "dependencies": { "atob": { @@ -1248,7 +1292,7 @@ "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", "dev": true, "requires": { - "amdefine": ">=0.0.4" + "amdefine": "1.0.1" } }, "source-map-resolve": { @@ -1257,10 +1301,10 @@ "integrity": "sha1-YQ9hIqRFuN1RU1oqcbeD38Ekh2E=", "dev": true, "requires": { - "atob": "~1.1.0", - "resolve-url": "~0.2.1", - "source-map-url": "~0.3.0", - "urix": "~0.1.0" + "atob": "1.1.3", + "resolve-url": "0.2.1", + "source-map-url": "0.3.0", + "urix": "0.1.0" } }, "source-map-url": { @@ -1277,7 +1321,7 @@ "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "es5-ext": "^0.10.9" + "es5-ext": "0.10.42" } }, "date-now": { @@ -1307,9 +1351,9 @@ "integrity": "sha512-GZqvGIgKNlUnHUPQhepnUZFIMoi3dgZKQBzKDeL2g7oJF9SNAji/AAu36dusFUas0O+pae74lNeoIPHqXWDkLg==", "dev": true, "requires": { - "debug": "3.X", - "memoizee": "0.4.X", - "object-assign": "4.X" + "debug": "3.1.0", + "memoizee": "0.4.12", + "object-assign": "4.1.1" }, "dependencies": { "debug": { @@ -1342,7 +1386,7 @@ "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", "dev": true, "requires": { - "type-detect": "^4.0.0" + "type-detect": "4.0.8" } }, "deep-is": { @@ -1357,7 +1401,7 @@ "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", "dev": true, "requires": { - "clone": "^1.0.2" + "clone": "1.0.4" } }, "define-properties": { @@ -1366,8 +1410,8 @@ "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", "dev": true, "requires": { - "foreach": "^2.0.5", - "object-keys": "^1.0.8" + "foreach": "2.0.5", + "object-keys": "1.0.11" } }, "define-property": { @@ -1376,8 +1420,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": { @@ -1386,7 +1430,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-data-descriptor": { @@ -1395,7 +1439,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-descriptor": { @@ -1404,9 +1448,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" } } } @@ -1423,12 +1467,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.0", - "p-map": "^1.1.1", - "pify": "^3.0.0", - "rimraf": "^2.2.8" + "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" } }, "deprecated": { @@ -1443,10 +1487,10 @@ "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", "dev": true, "requires": { - "JSONStream": "^1.0.3", - "shasum": "^1.0.0", - "subarg": "^1.0.0", - "through2": "^2.0.0" + "JSONStream": "1.3.2", + "shasum": "1.0.2", + "subarg": "1.0.0", + "through2": "2.0.3" } }, "des.js": { @@ -1455,8 +1499,8 @@ "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", "dev": true, "requires": { - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" + "inherits": "2.0.3", + "minimalistic-assert": "1.0.1" } }, "detect-file": { @@ -1477,9 +1521,9 @@ "integrity": "sha512-TFHMqfOvxlgrfVzTEkNBSh9SvSNX/HfF4OFI2QFGCyPm02EsyILqnUeb5P6q7JZ3SFNTBL5t2sePRgrN4epUWQ==", "dev": true, "requires": { - "acorn-node": "^1.3.0", - "defined": "^1.0.0", - "minimist": "^1.1.1" + "acorn-node": "1.3.0", + "defined": "1.0.0", + "minimist": "1.2.0" } }, "diff": { @@ -1494,9 +1538,9 @@ "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { - "bn.js": "^4.1.0", - "miller-rabin": "^4.0.0", - "randombytes": "^2.0.0" + "bn.js": "4.11.8", + "miller-rabin": "4.0.1", + "randombytes": "2.0.6" } }, "domain-browser": { @@ -1511,7 +1555,7 @@ "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, "requires": { - "readable-stream": "^2.0.2" + "readable-stream": "2.3.6" } }, "duplexify": { @@ -1520,10 +1564,10 @@ "integrity": "sha512-JzYSLYMhoVVBe8+mbHQ4KgpvHpm0DZpJuL8PY93Vyv1fW7jYJ90LoXa1di/CVbJM+TgMs91rbDapE/RNIfnJsA==", "dev": true, "requires": { - "end-of-stream": "^1.0.0", - "inherits": "^2.0.1", - "readable-stream": "^2.0.0", - "stream-shift": "^1.0.0" + "end-of-stream": "1.4.1", + "inherits": "2.0.3", + "readable-stream": "2.3.6", + "stream-shift": "1.0.0" }, "dependencies": { "end-of-stream": { @@ -1532,7 +1576,7 @@ "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "dev": true, "requires": { - "once": "^1.4.0" + "once": "1.4.0" } } } @@ -1543,13 +1587,13 @@ "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", "dev": true, "requires": { - "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" + "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" } }, "end-of-stream": { @@ -1558,7 +1602,7 @@ "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", "dev": true, "requires": { - "once": "~1.3.0" + "once": "1.3.3" }, "dependencies": { "once": { @@ -1567,7 +1611,7 @@ "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", "dev": true, "requires": { - "wrappy": "1" + "wrappy": "1.0.2" } } } @@ -1578,9 +1622,9 @@ "integrity": "sha512-AJxO1rmPe1bDEfSR6TJ/FgMFYuTBhR5R57KW58iCkYACMyFbrkqVyzXSurYoScDGvgyMpk7uRF/lPUPPTmsRSA==", "dev": true, "requires": { - "es6-iterator": "~2.0.3", - "es6-symbol": "~3.1.1", - "next-tick": "1" + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1", + "next-tick": "1.0.0" } }, "es6-iterator": { @@ -1589,9 +1633,9 @@ "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", "dev": true, "requires": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" + "d": "1.0.0", + "es5-ext": "0.10.42", + "es6-symbol": "3.1.1" } }, "es6-promise": { @@ -1600,14 +1644,31 @@ "integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=", "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-symbol": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", "dev": true, "requires": { - "d": "1", - "es5-ext": "~0.10.14" + "d": "1.0.0", + "es5-ext": "0.10.42" } }, "es6-weak-map": { @@ -1616,10 +1677,10 @@ "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", "dev": true, "requires": { - "d": "1", - "es5-ext": "^0.10.14", - "es6-iterator": "^2.0.1", - "es6-symbol": "^3.1.1" + "d": "1.0.0", + "es5-ext": "0.10.42", + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1" } }, "escape-string-regexp": { @@ -1634,11 +1695,11 @@ "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", "dev": true, "requires": { - "esprima": "^2.7.1", - "estraverse": "^1.9.1", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.2.0" + "esprima": "2.7.3", + "estraverse": "1.9.3", + "esutils": "2.0.2", + "optionator": "0.8.2", + "source-map": "0.2.0" }, "dependencies": { "source-map": { @@ -1648,7 +1709,7 @@ "dev": true, "optional": true, "requires": { - "amdefine": ">=0.0.4" + "amdefine": "1.0.1" } } } @@ -1677,8 +1738,8 @@ "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", "dev": true, "requires": { - "d": "1", - "es5-ext": "~0.10.14" + "d": "1.0.0", + "es5-ext": "0.10.42" } }, "events": { @@ -1693,8 +1754,8 @@ "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { - "md5.js": "^1.3.4", - "safe-buffer": "^5.1.1" + "md5.js": "1.3.4", + "safe-buffer": "5.1.2" } }, "expand-brackets": { @@ -1703,13 +1764,13 @@ "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "define-property": { @@ -1718,7 +1779,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } }, "extend-shallow": { @@ -1727,7 +1788,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -1738,7 +1799,7 @@ "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", "dev": true, "requires": { - "homedir-polyfill": "^1.0.1" + "homedir-polyfill": "1.0.1" } }, "extend": { @@ -1753,8 +1814,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": { @@ -1763,7 +1824,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "^2.0.4" + "is-plain-object": "2.0.4" } } } @@ -1774,14 +1835,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.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" + "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" }, "dependencies": { "define-property": { @@ -1790,7 +1851,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "^1.0.0" + "is-descriptor": "1.0.2" } }, "extend-shallow": { @@ -1799,7 +1860,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } }, "is-accessor-descriptor": { @@ -1808,7 +1869,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-data-descriptor": { @@ -1817,7 +1878,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-descriptor": { @@ -1826,9 +1887,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" } } } @@ -1839,9 +1900,9 @@ "integrity": "sha1-9BEl49hPLn2JpD0G2VjI94vha+E=", "dev": true, "requires": { - "ansi-gray": "^0.1.1", - "color-support": "^1.1.3", - "time-stamp": "^1.0.0" + "ansi-gray": "0.1.1", + "color-support": "1.1.3", + "time-stamp": "1.1.0" } }, "fast-levenshtein": { @@ -1856,8 +1917,8 @@ "integrity": "sha1-WKZBrR9XV0on/oekQO8xiDS1Vxk=", "dev": true, "requires": { - "minimatch": "^3.0.3", - "utilities": "^0.0.37" + "minimatch": "3.0.4", + "utilities": "0.0.37" }, "dependencies": { "utilities": { @@ -1874,10 +1935,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.0" + "extend-shallow": "2.0.1", + "is-number": "3.0.0", + "repeat-string": "1.6.1", + "to-regex-range": "2.1.1" }, "dependencies": { "extend-shallow": { @@ -1886,7 +1947,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -1903,10 +1964,10 @@ "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", "dev": true, "requires": { - "detect-file": "^1.0.0", - "is-glob": "^3.1.0", - "micromatch": "^3.0.4", - "resolve-dir": "^1.0.1" + "detect-file": "1.0.0", + "is-glob": "3.1.0", + "micromatch": "3.1.10", + "resolve-dir": "1.0.1" } }, "fined": { @@ -1915,11 +1976,11 @@ "integrity": "sha1-s33IRLdqL15wgeiE98CuNE8VNHY=", "dev": true, "requires": { - "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" + "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" } }, "first-chunk-stream": { @@ -1940,8 +2001,8 @@ "integrity": "sha512-calZMC10u0FMUqoiunI2AiGIIUtUIvifNwkHhNupZH4cbNnW1Itkoh/Nf5HFYmDrwWPjrUxpkZT0KhuCq0jmGw==", "dev": true, "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.4" + "inherits": "2.0.3", + "readable-stream": "2.3.6" } }, "for-in": { @@ -1956,7 +2017,7 @@ "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", "dev": true, "requires": { - "for-in": "^1.0.1" + "for-in": "1.0.2" } }, "foreach": { @@ -1971,7 +2032,7 @@ "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, "requires": { - "map-cache": "^0.2.2" + "map-cache": "0.2.2" } }, "fs-mkdirp-stream": { @@ -1980,8 +2041,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": { @@ -2010,7 +2071,7 @@ "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", "dev": true, "requires": { - "globule": "~0.1.0" + "globule": "0.1.0" } }, "get-func-name": { @@ -2031,12 +2092,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "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" + "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" } }, "glob-parent": { @@ -2045,8 +2106,8 @@ "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", "dev": true, "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" + "is-glob": "3.1.0", + "path-dirname": "1.0.2" } }, "glob-stream": { @@ -2055,12 +2116,12 @@ "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "glob": { @@ -2069,10 +2130,10 @@ "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", "dev": true, "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^2.0.1", - "once": "^1.3.0" + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "2.0.10", + "once": "1.4.0" } }, "isarray": { @@ -2087,7 +2148,7 @@ "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", "dev": true, "requires": { - "brace-expansion": "^1.0.0" + "brace-expansion": "1.1.11" } }, "readable-stream": { @@ -2096,10 +2157,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", + "core-util-is": "1.0.2", + "inherits": "2.0.3", "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "string_decoder": "0.10.31" } }, "string_decoder": { @@ -2114,8 +2175,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" + "readable-stream": "1.0.34", + "xtend": "4.0.1" } } } @@ -2126,7 +2187,7 @@ "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", "dev": true, "requires": { - "gaze": "^0.5.1" + "gaze": "0.5.2" } }, "glob2base": { @@ -2135,7 +2196,7 @@ "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", "dev": true, "requires": { - "find-index": "^0.1.1" + "find-index": "0.1.1" } }, "global-modules": { @@ -2144,9 +2205,9 @@ "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", "dev": true, "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" + "global-prefix": "1.0.2", + "is-windows": "1.0.2", + "resolve-dir": "1.0.1" } }, "global-prefix": { @@ -2155,11 +2216,11 @@ "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", "dev": true, "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" + "expand-tilde": "2.0.2", + "homedir-polyfill": "1.0.1", + "ini": "1.3.5", + "is-windows": "1.0.2", + "which": "1.3.0" } }, "globby": { @@ -2168,11 +2229,11 @@ "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { - "array-union": "^1.0.1", - "glob": "^7.0.3", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" + "array-union": "1.0.2", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" }, "dependencies": { "pify": { @@ -2189,9 +2250,9 @@ "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", "dev": true, "requires": { - "glob": "~3.1.21", - "lodash": "~1.0.1", - "minimatch": "~0.2.11" + "glob": "3.1.21", + "lodash": "1.0.2", + "minimatch": "0.2.14" }, "dependencies": { "glob": { @@ -2200,9 +2261,9 @@ "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", "dev": true, "requires": { - "graceful-fs": "~1.2.0", - "inherits": "1", - "minimatch": "~0.2.11" + "graceful-fs": "1.2.3", + "inherits": "1.0.2", + "minimatch": "0.2.14" } }, "graceful-fs": { @@ -2223,8 +2284,8 @@ "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", "dev": true, "requires": { - "lru-cache": "2", - "sigmund": "~1.0.0" + "lru-cache": "2.7.3", + "sigmund": "1.0.1" } } } @@ -2235,7 +2296,7 @@ "integrity": "sha512-ynYqXLoluBKf9XGR1gA59yEJisIL7YHEH4xr3ZziHB5/yl4qWfaK8Js9jGe6gBGCSCKVqiyO30WnRZADvemUNw==", "dev": true, "requires": { - "sparkles": "^1.0.0" + "sparkles": "1.0.0" } }, "graceful-fs": { @@ -2244,7 +2305,7 @@ "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", "dev": true, "requires": { - "natives": "^1.1.0" + "natives": "1.1.3" } }, "growl": { @@ -2259,19 +2320,19 @@ "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "ansi-styles": { @@ -2286,11 +2347,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "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" + "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" } }, "supports-color": { @@ -2307,8 +2368,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" } }, "gulp-concat": { @@ -2317,9 +2378,9 @@ "integrity": "sha1-Yz0WyV2IUEYorQJmVmPO5aR5M1M=", "dev": true, "requires": { - "concat-with-sourcemaps": "^1.0.0", - "through2": "^2.0.0", - "vinyl": "^2.0.0" + "concat-with-sourcemaps": "1.0.7", + "through2": "2.0.3", + "vinyl": "2.1.0" } }, "gulp-help": { @@ -2328,8 +2389,8 @@ "integrity": "sha1-Jh2xhuGDl/7z9qLCLpwxW/qIrgw=", "dev": true, "requires": { - "chalk": "^1.0.0", - "object-assign": "^3.0.0" + "chalk": "1.1.3", + "object-assign": "3.0.0" }, "dependencies": { "ansi-styles": { @@ -2344,11 +2405,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "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" + "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" } }, "object-assign": { @@ -2371,7 +2432,7 @@ "integrity": "sha1-MjE/E+SiPPWsylzl8MCAkjx3hgI=", "dev": true, "requires": { - "readable-stream": "^1.0.26-4", + "readable-stream": "1.1.14", "streamqueue": "0.0.6" }, "dependencies": { @@ -2387,10 +2448,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", + "core-util-is": "1.0.2", + "inherits": "2.0.3", "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "string_decoder": "0.10.31" } }, "string_decoder": { @@ -2407,9 +2468,9 @@ "integrity": "sha512-h79fGO55S/P9eAADbLAP9aTtVYpLSR1ONj08VPaSdVVNVYhTS8p1CO1TW7kEMu+hC+sytmCqcUr5LesvZEtDoQ==", "dev": true, "requires": { - "glob": "^7.0.3", - "kew": "^0.7.0", - "plugin-error": "^0.1.2" + "glob": "7.1.2", + "kew": "0.7.0", + "plugin-error": "0.1.2" } }, "gulp-sourcemaps": { @@ -2418,17 +2479,17 @@ "integrity": "sha1-y7IAhFCxvM5s0jv5gze+dRv24wo=", "dev": true, "requires": { - "@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" + "@gulp-sourcemaps/identity-map": "1.0.1", + "@gulp-sourcemaps/map-sources": "1.0.0", + "acorn": "5.5.3", + "convert-source-map": "1.5.1", + "css": "2.2.1", + "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" }, "dependencies": { "acorn": { @@ -2457,12 +2518,12 @@ "integrity": "sha512-Hhbn5Aa2l3T+tnn0KqsG6RRJmcYEsr3byTL2nBpNBeAK8pqug9Od4AwddU4JEI+hRw7mzZyjRbB8DDWR6paGVA==", "dev": true, "requires": { - "ansi-colors": "^1.0.1", - "plugin-error": "^0.1.2", - "source-map": "^0.6.1", - "through2": "^2.0.3", - "vinyl": "^2.1.0", - "vinyl-fs": "^3.0.0" + "ansi-colors": "1.1.0", + "plugin-error": "0.1.2", + "source-map": "0.6.1", + "through2": "2.0.3", + "vinyl": "2.1.0", + "vinyl-fs": "3.0.2" }, "dependencies": { "glob-stream": { @@ -2471,16 +2532,16 @@ "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", "dev": true, "requires": { - "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" + "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.4.0", + "readable-stream": "2.3.6", + "remove-trailing-separator": "1.1.0", + "to-absolute-glob": "2.0.2", + "unique-stream": "2.2.1" } }, "graceful-fs": { @@ -2495,7 +2556,7 @@ "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "dev": true, "requires": { - "jsonify": "~0.0.0" + "jsonify": "0.0.0" } }, "ordered-read-streams": { @@ -2504,7 +2565,7 @@ "integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=", "dev": true, "requires": { - "readable-stream": "^2.0.1" + "readable-stream": "2.3.6" } }, "source-map": { @@ -2519,8 +2580,8 @@ "integrity": "sha1-WqADz76Uxf+GbE59ZouxxNuts2k=", "dev": true, "requires": { - "json-stable-stringify": "^1.0.0", - "through2-filter": "^2.0.0" + "json-stable-stringify": "1.0.1", + "through2-filter": "2.0.0" } }, "vinyl-fs": { @@ -2529,23 +2590,23 @@ "integrity": "sha512-AUSFda1OukBwuLPBTbyuO4IRWgfXmqC4UTW0f8xrCa8Hkv9oyIU+NSqBlgfOLZRoUt7cHdo75hKQghCywpIyIw==", "dev": true, "requires": { - "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" + "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.4.0", + "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" } } } @@ -2556,24 +2617,24 @@ "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", "dev": true, "requires": { - "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", + "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", "replace-ext": "0.0.1", - "through2": "^2.0.0", - "vinyl": "^0.5.0" + "through2": "2.0.3", + "vinyl": "0.5.3" }, "dependencies": { "ansi-styles": { @@ -2588,11 +2649,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "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" + "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" } }, "object-assign": { @@ -2613,8 +2674,8 @@ "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", "dev": true, "requires": { - "clone": "^1.0.0", - "clone-stats": "^0.0.1", + "clone": "1.0.4", + "clone-stats": "0.0.1", "replace-ext": "0.0.1" } } @@ -2626,7 +2687,7 @@ "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", "dev": true, "requires": { - "glogg": "^1.0.0" + "glogg": "1.0.1" } }, "handlebars": { @@ -2635,10 +2696,10 @@ "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", "dev": true, "requires": { - "async": "^1.4.0", - "optimist": "^0.6.1", - "source-map": "^0.4.4", - "uglify-js": "^2.6" + "async": "1.5.2", + "optimist": "0.6.1", + "source-map": "0.4.4", + "uglify-js": "2.8.29" }, "dependencies": { "source-map": { @@ -2647,7 +2708,7 @@ "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { - "amdefine": ">=0.0.4" + "amdefine": "1.0.1" } } } @@ -2658,7 +2719,7 @@ "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", "dev": true, "requires": { - "function-bind": "^1.0.2" + "function-bind": "1.1.1" } }, "has-ansi": { @@ -2667,7 +2728,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "has-color": { @@ -2688,7 +2749,7 @@ "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", "dev": true, "requires": { - "sparkles": "^1.0.0" + "sparkles": "1.0.0" } }, "has-symbols": { @@ -2703,9 +2764,9 @@ "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" + "get-value": "2.0.6", + "has-values": "1.0.0", + "isobject": "3.0.1" } }, "has-values": { @@ -2714,8 +2775,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": { @@ -2724,7 +2785,7 @@ "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -2735,8 +2796,8 @@ "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" + "inherits": "2.0.3", + "safe-buffer": "5.1.2" } }, "hash.js": { @@ -2745,8 +2806,8 @@ "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", "dev": true, "requires": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" + "inherits": "2.0.3", + "minimalistic-assert": "1.0.1" } }, "he": { @@ -2761,9 +2822,9 @@ "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", "dev": true, "requires": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" + "hash.js": "1.1.3", + "minimalistic-assert": "1.0.1", + "minimalistic-crypto-utils": "1.0.1" } }, "homedir-polyfill": { @@ -2772,7 +2833,7 @@ "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", "dev": true, "requires": { - "parse-passwd": "^1.0.0" + "parse-passwd": "1.0.0" } }, "htmlescape": { @@ -2781,12 +2842,54 @@ "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", "dev": true }, + "http-proxy-agent": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", + "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", + "dev": true, + "requires": { + "agent-base": "4.2.0", + "debug": "3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, "https-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, + "https-proxy-agent": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", + "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", + "dev": true, + "requires": { + "agent-base": "4.2.0", + "debug": "3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } + } + }, "ieee754": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.11.tgz", @@ -2799,8 +2902,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "^1.3.0", - "wrappy": "1" + "once": "1.4.0", + "wrappy": "1.0.2" } }, "inherits": { @@ -2821,7 +2924,7 @@ "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", "dev": true, "requires": { - "source-map": "~0.5.3" + "source-map": "0.5.7" } }, "insert-module-globals": { @@ -2830,15 +2933,15 @@ "integrity": "sha512-R3sidKJr3SsggqQQ5cEwQb3pWG8RNx0UnpyeiOSR6jorRIeAOzH2gkTWnNdMnyRiVbjrG047K7UCtlMkQ1Mo9w==", "dev": true, "requires": { - "JSONStream": "^1.0.3", - "combine-source-map": "^0.8.0", - "concat-stream": "^1.6.1", - "is-buffer": "^1.1.0", - "lexical-scope": "^1.2.0", - "path-is-absolute": "^1.0.1", - "process": "~0.11.0", - "through2": "^2.0.0", - "xtend": "^4.0.0" + "combine-source-map": "0.8.0", + "concat-stream": "1.6.2", + "is-buffer": "1.1.6", + "JSONStream": "1.3.2", + "lexical-scope": "1.2.0", + "path-is-absolute": "1.0.1", + "process": "0.11.10", + "through2": "2.0.3", + "xtend": "4.0.1" } }, "interpret": { @@ -2853,8 +2956,8 @@ "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", "dev": true, "requires": { - "is-relative": "^1.0.0", - "is-windows": "^1.0.1" + "is-relative": "1.0.0", + "is-windows": "1.0.2" } }, "is-accessor-descriptor": { @@ -2863,7 +2966,7 @@ "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -2872,7 +2975,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -2889,7 +2992,7 @@ "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -2898,7 +3001,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -2909,9 +3012,9 @@ "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" + "is-accessor-descriptor": "0.1.6", + "is-data-descriptor": "0.1.4", + "kind-of": "5.1.0" }, "dependencies": { "kind-of": { @@ -2940,7 +3043,7 @@ "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", "dev": true, "requires": { - "is-extglob": "^2.1.0" + "is-extglob": "2.1.1" } }, "is-negated-glob": { @@ -2955,7 +3058,7 @@ "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -2964,7 +3067,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -2975,7 +3078,7 @@ "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", "dev": true, "requires": { - "is-number": "^4.0.0" + "is-number": "4.0.0" }, "dependencies": { "is-number": { @@ -2998,7 +3101,7 @@ "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", "dev": true, "requires": { - "is-path-inside": "^1.0.0" + "is-path-inside": "1.0.1" } }, "is-path-inside": { @@ -3007,7 +3110,7 @@ "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { - "path-is-inside": "^1.0.1" + "path-is-inside": "1.0.2" } }, "is-plain-object": { @@ -3016,7 +3119,7 @@ "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, "requires": { - "isobject": "^3.0.1" + "isobject": "3.0.1" } }, "is-promise": { @@ -3031,7 +3134,7 @@ "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", "dev": true, "requires": { - "is-unc-path": "^1.0.0" + "is-unc-path": "1.0.0" } }, "is-unc-path": { @@ -3040,7 +3143,7 @@ "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", "dev": true, "requires": { - "unc-path-regex": "^0.1.2" + "unc-path-regex": "0.1.2" } }, "is-utf8": { @@ -3085,20 +3188,20 @@ "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "glob": { @@ -3107,11 +3210,11 @@ "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "dev": true, "requires": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^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" } }, "has-flag": { @@ -3126,7 +3229,7 @@ "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", "dev": true, "requires": { - "has-flag": "^1.0.0" + "has-flag": "1.0.0" } } } @@ -3137,11 +3240,11 @@ "integrity": "sha512-qUTOVCKFkiz3tHgV1WMy7HTxDZgo+sO4X9GxFLAU+Mks4WsDGe9+ONHK6tPsSp8I3x6sPl0TwGbXHwTOhTyzog==", "dev": true, "requires": { - "async": "0.9.x", - "chalk": "0.4.x", - "filelist": "0.0.x", - "minimatch": "3.x", - "utilities": "1.0.x" + "async": "0.9.2", + "chalk": "0.4.0", + "filelist": "0.0.6", + "minimatch": "3.0.4", + "utilities": "1.0.5" }, "dependencies": { "ansi-styles": { @@ -3162,9 +3265,9 @@ "integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=", "dev": true, "requires": { - "ansi-styles": "~1.0.0", - "has-color": "~0.1.0", - "strip-ansi": "~0.1.0" + "ansi-styles": "1.0.0", + "has-color": "0.1.7", + "strip-ansi": "0.1.1" } }, "strip-ansi": { @@ -3187,8 +3290,8 @@ "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" + "argparse": "1.0.10", + "esprima": "4.0.0" }, "dependencies": { "esprima": { @@ -3205,7 +3308,7 @@ "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", "dev": true, "requires": { - "jsonify": "~0.0.0" + "jsonify": "0.0.0" } }, "jsonify": { @@ -3220,6 +3323,16 @@ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, + "JSONStream": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", + "integrity": "sha1-wQI3G27Dp887hHygDCC7D85Mbeo=", + "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", @@ -3238,9 +3351,9 @@ "integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==", "dev": true, "requires": { - "inherits": "^2.0.1", - "isarray": "^2.0.4", - "stream-splicer": "^2.0.0" + "inherits": "2.0.3", + "isarray": "2.0.4", + "stream-splicer": "2.0.0" }, "dependencies": { "isarray": { @@ -3264,7 +3377,7 @@ "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", "dev": true, "requires": { - "readable-stream": "^2.0.5" + "readable-stream": "2.3.6" } }, "lead": { @@ -3273,7 +3386,7 @@ "integrity": "sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI=", "dev": true, "requires": { - "flush-write-stream": "^1.0.2" + "flush-write-stream": "1.0.3" } }, "levn": { @@ -3282,8 +3395,8 @@ "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true, "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "prelude-ls": "1.1.2", + "type-check": "0.3.2" } }, "lexical-scope": { @@ -3292,7 +3405,7 @@ "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", "dev": true, "requires": { - "astw": "^2.0.0" + "astw": "2.2.0" } }, "liftoff": { @@ -3301,14 +3414,14 @@ "integrity": "sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew=", "dev": true, "requires": { - "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" + "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" } }, "lodash": { @@ -3377,7 +3490,7 @@ "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", "dev": true, "requires": { - "lodash._root": "^3.0.0" + "lodash._root": "3.0.1" } }, "lodash.isarguments": { @@ -3398,9 +3511,9 @@ "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", "dev": true, "requires": { - "lodash._getnative": "^3.0.0", - "lodash.isarguments": "^3.0.0", - "lodash.isarray": "^3.0.0" + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" } }, "lodash.memoize": { @@ -3421,15 +3534,15 @@ "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", "dev": true, "requires": { - "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._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.templatesettings": { @@ -3438,8 +3551,8 @@ "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", "dev": true, "requires": { - "lodash._reinterpolate": "^3.0.0", - "lodash.escape": "^3.0.0" + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0" } }, "longest": { @@ -3460,7 +3573,7 @@ "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", "dev": true, "requires": { - "es5-ext": "~0.10.2" + "es5-ext": "0.10.42" } }, "make-iterator": { @@ -3469,7 +3582,7 @@ "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", "dev": true, "requires": { - "kind-of": "^6.0.2" + "kind-of": "6.0.2" } }, "map-cache": { @@ -3484,7 +3597,7 @@ "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, "requires": { - "object-visit": "^1.0.0" + "object-visit": "1.0.1" } }, "md5.js": { @@ -3493,8 +3606,8 @@ "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", "dev": true, "requires": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1" + "hash-base": "3.0.4", + "inherits": "2.0.3" } }, "memoizee": { @@ -3503,14 +3616,14 @@ "integrity": "sha512-sprBu6nwxBWBvBOh5v2jcsGqiGLlL2xr2dLub3vR8dnE8YB17omwtm/0NSHl8jjNbcsJd5GMWJAnTSVe/O0Wfg==", "dev": true, "requires": { - "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" + "d": "1.0.0", + "es5-ext": "0.10.42", + "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" } }, "merge2": { @@ -3525,19 +3638,19 @@ "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { - "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" + "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" } }, "miller-rabin": { @@ -3546,8 +3659,8 @@ "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, "requires": { - "bn.js": "^4.0.0", - "brorand": "^1.0.1" + "bn.js": "4.11.8", + "brorand": "1.1.0" } }, "minimalistic-assert": { @@ -3568,7 +3681,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "1.1.11" } }, "minimist": { @@ -3583,8 +3696,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": { @@ -3593,7 +3706,7 @@ "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { - "is-plain-object": "^2.0.4" + "is-plain-object": "2.0.4" } } } @@ -3655,7 +3768,7 @@ "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", "dev": true, "requires": { - "has-flag": "^2.0.0" + "has-flag": "2.0.0" } } } @@ -3672,21 +3785,21 @@ "integrity": "sha512-KWBI3009iRnHjRlxRhe8nJ6kdeBTg4sMi5N6AZgg5f1/v5S7EBCRBOY854I4P5Anl4kx6AJH+4bBBC2Gi3nkvg==", "dev": true, "requires": { - "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" + "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.2", + "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" }, "dependencies": { "resolve": { @@ -3695,7 +3808,7 @@ "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "path-parse": "1.0.5" } } } @@ -3721,7 +3834,7 @@ "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", "dev": true, "requires": { - "readable-stream": "~1.1.9" + "readable-stream": "1.1.14" } }, "isarray": { @@ -3736,10 +3849,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", + "core-util-is": "1.0.2", + "inherits": "2.0.3", "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "string_decoder": "0.10.31" } }, "string_decoder": { @@ -3756,18 +3869,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.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" + "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" } }, "natives": { @@ -3782,13 +3895,19 @@ "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, + "node-fetch": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz", + "integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=", + "dev": true + }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "dev": true, "requires": { - "abbrev": "1" + "abbrev": "1.0.9" } }, "normalize-path": { @@ -3797,7 +3916,7 @@ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "remove-trailing-separator": "^1.0.1" + "remove-trailing-separator": "1.1.0" } }, "now-and-later": { @@ -3806,7 +3925,7 @@ "integrity": "sha1-vGHLtFbXnLMiB85HygUTb/Ln1u4=", "dev": true, "requires": { - "once": "^1.3.2" + "once": "1.4.0" } }, "object-assign": { @@ -3821,9 +3940,9 @@ "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" + "copy-descriptor": "0.1.1", + "define-property": "0.2.5", + "kind-of": "3.2.2" }, "dependencies": { "define-property": { @@ -3832,7 +3951,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } }, "kind-of": { @@ -3841,7 +3960,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -3858,7 +3977,7 @@ "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, "requires": { - "isobject": "^3.0.0" + "isobject": "3.0.1" } }, "object.assign": { @@ -3867,10 +3986,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.11" + "define-properties": "1.1.2", + "function-bind": "1.1.1", + "has-symbols": "1.0.0", + "object-keys": "1.0.11" } }, "object.defaults": { @@ -3879,10 +3998,10 @@ "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", "dev": true, "requires": { - "array-each": "^1.0.1", - "array-slice": "^1.0.0", - "for-own": "^1.0.0", - "isobject": "^3.0.0" + "array-each": "1.0.1", + "array-slice": "1.1.0", + "for-own": "1.0.0", + "isobject": "3.0.1" } }, "object.map": { @@ -3891,8 +4010,8 @@ "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", "dev": true, "requires": { - "for-own": "^1.0.0", - "make-iterator": "^1.0.0" + "for-own": "1.0.0", + "make-iterator": "1.0.1" } }, "object.pick": { @@ -3901,7 +4020,7 @@ "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, "requires": { - "isobject": "^3.0.1" + "isobject": "3.0.1" } }, "once": { @@ -3910,7 +4029,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1" + "wrappy": "1.0.2" } }, "optimist": { @@ -3919,8 +4038,8 @@ "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "requires": { - "minimist": "~0.0.1", - "wordwrap": "~0.0.2" + "minimist": "0.0.10", + "wordwrap": "0.0.3" }, "dependencies": { "minimist": { @@ -3943,12 +4062,12 @@ "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "dev": true, "requires": { - "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" + "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" } }, "orchestrator": { @@ -3957,9 +4076,9 @@ "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", "dev": true, "requires": { - "end-of-stream": "~0.1.5", - "sequencify": "~0.0.7", - "stream-consume": "~0.1.0" + "end-of-stream": "0.1.5", + "sequencify": "0.0.7", + "stream-consume": "0.1.1" } }, "ordered-read-streams": { @@ -3998,7 +4117,7 @@ "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", "dev": true, "requires": { - "path-platform": "~0.11.15" + "path-platform": "0.11.15" } }, "parse-asn1": { @@ -4007,11 +4126,11 @@ "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "dev": true, "requires": { - "asn1.js": "^4.0.0", - "browserify-aes": "^1.0.0", - "create-hash": "^1.1.0", - "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3" + "asn1.js": "4.10.1", + "browserify-aes": "1.2.0", + "create-hash": "1.2.0", + "evp_bytestokey": "1.0.3", + "pbkdf2": "3.0.16" } }, "parse-filepath": { @@ -4020,9 +4139,9 @@ "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", "dev": true, "requires": { - "is-absolute": "^1.0.0", - "map-cache": "^0.2.0", - "path-root": "^0.1.1" + "is-absolute": "1.0.0", + "map-cache": "0.2.2", + "path-root": "0.1.1" } }, "parse-passwd": { @@ -4079,7 +4198,7 @@ "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", "dev": true, "requires": { - "path-root-regex": "^0.1.0" + "path-root-regex": "0.1.2" } }, "path-root-regex": { @@ -4100,11 +4219,11 @@ "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", "dev": true, "requires": { - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4", - "ripemd160": "^2.0.1", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" + "create-hash": "1.2.0", + "create-hmac": "1.1.7", + "ripemd160": "2.0.2", + "safe-buffer": "5.1.2", + "sha.js": "2.4.11" } }, "pify": { @@ -4125,7 +4244,7 @@ "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, "requires": { - "pinkie": "^2.0.0" + "pinkie": "2.0.4" } }, "plugin-error": { @@ -4134,11 +4253,11 @@ "integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "arr-diff": { @@ -4147,8 +4266,8 @@ "integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=", "dev": true, "requires": { - "arr-flatten": "^1.0.1", - "array-slice": "^0.2.3" + "arr-flatten": "1.1.0", + "array-slice": "0.2.3" } }, "arr-union": { @@ -4169,7 +4288,7 @@ "integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=", "dev": true, "requires": { - "kind-of": "^1.1.0" + "kind-of": "1.1.0" } }, "kind-of": { @@ -4216,11 +4335,11 @@ "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", "dev": true, "requires": { - "bn.js": "^4.1.0", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1" + "bn.js": "4.11.8", + "browserify-rsa": "4.0.1", + "create-hash": "1.2.0", + "parse-asn1": "5.1.1", + "randombytes": "2.0.6" } }, "pump": { @@ -4229,8 +4348,8 @@ "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", "dev": true, "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" + "end-of-stream": "1.4.1", + "once": "1.4.0" }, "dependencies": { "end-of-stream": { @@ -4239,7 +4358,7 @@ "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "dev": true, "requires": { - "once": "^1.4.0" + "once": "1.4.0" } } } @@ -4250,9 +4369,9 @@ "integrity": "sha512-2kmNR9ry+Pf45opRVirpNuIFotsxUGLaYqxIwuR77AYrYRMuFCz9eryHBS52L360O+NcR383CL4QYlMKPq4zYA==", "dev": true, "requires": { - "duplexify": "^3.5.3", - "inherits": "^2.0.3", - "pump": "^2.0.0" + "duplexify": "3.5.4", + "inherits": "2.0.3", + "pump": "2.0.1" } }, "punycode": { @@ -4285,7 +4404,7 @@ "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", "dev": true, "requires": { - "safe-buffer": "^5.1.0" + "safe-buffer": "5.1.2" } }, "randomfill": { @@ -4294,8 +4413,8 @@ "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, "requires": { - "randombytes": "^2.0.5", - "safe-buffer": "^5.1.0" + "randombytes": "2.0.6", + "safe-buffer": "5.1.2" } }, "read-only-stream": { @@ -4304,7 +4423,7 @@ "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", "dev": true, "requires": { - "readable-stream": "^2.0.2" + "readable-stream": "2.3.6" } }, "readable-stream": { @@ -4313,13 +4432,13 @@ "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { - "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" + "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" } }, "rechoir": { @@ -4328,7 +4447,7 @@ "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "dev": true, "requires": { - "resolve": "^1.1.6" + "resolve": "1.1.7" } }, "regex-not": { @@ -4337,8 +4456,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": { @@ -4347,8 +4466,8 @@ "integrity": "sha512-8v2rWhaakv18qcvNeli2mZ/TMTL2nEyAKRvzo1WtnZBl15SHyEhrCu2/xKlJyUFKHiHgfXIyuY6g2dObJJycXQ==", "dev": true, "requires": { - "is-buffer": "^1.1.5", - "is-utf8": "^0.2.1" + "is-buffer": "1.1.6", + "is-utf8": "0.2.1" } }, "remove-bom-stream": { @@ -4357,9 +4476,9 @@ "integrity": "sha1-BfGlk/FuQuH7kOv1nejlaVJflSM=", "dev": true, "requires": { - "remove-bom-buffer": "^3.0.0", - "safe-buffer": "^5.1.0", - "through2": "^2.0.3" + "remove-bom-buffer": "3.0.0", + "safe-buffer": "5.1.2", + "through2": "2.0.3" } }, "remove-trailing-separator": { @@ -4398,8 +4517,8 @@ "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", "dev": true, "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" + "expand-tilde": "2.0.2", + "global-modules": "1.0.0" } }, "resolve-options": { @@ -4408,7 +4527,7 @@ "integrity": "sha1-MrueOcBtZzONyTeMDW1gdFZq0TE=", "dev": true, "requires": { - "value-or-function": "^3.0.0" + "value-or-function": "3.0.0" } }, "resolve-url": { @@ -4430,7 +4549,7 @@ "dev": true, "optional": true, "requires": { - "align-text": "^0.1.1" + "align-text": "0.1.4" } }, "rimraf": { @@ -4439,7 +4558,7 @@ "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { - "glob": "^7.0.5" + "glob": "7.1.2" } }, "ripemd160": { @@ -4448,8 +4567,8 @@ "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { - "hash-base": "^3.0.0", - "inherits": "^2.0.1" + "hash-base": "3.0.4", + "inherits": "2.0.3" } }, "run-sequence": { @@ -4458,9 +4577,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": { @@ -4475,11 +4594,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "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" + "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" } }, "supports-color": { @@ -4502,7 +4621,7 @@ "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, "requires": { - "ret": "~0.1.10" + "ret": "0.1.15" } }, "sander": { @@ -4511,10 +4630,10 @@ "integrity": "sha1-dB4kXiMfB8r7b98PEzrfohalAq0=", "dev": true, "requires": { - "es6-promise": "^3.1.2", - "graceful-fs": "^4.1.3", - "mkdirp": "^0.5.1", - "rimraf": "^2.5.2" + "es6-promise": "3.3.1", + "graceful-fs": "4.1.11", + "mkdirp": "0.5.1", + "rimraf": "2.6.2" }, "dependencies": { "graceful-fs": { @@ -4549,10 +4668,10 @@ "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "dev": true, "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "split-string": "3.1.0" }, "dependencies": { "extend-shallow": { @@ -4561,7 +4680,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -4572,8 +4691,8 @@ "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" + "inherits": "2.0.3", + "safe-buffer": "5.1.2" } }, "shasum": { @@ -4582,8 +4701,8 @@ "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", "dev": true, "requires": { - "json-stable-stringify": "~0.0.0", - "sha.js": "~2.4.4" + "json-stable-stringify": "0.0.1", + "sha.js": "2.4.11" } }, "shell-quote": { @@ -4592,10 +4711,10 @@ "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", "dev": true, "requires": { - "array-filter": "~0.0.0", - "array-map": "~0.0.0", - "array-reduce": "~0.0.0", - "jsonify": "~0.0.0" + "array-filter": "0.0.1", + "array-map": "0.0.0", + "array-reduce": "0.0.0", + "jsonify": "0.0.0" } }, "sigmund": { @@ -4610,14 +4729,14 @@ "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "define-property": { @@ -4626,7 +4745,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } }, "extend-shallow": { @@ -4635,7 +4754,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } } } @@ -4646,9 +4765,9 @@ "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" + "define-property": "1.0.0", + "isobject": "3.0.1", + "snapdragon-util": "3.0.1" }, "dependencies": { "define-property": { @@ -4657,7 +4776,7 @@ "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, "requires": { - "is-descriptor": "^1.0.0" + "is-descriptor": "1.0.2" } }, "is-accessor-descriptor": { @@ -4666,7 +4785,7 @@ "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-data-descriptor": { @@ -4675,7 +4794,7 @@ "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "6.0.2" } }, "is-descriptor": { @@ -4684,9 +4803,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" } } } @@ -4697,7 +4816,7 @@ "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, "requires": { - "kind-of": "^3.2.0" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -4706,7 +4825,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -4717,10 +4836,10 @@ "integrity": "sha1-iukK19fLBfxZ8asMY3hF1cFaUrc=", "dev": true, "requires": { - "buffer-crc32": "^0.2.5", - "minimist": "^1.2.0", - "sander": "^0.5.0", - "sourcemap-codec": "^1.3.0" + "buffer-crc32": "0.2.13", + "minimist": "1.2.0", + "sander": "0.5.1", + "sourcemap-codec": "1.4.1" } }, "source-map": { @@ -4735,11 +4854,11 @@ "integrity": "sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A==", "dev": true, "requires": { - "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" + "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" } }, "source-map-support": { @@ -4748,8 +4867,8 @@ "integrity": "sha512-mR7/Nd5l1z6g99010shcXJiNEaf3fEtmLhRB/sBcQVJGodcHCULPp2y4Sfa43Kv2zq7T+Izmfp/WHCR6dYkQCA==", "dev": true, "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" + "buffer-from": "1.0.0", + "source-map": "0.6.1" }, "dependencies": { "source-map": { @@ -4784,7 +4903,7 @@ "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, "requires": { - "extend-shallow": "^3.0.0" + "extend-shallow": "3.0.2" } }, "sprintf-js": { @@ -4799,8 +4918,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": { @@ -4809,7 +4928,7 @@ "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, "requires": { - "is-descriptor": "^0.1.0" + "is-descriptor": "0.1.6" } } } @@ -4820,8 +4939,8 @@ "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "dev": true, "requires": { - "inherits": "~2.0.1", - "readable-stream": "^2.0.2" + "inherits": "2.0.3", + "readable-stream": "2.3.6" } }, "stream-combiner2": { @@ -4830,8 +4949,8 @@ "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, "requires": { - "duplexer2": "~0.1.0", - "readable-stream": "^2.0.2" + "duplexer2": "0.1.4", + "readable-stream": "2.3.6" } }, "stream-consume": { @@ -4846,11 +4965,11 @@ "integrity": "sha512-cQ0jo17BLca2r0GfRdZKYAGLU6JRoIWxqSOakUMuKOT6MOK7AAlE856L33QuDmAy/eeOrhLee3dZKX0Uadu93A==", "dev": true, "requires": { - "builtin-status-codes": "^3.0.0", - "inherits": "^2.0.1", - "readable-stream": "^2.3.3", - "to-arraybuffer": "^1.0.0", - "xtend": "^4.0.0" + "builtin-status-codes": "3.0.0", + "inherits": "2.0.3", + "readable-stream": "2.3.6", + "to-arraybuffer": "1.0.1", + "xtend": "4.0.1" } }, "stream-shift": { @@ -4865,8 +4984,8 @@ "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", "dev": true, "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.2" + "inherits": "2.0.3", + "readable-stream": "2.3.6" } }, "streamqueue": { @@ -4875,7 +4994,7 @@ "integrity": "sha1-ZvX17JTpuK8knkrsLdH3Qb/pTeM=", "dev": true, "requires": { - "readable-stream": "^1.0.26-2" + "readable-stream": "1.1.14" }, "dependencies": { "isarray": { @@ -4890,10 +5009,10 @@ "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", + "core-util-is": "1.0.2", + "inherits": "2.0.3", "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "string_decoder": "0.10.31" } }, "string_decoder": { @@ -4910,7 +5029,7 @@ "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { - "safe-buffer": "~5.1.0" + "safe-buffer": "5.1.2" } }, "strip-ansi": { @@ -4919,7 +5038,7 @@ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "2.1.1" } }, "strip-bom": { @@ -4928,8 +5047,8 @@ "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", "dev": true, "requires": { - "first-chunk-stream": "^1.0.0", - "is-utf8": "^0.2.0" + "first-chunk-stream": "1.0.0", + "is-utf8": "0.2.1" } }, "strip-bom-string": { @@ -4944,7 +5063,7 @@ "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", "dev": true, "requires": { - "minimist": "^1.1.0" + "minimist": "1.2.0" } }, "supports-color": { @@ -4953,7 +5072,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } }, "syntax-error": { @@ -4962,7 +5081,7 @@ "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, "requires": { - "acorn-node": "^1.2.0" + "acorn-node": "1.3.0" } }, "through": { @@ -4977,8 +5096,8 @@ "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "readable-stream": "^2.1.5", - "xtend": "~4.0.1" + "readable-stream": "2.3.6", + "xtend": "4.0.1" } }, "through2-filter": { @@ -4987,8 +5106,8 @@ "integrity": "sha1-YLxVoNrLdghdsfna6Zq0P4PWIuw=", "dev": true, "requires": { - "through2": "~2.0.0", - "xtend": "~4.0.0" + "through2": "2.0.3", + "xtend": "4.0.1" } }, "tildify": { @@ -4997,7 +5116,7 @@ "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", "dev": true, "requires": { - "os-homedir": "^1.0.0" + "os-homedir": "1.0.2" } }, "time-stamp": { @@ -5012,7 +5131,7 @@ "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", "dev": true, "requires": { - "process": "~0.11.0" + "process": "0.11.10" } }, "timers-ext": { @@ -5021,8 +5140,8 @@ "integrity": "sha512-tsEStd7kmACHENhsUPaxb8Jf8/+GZZxyNFQbZD07HQOyooOa6At1rQqjffgvg7n+dxscQa9cjjMdWhJtsP2sxg==", "dev": true, "requires": { - "es5-ext": "~0.10.14", - "next-tick": "1" + "es5-ext": "0.10.42", + "next-tick": "1.0.0" } }, "to-absolute-glob": { @@ -5031,8 +5150,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": { @@ -5047,7 +5166,7 @@ "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, "requires": { - "kind-of": "^3.0.2" + "kind-of": "3.2.2" }, "dependencies": { "kind-of": { @@ -5056,7 +5175,7 @@ "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "^1.1.5" + "is-buffer": "1.1.6" } } } @@ -5067,10 +5186,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": { @@ -5079,8 +5198,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": { @@ -5089,7 +5208,7 @@ "integrity": "sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY=", "dev": true, "requires": { - "through2": "^2.0.3" + "through2": "2.0.3" } }, "travis-fold": { @@ -5110,18 +5229,18 @@ "integrity": "sha1-ElX4ej/1frCw4fDmEKi0dIBGya4=", "dev": true, "requires": { - "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" + "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.0", + "tsutils": "2.26.2" }, "dependencies": { "commander": { @@ -5136,7 +5255,7 @@ "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "path-parse": "1.0.5" } }, "semver": { @@ -5153,7 +5272,7 @@ "integrity": "sha512-uzwnhmrSbyinPCiwfzGsOY3IulBTwoky7r83HmZdz9QNCjhSCzavkh47KLWuU0zF2F2WbpmmzoJUIEiYyd+jEQ==", "dev": true, "requires": { - "tslib": "^1.8.1" + "tslib": "1.9.0" } }, "tty-browserify": { @@ -5168,7 +5287,7 @@ "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true, "requires": { - "prelude-ls": "~1.1.2" + "prelude-ls": "1.1.2" } }, "type-detect": { @@ -5196,9 +5315,9 @@ "dev": true, "optional": true, "requires": { - "source-map": "~0.5.1", - "uglify-to-browserify": "~1.0.0", - "yargs": "~3.10.0" + "source-map": "0.5.7", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" } }, "uglify-to-browserify": { @@ -5226,10 +5345,10 @@ "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": { @@ -5238,7 +5357,7 @@ "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, "requires": { - "is-extendable": "^0.1.0" + "is-extendable": "0.1.1" } }, "set-value": { @@ -5247,10 +5366,10 @@ "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", "dev": true, "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" + "extend-shallow": "2.0.1", + "is-extendable": "0.1.1", + "is-plain-object": "2.0.4", + "to-object-path": "0.3.0" } } } @@ -5267,8 +5386,8 @@ "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" + "has-value": "0.3.1", + "isobject": "3.0.1" }, "dependencies": { "has-value": { @@ -5277,9 +5396,9 @@ "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" + "get-value": "2.0.6", + "has-values": "0.1.4", + "isobject": "2.1.0" }, "dependencies": { "isobject": { @@ -5325,13 +5444,19 @@ } } }, + "url-template": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz", + "integrity": "sha1-/FZaPMy/93MMd19WQflVV5FDnyE=", + "dev": true + }, "use": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/use/-/use-3.1.0.tgz", "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", "dev": true, "requires": { - "kind-of": "^6.0.2" + "kind-of": "6.0.2" } }, "user-home": { @@ -5375,7 +5500,7 @@ "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", "dev": true, "requires": { - "user-home": "^1.1.1" + "user-home": "1.1.1" } }, "value-or-function": { @@ -5390,12 +5515,12 @@ "integrity": "sha1-Ah+cLPlR1rk5lDyJ617lrdT9kkw=", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "clone": { @@ -5424,14 +5549,14 @@ "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "clone": { @@ -5452,10 +5577,10 @@ "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", + "core-util-is": "1.0.2", + "inherits": "2.0.3", "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "string_decoder": "0.10.31" } }, "string_decoder": { @@ -5470,8 +5595,8 @@ "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", "dev": true, "requires": { - "readable-stream": ">=1.0.33-1 <1.1.0-0", - "xtend": ">=4.0.0 <4.1.0-0" + "readable-stream": "1.0.34", + "xtend": "4.0.1" } }, "vinyl": { @@ -5480,8 +5605,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" } } } @@ -5492,13 +5617,13 @@ "integrity": "sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY=", "dev": true, "requires": { - "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" + "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" }, "dependencies": { "graceful-fs": { @@ -5521,7 +5646,7 @@ "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { - "isexe": "^2.0.0" + "isexe": "2.0.0" } }, "window-size": { @@ -5549,8 +5674,8 @@ "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", "dev": true, "requires": { - "sax": ">=0.6.0", - "xmlbuilder": "~9.0.1" + "sax": "1.2.4", + "xmlbuilder": "9.0.7" } }, "xmlbuilder": { @@ -5572,9 +5697,9 @@ "dev": true, "optional": true, "requires": { - "camelcase": "^1.0.2", - "cliui": "^2.1.0", - "decamelize": "^1.0.0", + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", "window-size": "0.1.0" } } diff --git a/package.json b/package.json index ef4650c49b0..48179f02e10 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "node": ">=4.2.0" }, "devDependencies": { + "@octokit/rest": "latest", "@types/browserify": "latest", "@types/chai": "latest", "@types/convert-source-map": "latest", diff --git a/scripts/open-user-pr.ts b/scripts/open-user-pr.ts new file mode 100644 index 00000000000..9e14bd5f37d --- /dev/null +++ b/scripts/open-user-pr.ts @@ -0,0 +1,64 @@ +import cp = require("child_process"); +import Octokit = require("@octokit/rest"); + +const opts = { timeout: 100_000, shell: true, stdio: "inherit" } +function runSequence(tasks: [string, string[]][]) { + for (const task of tasks) { + console.log(`${task[0]} ${task[1].join(" ")}`); + const result = cp.spawnSync(task[0], task[1], opts); + if (result.status !== 0) throw new Error(`${task[0]} ${task[1].join(" ")} failed: ${result.stderr && result.stderr.toString()}`); + } +} + +function padNum(number: number) { + const str = "" + number; + return str.length >= 2 ? str : "0" + str; +} + +const userName = process.env.GH_USERNAME; +const reviewers = ["weswigham", "sandersn", "mhegazy"] +const now = new Date(); +const branchName = `user-update-${now.getFullYear()}${padNum(now.getMonth())}${padNum(now.getDay())}`; +const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`; +runSequence([ + ["git", ["checkout", "."]], // reset any changes + ["node", ["./node_modules/jake/bin/cli.js", "baseline-accept"]], // accept baselines + ["git", ["checkout", "-b", branchName]], // create a branch + ["git", ["add", "."]], // Add all changes + ["git", ["commit", "-m", `"Update user baselines"`]], // Commit all changes + ["git", ["remote", "add", "fork", remoteUrl]], // Add the remote fork + ["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch +]); + +const gh = new Octokit(); +gh.authenticate({ + type: "token", + token: process.argv[2] +}); +gh.pullRequests.create({ + owner: process.env.TARGET_FORK, + repo: "TypeScript", + maintainer_can_modify: true, + title: `🤖 User test baselines have changed`, + head: `${userName}:${branchName}`, + base: "master", + body: +`Please review the diff and merge if no changes are unexpected. +You can view the build log [here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary). + +cc ${reviewers.map(r => "@" + r).join(" ")}`, +}).then(r => { + const num = r.data.number; + console.log(`Pull request ${num} created.`); + return gh.pullRequests.createReviewRequest({ + owner: process.env.TARGET_FORK, + repo: "TypeScript", + number: num, + reviewers, + }); +}).then(() => { + console.log(`Reviewers requested, done.`); +}).catch(e => { + console.error(e); + process.exit(1); +}); diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index d1c782d6155..d95001b1041 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -118,7 +118,7 @@ namespace ts { let thisParentContainer: Node; // Container one level up let blockScopeContainer: Node; let lastContainer: Node; - let delayedTypedefs: { typedef: JSDocTypedefTag, container: Node, lastContainer: Node, blockScopeContainer: Node, parent: Node }[]; + let delayedTypeAliases: (JSDocTypedefTag | JSDocCallbackTag)[]; let seenThisKeyword: boolean; // state used by control flow analysis @@ -188,7 +188,7 @@ namespace ts { thisParentContainer = undefined; blockScopeContainer = undefined; lastContainer = undefined; - delayedTypedefs = undefined; + delayedTypeAliases = undefined; seenThisKeyword = false; currentFlow = undefined; currentBreakTarget = undefined; @@ -273,6 +273,7 @@ namespace ts { return InternalSymbolName.Constructor; case SyntaxKind.FunctionType: case SyntaxKind.CallSignature: + case SyntaxKind.JSDocSignature: return InternalSymbolName.Call; case SyntaxKind.ConstructorType: case SyntaxKind.ConstructSignature: @@ -301,9 +302,6 @@ namespace ts { const functionType = node.parent; const index = functionType.parameters.indexOf(node as ParameterDeclaration); return "arg" + index as __String; - case SyntaxKind.JSDocTypedefTag: - const name = getNameOfJSDocTypedef(node as JSDocTypedefTag); - return typeof name !== "undefined" ? name.escapedText : undefined; } } @@ -456,8 +454,8 @@ namespace ts { // during global merging in the checker. Why? The only case when ambient module is permitted inside another module is module augmentation // and this case is specially handled. Module augmentations should only be merged with original module definition // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. - if (node.kind === SyntaxKind.JSDocTypedefTag) Debug.assert(isInJavaScriptFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypedefTag(node)) { + if (isJSDocTypeAlias(node)) Debug.assert(isInJavaScriptFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. + if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypeAlias(node)) { if (hasModifier(node, ModifierFlags.Default) && !getDeclarationName(node)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } @@ -628,22 +626,6 @@ namespace ts { } function bindChildrenWorker(node: Node): void { - // Binding of JsDocComment should be done before the current block scope container changes. - // because the scope of JsDocComment should not be affected by whether the current node is a - // container or not. - if (hasJSDocNodes(node)) { - if (isInJavaScriptFile(node)) { - for (const j of node.jsDoc) { - bind(j); - } - } - else { - for (const j of node.jsDoc) { - setParentPointers(node, j); - } - } - } - if (checkUnreachable(node)) { bindEachChild(node); return; @@ -709,11 +691,9 @@ namespace ts { case SyntaxKind.CallExpression: bindCallExpressionFlow(node); break; - case SyntaxKind.JSDocComment: - bindJSDocComment(node); - break; case SyntaxKind.JSDocTypedefTag: - bindJSDocTypedefTag(node); + case SyntaxKind.JSDocCallbackTag: + bindJSDocTypeAlias(node as JSDocTypedefTag | JSDocCallbackTag); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime case SyntaxKind.SourceFile: @@ -728,6 +708,7 @@ namespace ts { bindEachChild(node); break; } + bindJSDoc(node); } function isNarrowingExpression(expr: Expression): boolean { @@ -1379,24 +1360,10 @@ namespace ts { } } - function bindJSDocComment(node: JSDoc) { - forEachChild(node, n => { - if (n.kind !== SyntaxKind.JSDocTypedefTag) { - bind(n); - } - }); - } - - function bindJSDocTypedefTag(node: JSDocTypedefTag) { - forEachChild(node, n => { - // if the node has a fullName "A.B.C", that means symbol "C" was already bound - // when we visit "fullName"; so when we visit the name "C" as the next child of - // the jsDocTypedefTag, we should skip binding it. - if (node.fullName && n === node.name && node.fullName.kind !== SyntaxKind.Identifier) { - return; - } - bind(n); - }); + function bindJSDocTypeAlias(node: JSDocTypedefTag | JSDocCallbackTag) { + if (node.fullName) { + setParentPointers(node, node.fullName); + } } function bindCallExpressionFlow(node: CallExpression) { @@ -1456,6 +1423,7 @@ namespace ts { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.CallSignature: + case SyntaxKind.JSDocSignature: case SyntaxKind.JSDocFunctionType: case SyntaxKind.FunctionType: case SyntaxKind.ConstructSignature: @@ -1545,6 +1513,7 @@ namespace ts { case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: + case SyntaxKind.JSDocSignature: case SyntaxKind.IndexSignature: case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: @@ -1555,6 +1524,8 @@ namespace ts { case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: case SyntaxKind.JSDocFunctionType: + case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JSDocCallbackTag: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.MappedType: // All the children of these container types are never visible through another @@ -1650,7 +1621,7 @@ namespace ts { return state; } - function bindFunctionOrConstructorType(node: SignatureDeclaration): void { + function bindFunctionOrConstructorType(node: SignatureDeclaration | JSDocSignature): void { // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } // @@ -1752,21 +1723,34 @@ namespace ts { } function delayedBindJSDocTypedefTag() { - if (!delayedTypedefs) { + if (!delayedTypeAliases) { return; } const saveContainer = container; const saveLastContainer = lastContainer; const saveBlockScopeContainer = blockScopeContainer; const saveParent = parent; - for (const delay of delayedTypedefs) { - ({ container, lastContainer, blockScopeContainer, parent } = delay); - bindBlockScopedDeclaration(delay.typedef, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); + const saveCurrentFlow = currentFlow; + for (const typeAlias of delayedTypeAliases) { + const host = getJSDocHost(typeAlias); + container = findAncestor(host.parent, n => !!(getContainerFlags(n) & ContainerFlags.IsContainer)) || file; + blockScopeContainer = getEnclosingBlockScopeContainer(host) || file; + currentFlow = { flags: FlowFlags.Start }; + parent = typeAlias; + bind(typeAlias.typeExpression); + if (!typeAlias.fullName || typeAlias.fullName.kind === SyntaxKind.Identifier) { + parent = typeAlias.parent; + bindBlockScopedDeclaration(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); + } + else { + bind(typeAlias.fullName); + } } container = saveContainer; lastContainer = saveLastContainer; blockScopeContainer = saveBlockScopeContainer; parent = saveParent; + currentFlow = saveCurrentFlow; } // The binder visits every node in the syntax tree so it is a convenient place to perform a single localized @@ -1946,7 +1930,6 @@ namespace ts { // Here the current node is "foo", which is a container, but the scope of "MyType" should // not be inside "foo". Therefore we always bind @typedef before bind the parent node, // and skip binding this tag later when binding all the other jsdoc tags. - if (isInJavaScriptFile(node)) bindJSDocTypedefTagIfAny(node); // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and then potentially add the symbol to an appropriate symbol table. Possible @@ -1978,26 +1961,21 @@ namespace ts { } else if (!skipTransformFlagAggregation && (node.transformFlags & TransformFlags.HasComputedFlags) === 0) { subtreeTransformFlags |= computeTransformFlagsForNode(node, 0); + bindJSDoc(node); } inStrictMode = saveInStrictMode; } - function bindJSDocTypedefTagIfAny(node: Node) { - if (!hasJSDocNodes(node)) { - return; - } - - for (const jsDoc of node.jsDoc) { - if (!jsDoc.tags) { - continue; + function bindJSDoc(node: Node) { + if (hasJSDocNodes(node)) { + if (isInJavaScriptFile(node)) { + for (const j of node.jsDoc) { + bind(j); + } } - - for (const tag of jsDoc.tags) { - if (tag.kind === SyntaxKind.JSDocTypedefTag) { - const savedParent = parent; - parent = jsDoc; - bind(tag); - parent = savedParent; + else { + for (const j of node.jsDoc) { + setParentPointers(node, j); } } } @@ -2036,10 +2014,10 @@ namespace ts { // current "blockScopeContainer" needs to be set to its immediate namespace parent. if ((node).isInJSDocNamespace) { let parentNode = node.parent; - while (parentNode && parentNode.kind !== SyntaxKind.JSDocTypedefTag) { + while (parentNode && !isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); + bindBlockScopedDeclaration(parentNode as Declaration, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); break; } // falls through @@ -2141,8 +2119,9 @@ namespace ts { return bindPropertyOrMethodOrAccessor(node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes); case SyntaxKind.FunctionType: case SyntaxKind.JSDocFunctionType: + case SyntaxKind.JSDocSignature: case SyntaxKind.ConstructorType: - return bindFunctionOrConstructorType(node); + return bindFunctionOrConstructorType(node); case SyntaxKind.TypeLiteral: case SyntaxKind.JSDocTypeLiteral: case SyntaxKind.MappedType: @@ -2205,6 +2184,9 @@ namespace ts { return updateStrictModeStatementList((node).statements); case SyntaxKind.JSDocParameterTag: + if (node.parent.kind === SyntaxKind.JSDocSignature) { + return bindParameter(node as JSDocParameterTag); + } if (node.parent.kind !== SyntaxKind.JSDocTypeLiteral) { break; } @@ -2215,13 +2197,9 @@ namespace ts { SymbolFlags.Property | SymbolFlags.Optional : SymbolFlags.Property; return declareSymbolAndAddToSymbolTable(propTag, flags, SymbolFlags.PropertyExcludes); - case SyntaxKind.JSDocTypedefTag: { - const { fullName } = node as JSDocTypedefTag; - if (!fullName || fullName.kind === SyntaxKind.Identifier) { - (delayedTypedefs || (delayedTypedefs = [])).push({ typedef: node as JSDocTypedefTag, container, lastContainer, blockScopeContainer, parent }); - } - break; - } + case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JSDocCallbackTag: + return (delayedTypeAliases || (delayedTypeAliases = [])).push(node as JSDocTypedefTag | JSDocCallbackTag); } } @@ -2622,7 +2600,10 @@ namespace ts { } } - function bindParameter(node: ParameterDeclaration) { + function bindParameter(node: ParameterDeclaration | JSDocParameterTag) { + if (node.kind === SyntaxKind.JSDocParameterTag && container.kind !== SyntaxKind.JSDocSignature) { + return; + } if (inStrictMode && !(node.flags & NodeFlags.Ambient)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) @@ -2630,7 +2611,7 @@ namespace ts { } if (isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, "__" + node.parent.parameters.indexOf(node) as __String); + bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, "__" + (node as ParameterDeclaration).parent.parameters.indexOf(node as ParameterDeclaration) as __String); } else { declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes); @@ -2690,18 +2671,24 @@ namespace ts { } function getInferTypeContainer(node: Node): ConditionalTypeNode { - while (node) { - const parent = node.parent; - if (parent && parent.kind === SyntaxKind.ConditionalType && (parent).extendsType === node) { - return parent; - } - node = parent; - } - return undefined; + const extendsType = findAncestor(node, n => n.parent && isConditionalTypeNode(n.parent) && n.parent.extendsType === n); + return extendsType && extendsType.parent as ConditionalTypeNode; } function bindTypeParameter(node: TypeParameterDeclaration) { - if (node.parent.kind === SyntaxKind.InferType) { + if (isJSDocTemplateTag(node.parent)) { + const container = find((node.parent.parent as JSDoc).tags, isJSDocTypeAlias) || getHostSignatureFromJSDoc(node.parent); + if (container) { + if (!container.locals) { + container.locals = createSymbolTable(); + } + declareSymbol(container.locals, /*parent*/ undefined, node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); + } + else { + declareSymbolAndAddToSymbolTable(node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes); + } + } + else if (node.parent.kind === SyntaxKind.InferType) { const container = getInferTypeContainer(node.parent); if (container) { if (!container.locals) { @@ -3804,6 +3791,6 @@ namespace ts { */ function setParentPointers(parent: Node, child: Node): void { child.parent = parent; - forEachChild(child, (childsChild) => setParentPointers(child, childsChild)); + forEachChild(child, grandchild => setParentPointers(child, grandchild)); } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a368a6a8f64..9f3c8fa6fd7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -319,7 +319,7 @@ namespace ts { checkSourceFile(file); const diagnostics: Diagnostic[] = []; Debug.assert(!!(getNodeLinks(file).flags & NodeCheckFlags.TypeChecked)); - checkUnusedIdentifiers(allPotentiallyUnusedIdentifiers.get(file.fileName)!, (kind, diag) => { + checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), (kind, diag) => { if (!unusedIsError(kind)) { diagnostics.push({ ...diag, category: DiagnosticCategory.Suggestion }); } @@ -401,6 +401,7 @@ namespace ts { const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + const resolvingSignaturesArray = [resolvingSignature]; const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); const jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); @@ -449,9 +450,7 @@ namespace ts { let deferredGlobalExtractSymbol: Symbol; let deferredNodes: Node[]; - const allPotentiallyUnusedIdentifiers = createMap>(); // key is file name - let potentiallyUnusedIdentifiers: PotentiallyUnusedIdentifier[]; // Potentially unused identifiers in the source file currently being checked. - const seenPotentiallyUnusedIdentifiers = createMap(); // For assertion that we don't defer the same identifier twice + const allPotentiallyUnusedIdentifiers = createMap(); // key is file name let flowLoopStart = 0; let flowLoopCount = 0; @@ -892,6 +891,8 @@ namespace ts { function mergeSymbol(target: Symbol, source: Symbol) { if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & SymbolFlags.JSContainer) { + const targetValueDeclaration = target.valueDeclaration; + Debug.assert(!!(target.flags & SymbolFlags.Transient)); // Javascript static-property-assignment declarations always merge, even though they are also values if (source.flags & SymbolFlags.ValueModule && target.flags & SymbolFlags.ValueModule && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums @@ -915,7 +916,12 @@ namespace ts { } if ((source.flags | target.flags) & SymbolFlags.JSContainer) { const sourceInitializer = getJSInitializerSymbol(source); - const targetInitializer = getJSInitializerSymbol(target); + const init = getDeclaredJavascriptInitializer(targetValueDeclaration) || getAssignedJavascriptInitializer(targetValueDeclaration); + let targetInitializer = init && init.symbol ? init.symbol : target; + if (!(targetInitializer.flags & SymbolFlags.Transient)) { + const mergedInitializer = getMergedSymbol(targetInitializer); + targetInitializer = mergedInitializer === targetInitializer ? cloneSymbol(targetInitializer) : mergedInitializer; + } if (sourceInitializer !== source || targetInitializer !== target) { mergeSymbol(targetInitializer, sourceInitializer); } @@ -1445,6 +1451,12 @@ namespace ts { location = location.parent; } break; + case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JSDocCallbackTag: + // js type aliases do not resolve names from their host, so skip past it + lastLocation = location; + location = getJSDocHost(location).parent; + continue; } if (isSelfReferenceLocation(location)) { lastSelfReferenceLocation = location; @@ -1569,9 +1581,11 @@ namespace ts { function isTypeParameterSymbolDeclaredInContainer(symbol: Symbol, container: Node) { for (const decl of symbol.declarations) { - const parent = isJSDocTemplateTag(decl.parent) ? getJSDocHost(decl.parent) : decl.parent; - if (decl.kind === SyntaxKind.TypeParameter && parent === container) { - return true; + if (decl.kind === SyntaxKind.TypeParameter) { + const parent = isJSDocTemplateTag(decl.parent) ? getJSDocHost(decl.parent) : decl.parent; + if (parent === container) { + return !(isJSDocTemplateTag(decl.parent) && find((decl.parent.parent as JSDoc).tags, isJSDocTypeAlias)); + } } } @@ -2081,7 +2095,7 @@ namespace ts { let symbol: Symbol; if (name.kind === SyntaxKind.Identifier) { const message = meaning === namespaceMeaning ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0; - const symbolFromJSPrototype = isInJavaScriptFile(name) ? resolveEntityNameFromJSPrototype(name, meaning) : undefined; + const symbolFromJSPrototype = isInJavaScriptFile(name) ? resolveEntityNameFromJSSpecialAssignment(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); if (!symbol) { return symbolFromJSPrototype; @@ -2136,25 +2150,39 @@ namespace ts { } /** - * For prototype-property methods like `A.prototype.m = function () ...`, try to resolve names in the scope of `A` too. + * 1. For prototype-property methods like `A.prototype.m = function () ...`, try to resolve names in the scope of `A` too. * Note that prototype-property assignment to locations outside the current file (eg globals) doesn't work, so * name resolution won't work either. + * 2. For property assignments like `{ x: function f () { } }`, try to resolve names in the scope of `f` too. */ - function resolveEntityNameFromJSPrototype(name: Identifier, meaning: SymbolFlags) { - if (isJSDocTypeReference(name.parent) && isJSDocTag(name.parent.parent.parent)) { - const host = getJSDocHost(name.parent.parent.parent as JSDocTag); - if (isExpressionStatement(host) && - isBinaryExpression(host.expression) && - getSpecialPropertyAssignmentKind(host.expression) === SpecialPropertyAssignmentKind.PrototypeProperty) { - const symbol = getSymbolOfNode(host.expression.left); - if (symbol) { - const secondaryLocation = symbol.parent.valueDeclaration; - return resolveName(secondaryLocation, name.escapedText, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ true); - } + function resolveEntityNameFromJSSpecialAssignment(name: Identifier, meaning: SymbolFlags) { + if (isJSDocTypeReference(name.parent)) { + const secondaryLocation = getJSSpecialAssignmentLocation(name.parent); + if (secondaryLocation) { + return resolveName(secondaryLocation, name.escapedText, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ true); } } } + function getJSSpecialAssignmentLocation(node: TypeReferenceNode): Declaration | undefined { + const typeAlias = findAncestor(node, node => !(isJSDocNode(node) || node.flags & NodeFlags.JSDoc) ? "quit" : isJSDocTypeAlias(node)); + if (typeAlias) { + return; + } + const host = getJSDocHost(node); + if (isExpressionStatement(host) && + isBinaryExpression(host.expression) && + getSpecialPropertyAssignmentKind(host.expression) === SpecialPropertyAssignmentKind.PrototypeProperty) { + const symbol = getSymbolOfNode(host.expression.left); + return symbol && symbol.parent.valueDeclaration; + } + const sig = getHostSignatureFromJSDocHost(host); + if (sig) { + const symbol = getSymbolOfNode(sig); + return symbol && symbol.valueDeclaration; + } + } + function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression): Symbol { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, Diagnostics.Cannot_find_module_0); } @@ -2746,7 +2774,7 @@ namespace ts { * @param shouldComputeAliasToMakeVisible a boolean value to indicate whether to return aliases to be mark visible in case the symbol is accessible */ function isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasesToMakeVisible: boolean): SymbolAccessibilityResult { - if (symbol && enclosingDeclaration && !(symbol.flags & SymbolFlags.TypeParameter)) { + if (symbol && enclosingDeclaration) { const initialSymbol = symbol; let meaningToLook = meaning; while (symbol) { @@ -2763,6 +2791,14 @@ namespace ts { } return hasAccessibleDeclarations; } + else { + if (some(symbol.declarations, hasExternalModuleSymbol)) { + // 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 @@ -2837,6 +2873,11 @@ namespace ts { isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } + else if (isLateVisibilityPaintedStatement(declaration) // unexported top-level statement + && !hasModifier(declaration, ModifierFlags.Export) + && isDeclarationVisible(declaration.parent)) { + return addVisibleAlias(declaration, declaration); + } // Declaration is not visible return false; @@ -3016,7 +3057,7 @@ namespace ts { flags, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: noop }, encounteredError: false, - symbolStack: undefined, + visitedSymbols: undefined, inferTypeParameters: undefined }; } @@ -3113,16 +3154,24 @@ namespace ts { } if (type.flags & TypeFlags.TypeParameter || objectFlags & ObjectFlags.ClassOrInterface) { if (type.flags & TypeFlags.TypeParameter && contains(context.inferTypeParameters, type)) { - return createInferTypeNode(createTypeParameterDeclaration(getNameOfSymbolAsWritten(type.symbol))); + return createInferTypeNode(typeParameterToDeclarationWithConstraint(type as TypeParameter, context, /*constraintNode*/ undefined)); + } + if (context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams && + type.flags & TypeFlags.TypeParameter && + length(type.symbol.declarations) && + 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 ? symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false) : createIdentifier("?"); // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return createTypeReferenceNode(name, /*typeArguments*/ undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - const name = symbolToTypeReferenceName(type.aliasSymbol); const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - return createTypeReferenceNode(name, typeArgumentNodes); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & SymbolFlags.Class)) return createTypeReferenceNode(createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, SymbolFlags.Type, typeArgumentNodes); } if (type.flags & (TypeFlags.Union | TypeFlags.Intersection)) { const types = type.flags & TypeFlags.Union ? formatUnionTypes((type).types) : (type).types; @@ -3190,7 +3239,10 @@ namespace ts { function createAnonymousTypeNode(type: ObjectType): TypeNode { const symbol = type.symbol; + let id: string; if (symbol) { + const isConstructorObject = getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & SymbolFlags.Class; + id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJavaScriptConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. const isInstanceType = type === getInferredClassType(symbol) ? SymbolFlags.Type : SymbolFlags.Value; @@ -3202,7 +3254,7 @@ namespace ts { shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, SymbolFlags.Value); } - else if (contains(context.symbolStack, symbol)) { + else if (context.visitedSymbols && context.visitedSymbols.has(id)) { // If type is an anonymous type literal in a type alias declaration, use type alias name const typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { @@ -3216,20 +3268,14 @@ namespace ts { else { // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.symbolStack) { - context.symbolStack = []; + if (!context.visitedSymbols) { + context.visitedSymbols = createMap(); } - const isConstructorObject = getObjectFlags(type) & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & SymbolFlags.Class; - if (isConstructorObject) { - return createTypeNodeFromObjectType(type); - } - else { - context.symbolStack.push(symbol); - const result = createTypeNodeFromObjectType(type); - context.symbolStack.pop(); - return result; - } + context.visitedSymbols.set(id, true); + const result = createTypeNodeFromObjectType(type); + context.visitedSymbols.delete(id); + return result; } } else { @@ -3246,7 +3292,7 @@ namespace ts { declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & NodeBuilderFlags.UseTypeOfFunction) || contains(context.symbolStack, symbol)) && // it is type of the symbol uses itself recursively + return (!!(context.flags & NodeBuilderFlags.UseTypeOfFunction) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively (!(context.flags & NodeBuilderFlags.UseStructuralFallback) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } @@ -3285,12 +3331,6 @@ namespace ts { return setEmitFlags(typeLiteralNode, (context.flags & NodeBuilderFlags.MultilineObjectLiterals) ? 0 : EmitFlags.SingleLine); } - function symbolToTypeReferenceName(symbol: Symbol) { - // Unnamed function expressions and arrow functions have reserved names that we don't want to display - const entityName = symbol.flags & SymbolFlags.Class || !isReservedMemberName(symbol.escapedName) ? symbolToName(symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false) : createIdentifier(""); - return entityName; - } - function typeReferenceToTypeNode(type: TypeReference) { const typeArguments: Type[] = type.typeArguments || emptyArray; if (type.target === globalArrayType) { @@ -3325,7 +3365,7 @@ namespace ts { else { const outerTypeParameters = type.target.outerTypeParameters; let i = 0; - let qualifiedName: QualifiedName | undefined; + let resultType: TypeReferenceNode | ImportTypeNode; if (outerTypeParameters) { const length = outerTypeParameters.length; while (i < length) { @@ -3339,64 +3379,66 @@ namespace ts { // the default outer type arguments), we don't show the group. if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { const typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); - const typeArgumentNodes = typeArgumentSlice && createNodeArray(typeArgumentSlice); - const namePart = symbolToTypeReferenceName(parent); - (namePart.kind === SyntaxKind.Identifier ? namePart : namePart.right).typeArguments = typeArgumentNodes; - - if (qualifiedName) { - Debug.assert(!qualifiedName.right); - qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, namePart); - qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); - } - else { - qualifiedName = createQualifiedName(namePart, /*right*/ undefined); - } + const flags = context.flags; + context.flags |= NodeBuilderFlags.ForbidIndexedAccessSymbolReferences; + const ref = symbolToTypeNode(parent, context, SymbolFlags.Type, typeArgumentSlice) as TypeReferenceNode | ImportTypeNode; + context.flags = flags; + resultType = !resultType ? ref : appendReferenceToType(resultType, ref as TypeReferenceNode); } } } - - let entityName: EntityName; - const nameIdentifier = symbolToTypeReferenceName(type.symbol); - if (qualifiedName) { - Debug.assert(!qualifiedName.right); - qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, nameIdentifier); - entityName = qualifiedName; - } - else { - entityName = nameIdentifier; - } - let typeArgumentNodes: ReadonlyArray | undefined; if (typeArguments.length > 0) { const typeParameterCount = (type.target.typeParameters || emptyArray).length; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } - - if (typeArgumentNodes) { - const lastIdentifier = entityName.kind === SyntaxKind.Identifier ? entityName : entityName.right; - lastIdentifier.typeArguments = undefined; - } - - return createTypeReferenceNode(entityName, typeArgumentNodes); + const flags = context.flags; + context.flags |= NodeBuilderFlags.ForbidIndexedAccessSymbolReferences; + const finalRef = symbolToTypeNode(type.symbol, context, SymbolFlags.Type, typeArgumentNodes); + context.flags = flags; + return !resultType ? finalRef : appendReferenceToType(resultType, finalRef as TypeReferenceNode); } } - function addToQualifiedNameMissingRightIdentifier(left: QualifiedName, right: Identifier | QualifiedName) { - Debug.assert(left.right === undefined); - if (right.kind === SyntaxKind.Identifier) { - left.right = right; - return left; + function appendReferenceToType(root: TypeReferenceNode | ImportTypeNode, ref: TypeReferenceNode): TypeReferenceNode | ImportTypeNode { + if (isImportTypeNode(root)) { + // first shift type arguments + const innerParams = root.typeArguments; + if (root.qualifier) { + (isIdentifier(root.qualifier) ? root.qualifier : root.qualifier.right).typeArguments = innerParams; + } + root.typeArguments = ref.typeArguments; + // then move qualifiers + const ids = getAccessStack(ref); + for (const id of ids) { + root.qualifier = root.qualifier ? createQualifiedName(root.qualifier, id) : id; + } + return root; } - - let rightPart = right; - while (rightPart.left.kind !== SyntaxKind.Identifier) { - rightPart = rightPart.left; + else { + // first shift type arguments + const innerParams = root.typeArguments; + (isIdentifier(root.typeName) ? root.typeName : root.typeName.right).typeArguments = innerParams; + root.typeArguments = ref.typeArguments; + // then move qualifiers + const ids = getAccessStack(ref); + for (const id of ids) { + root.typeName = createQualifiedName(root.typeName, id); + } + return root; } + } - left.right = rightPart.left; - rightPart.left = left; - return right; + function getAccessStack(ref: TypeReferenceNode): Identifier[] { + let state = ref.typeName; + const ids = []; + while (!isIdentifier(state)) { + ids.unshift(state.right); + state = state.left; + } + ids.unshift(state); + return ids; } function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { @@ -3558,10 +3600,21 @@ namespace ts { return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); } - function typeParameterToDeclarationWithConstraint(type: TypeParameter, context: NodeBuilderContext, constraintNode: TypeNode): TypeParameterDeclaration { + function typeParameterShadowsNameInScope(type: TypeParameter, context: NodeBuilderContext) { + return !!resolveName(context.enclosingDeclaration, type.symbol.escapedName, SymbolFlags.Type, /*nameNotFoundArg*/ undefined, type.symbol.escapedName, /*isUse*/ false); + } + + function typeParameterToDeclarationWithConstraint(type: TypeParameter, context: NodeBuilderContext, constraintNode: TypeNode | undefined): TypeParameterDeclaration { const savedContextFlags = context.flags; context.flags &= ~NodeBuilderFlags.WriteTypeParametersInQualifiedName; // Avoids potential infinite loop when building for a claimspace with a generic - const name = symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ true); + const shouldUseGeneratedName = + context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams && + type.symbol.declarations[0] && + isTypeParameterDeclaration(type.symbol.declarations[0]) && + typeParameterShadowsNameInScope(type, context); + const name = shouldUseGeneratedName + ? getGeneratedNameForNode((type.symbol.declarations[0] as TypeParameterDeclaration).name, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.ReservedInNestedScopes) + : symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ true); const defaultParameter = getDefaultFromTypeParameter(type); const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context); context.flags = savedContextFlags; @@ -3574,8 +3627,10 @@ namespace ts { } function symbolToParameterDeclaration(parameterSymbol: Symbol, context: NodeBuilderContext, preserveModifierFlags?: boolean): ParameterDeclaration { - const parameterDeclaration = getDeclarationOfKind(parameterSymbol, SyntaxKind.Parameter); - Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol) && !!parameterSymbol.isRestParameter); + let parameterDeclaration: ParameterDeclaration | JSDocParameterTag = getDeclarationOfKind(parameterSymbol, SyntaxKind.Parameter); + if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { + parameterDeclaration = getDeclarationOfKind(parameterSymbol, SyntaxKind.JSDocParameterTag); + } let parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -3584,11 +3639,12 @@ namespace ts { const parameterTypeNode = typeToTypeNodeHelper(parameterType, context); const modifiers = !(context.flags & NodeBuilderFlags.OmitParameterModifiers) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone); - const dotDotDotToken = !parameterDeclaration || isRestParameter(parameterDeclaration) ? createToken(SyntaxKind.DotDotDotToken) : undefined; + const isRest = parameterDeclaration ? isRestParameter(parameterDeclaration) : (parameterSymbol as TransientSymbol).isRestParameter; + const dotDotDotToken = isRest ? createToken(SyntaxKind.DotDotDotToken) : undefined; const name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === SyntaxKind.Identifier ? - setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) : + parameterDeclaration.name.kind === SyntaxKind.Identifier ? setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) : + parameterDeclaration.name.kind === SyntaxKind.QualifiedName ? setEmitFlags(getSynthesizedClone(parameterDeclaration.name.right), EmitFlags.NoAsciiEscaping) : cloneBindingName(parameterDeclaration.name) : symbolName(parameterSymbol) : symbolName(parameterSymbol); @@ -3616,7 +3672,7 @@ namespace ts { } } - function lookupSymbolChain(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags) { + function lookupSymbolChain(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, yieldModuleSymbol?: boolean) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. let chain: Symbol[]; @@ -3656,7 +3712,7 @@ namespace ts { // 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`.) - !(!parentSymbol && forEach(symbol.declarations, hasExternalModuleSymbol)) && + (yieldModuleSymbol || !(!parentSymbol && forEach(symbol.declarations, hasExternalModuleSymbol))) && // If a parent symbol is an anonymous type, don't write it. !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { @@ -3694,8 +3750,18 @@ namespace ts { return typeParameterNodes; } - function symbolToTypeNode(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags): TypeQueryNode | TypeReferenceNode | ImportTypeNode { - const chain = lookupSymbolChain(symbol, context, meaning); + /** + * Given A[B][C][D], finds A[B] + */ + function getTopmostIndexedAccessType(top: IndexedAccessTypeNode): IndexedAccessTypeNode { + if (isIndexedAccessTypeNode(top.objectType)) { + return getTopmostIndexedAccessType(top.objectType); + } + return top; + } + + 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); @@ -3704,16 +3770,39 @@ namespace ts { const isTypeOf = meaning === SymbolFlags.Value; if (ambientModuleSymbolRegex.test(rootName)) { // module is root, must use `ImportTypeNode` - const nonRootParts = chain.length > 1 ? createEntityNameFromSymbolChain(chain, chain.length - 1, 1) : undefined; - const typeParameterNodes = lookupTypeParameterNodes(chain, 0, context); - return createImportTypeNode(createLiteralTypeNode(createLiteral(rootName.substring(1, rootName.length - 1))), nonRootParts, typeParameterNodes as ReadonlyArray, isTypeOf); + 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))); + if (!nonRootParts || isEntityName(nonRootParts)) { + if (nonRootParts) { + const lastId = isIdentifier(nonRootParts) ? nonRootParts : (nonRootParts as QualifiedName).right; + lastId.typeArguments = undefined; + } + return createImportTypeNode(lit, nonRootParts as EntityName, typeParameterNodes as ReadonlyArray, isTypeOf); + } + else { + const splitNode = getTopmostIndexedAccessType(nonRootParts); + const qualifier = (splitNode.objectType as TypeReferenceNode).typeName; + return createIndexedAccessTypeNode(createImportTypeNode(lit, qualifier, typeParameterNodes as ReadonlyArray, isTypeOf), splitNode.indexType); + } } - const entityName = createEntityNameFromSymbolChain(chain, chain.length - 1, 0); - return isTypeOf ? createTypeQueryNode(entityName) : createTypeReferenceNode(entityName, /*typeArguments*/ undefined); + const entityName = createAccessFromSymbolChain(chain, chain.length - 1, 0); + if (isIndexedAccessTypeNode(entityName)) { + return entityName; // Indexed accesses can never be `typeof` + } + if (isTypeOf) { + return createTypeQueryNode(entityName); + } + else { + const lastId = isIdentifier(entityName) ? entityName : entityName.right; + const lastTypeArgs = lastId.typeArguments; + lastId.typeArguments = undefined; + return createTypeReferenceNode(entityName, lastTypeArgs as NodeArray); + } - function createEntityNameFromSymbolChain(chain: Symbol[], index: number, stopper: number): EntityName { - const typeParameterNodes = lookupTypeParameterNodes(chain, index, context); + function createAccessFromSymbolChain(chain: Symbol[], index: number, stopper: number): EntityName | IndexedAccessTypeNode { + const typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); const symbol = chain[index]; if (index === 0) { @@ -3723,10 +3812,30 @@ namespace ts { if (index === 0) { context.flags ^= NodeBuilderFlags.InInitialEntityName; } + + const parent = chain[index - 1]; + if (!(context.flags & NodeBuilderFlags.ForbidIndexedAccessSymbolReferences) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + // Should use an indexed access + const LHS = createAccessFromSymbolChain(chain, index - 1, stopper); + if (isIndexedAccessTypeNode(LHS)) { + return createIndexedAccessTypeNode(LHS, createLiteralTypeNode(createLiteral(symbolName))); + } + else { + return createIndexedAccessTypeNode(createTypeReferenceNode(LHS, typeParameterNodes as ReadonlyArray), createLiteralTypeNode(createLiteral(symbolName))); + } + } + const identifier = setEmitFlags(createIdentifier(symbolName, typeParameterNodes), EmitFlags.NoAsciiEscaping); identifier.symbol = symbol; - return index > stopper ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1, stopper), identifier) : identifier; + if (index > stopper) { + const LHS = createAccessFromSymbolChain(chain, index - 1, stopper); + if (!isEntityName(LHS)) { + return Debug.fail("Impossible construct - an export of an indexed access cannot be reachable"); + } + return createQualifiedName(LHS, identifier); + } + return identifier; } } @@ -3753,6 +3862,7 @@ namespace ts { if (index === 0) { context.flags ^= NodeBuilderFlags.InInitialEntityName; } + const identifier = setEmitFlags(createIdentifier(symbolName, typeParameterNodes), EmitFlags.NoAsciiEscaping); identifier.symbol = symbol; @@ -3881,7 +3991,7 @@ namespace ts { // State encounteredError: boolean; - symbolStack: Symbol[] | undefined; + visitedSymbols: Map | undefined; inferTypeParameters: TypeParameter[] | undefined; } @@ -3907,6 +4017,23 @@ namespace ts { return "default"; } if (symbol.declarations && symbol.declarations.length) { + if (some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { + 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); + } + } + } + // ambient module, just use declaration/symbol name (fallthrough) + } + else { + return `"${getResolvedExternalModuleName(context.tracker.moduleResolverHost, file, getSourceFileOfNode(getOriginalNode(context.enclosingDeclaration)))}"`; + } + } const declaration = symbol.declarations[0]; const name = getNameOfDeclaration(declaration); if (name) { @@ -3951,6 +4078,11 @@ namespace ts { function determineIfDeclarationIsVisible() { switch (node.kind) { + case SyntaxKind.JSDocCallbackTag: + case SyntaxKind.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 && isSourceFile(node.parent.parent.parent)); case SyntaxKind.BindingElement: return isDeclarationVisible(node.parent.parent); case SyntaxKind.VariableDeclaration: @@ -4723,7 +4855,7 @@ namespace ts { if (symbol.flags & SymbolFlags.Prototype) { return links.type = getTypeOfPrototypeProperty(symbol); } - // CommonsJS require/module/exports all have type any. + // CommonsJS require and module both have type any. if (symbol === requireSymbol || symbol === moduleSymbol) { return links.type = anyType; } @@ -4758,7 +4890,7 @@ namespace ts { declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } - else if (isJSDocPropertyTag(declaration) + else if (isJSDocPropertyLikeTag(declaration) || isPropertyAccessExpression(declaration) || isIdentifier(declaration) || (isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration)) @@ -5030,7 +5162,7 @@ namespace ts { // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. - function appendTypeParameters(typeParameters: TypeParameter[], declarations: ReadonlyArray): TypeParameter[] { + function appendTypeParameters(typeParameters: TypeParameter[] | undefined, declarations: ReadonlyArray): TypeParameter[] { for (const declaration of declarations) { typeParameters = appendIfUnique(typeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration))); } @@ -5060,6 +5192,8 @@ namespace ts { case SyntaxKind.ArrowFunction: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.JSDocTemplateTag: + case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JSDocCallbackTag: case SyntaxKind.MappedType: case SyntaxKind.ConditionalType: const outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); @@ -5069,7 +5203,7 @@ namespace ts { else if (node.kind === SyntaxKind.ConditionalType) { return concatenate(outerTypeParameters, getInferTypeParameters(node)); } - const outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, getEffectiveTypeParameterDeclarations(node) || emptyArray); + const outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, getEffectiveTypeParameterDeclarations(node)); const thisType = includeThisTypes && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.InterfaceDeclaration) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; @@ -5087,15 +5221,14 @@ namespace ts { // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol: Symbol): TypeParameter[] { - let result: TypeParameter[]; + let result: TypeParameter[] | undefined; for (const node of symbol.declarations) { - if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.ClassDeclaration || - node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.TypeAliasDeclaration) { - const declaration = node; - const typeParameters = getEffectiveTypeParameterDeclarations(declaration); - if (typeParameters) { - result = appendTypeParameters(result, typeParameters); - } + if (node.kind === SyntaxKind.InterfaceDeclaration || + node.kind === SyntaxKind.ClassDeclaration || + node.kind === SyntaxKind.ClassExpression || + isTypeAlias(node)) { + const declaration = node; + result = appendTypeParameters(result, getEffectiveTypeParameterDeclarations(declaration)); } } return result; @@ -5387,9 +5520,9 @@ namespace ts { return unknownType; } - const declaration = find(symbol.declarations, d => - d.kind === SyntaxKind.JSDocTypedefTag || d.kind === SyntaxKind.TypeAliasDeclaration); - const typeNode = declaration.kind === SyntaxKind.JSDocTypedefTag ? declaration.typeExpression : declaration.type; + const declaration = find(symbol.declarations, d => + isJSDocTypeAlias(d) || d.kind === SyntaxKind.TypeAliasDeclaration); + const typeNode = isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. let type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; @@ -5605,7 +5738,7 @@ namespace ts { const typeParameters = getEffectiveTypeParameterDeclarations(node); return (node.kind === SyntaxKind.Constructor || (returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && - (!typeParameters || typeParameters.every(isThislessTypeParameter)); + typeParameters.every(isThislessTypeParameter); } /** @@ -5656,6 +5789,10 @@ namespace ts { const symbol = type.symbol; const members = getMembersOfSymbol(symbol); (type).declaredProperties = getNamedMembers(members); + // Start with signatures at empty array in case of recursive types + (type).declaredCallSignatures = emptyArray; + (type).declaredConstructSignatures = emptyArray; + (type).declaredCallSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.Call)); (type).declaredConstructSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.New)); (type).declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, IndexKind.String); @@ -5953,7 +6090,7 @@ namespace ts { } function createSignature( - declaration: SignatureDeclaration, + declaration: SignatureDeclaration | JSDocSignature, typeParameters: TypeParameter[], thisParameter: Symbol | undefined, parameters: Symbol[], @@ -6928,11 +7065,11 @@ namespace ts { // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). - function getTypeParametersFromDeclaration(declaration: DeclarationWithTypeParameters): TypeParameter[] { - let result: TypeParameter[]; - forEach(getEffectiveTypeParameterDeclarations(declaration), node => { + function getTypeParametersFromDeclaration(declaration: DeclarationWithTypeParameters): TypeParameter[] | undefined { + let result: TypeParameter[] | undefined; + for (const node of getEffectiveTypeParameterDeclarations(declaration)) { result = appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol)); - }); + } return result; } @@ -6963,8 +7100,8 @@ namespace ts { return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } - function isOptionalParameter(node: ParameterDeclaration) { - if (hasQuestionToken(node) || isJSDocOptionalParameter(node)) { + function isOptionalParameter(node: ParameterDeclaration | JSDocParameterTag) { + if (hasQuestionToken(node) || isOptionalJSDocParameterTag(node) || isJSDocOptionalParameter(node)) { return true; } @@ -6984,6 +7121,14 @@ namespace ts { return false; } + function isOptionalJSDocParameterTag(node: Node): node is JSDocParameterTag { + if (!isJSDocParameterTag(node)) { + return false; + } + const { isBracketed, typeExpression } = node; + return isBracketed || !!typeExpression && typeExpression.type.kind === SyntaxKind.JSDocOptionalType; + } + function createTypePredicateFromTypePredicateNode(node: TypePredicateNode): IdentifierTypePredicate | ThisTypePredicate { const { parameterName } = node; const type = getTypeFromTypeNode(node.type); @@ -7048,7 +7193,7 @@ namespace ts { for (let i = numTypeArguments; i < numTypeParameters; i++) { const mapper = createTypeMapper(typeParameters, typeArguments); let defaultType = getDefaultFromTypeParameter(typeParameters[i]); - if (defaultType && isTypeIdenticalTo(defaultType, emptyObjectType) && isJavaScriptImplicitAny) { + if (isJavaScriptImplicitAny && defaultType && isTypeIdenticalTo(defaultType, emptyObjectType)) { defaultType = anyType; } typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : getDefaultTypeArgumentType(isJavaScriptImplicitAny); @@ -7059,7 +7204,7 @@ namespace ts { return typeArguments; } - function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature { + function getSignatureFromDeclaration(declaration: SignatureDeclaration | JSDocSignature): Signature { const links = getNodeLinks(declaration); if (!links.resolvedSignature) { const parameters: Symbol[] = []; @@ -7082,6 +7227,7 @@ namespace ts { const param = declaration.parameters[i]; let paramSymbol = param.symbol; + const type = isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & SymbolFlags.Property) && !isBindingPattern(param.name)) { const resolvedSymbol = resolveName(param, paramSymbol.escapedName, SymbolFlags.Value, undefined, undefined, /*isUse*/ false); @@ -7095,13 +7241,14 @@ namespace ts { parameters.push(paramSymbol); } - if (param.type && param.type.kind === SyntaxKind.LiteralType) { + if (type && type.kind === SyntaxKind.LiteralType) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter - const isOptionalParameter = param.initializer || param.questionToken || param.dotDotDotToken || - iife && parameters.length > iife.arguments.length && !param.type || + const isOptionalParameter = isOptionalJSDocParameterTag(param) || + param.initializer || param.questionToken || param.dotDotDotToken || + iife && parameters.length > iife.arguments.length && !type || isUntypedSignatureInJSFile || isJSDocOptionalParameter(param); if (!isOptionalParameter) { @@ -7137,8 +7284,8 @@ namespace ts { * OR * 2. It has at least one parameter, and the last parameter has a matching `@param` with a type that starts with `...` */ - function maybeAddJsSyntheticRestParameter(declaration: SignatureDeclaration, parameters: Symbol[]): boolean { - if (!containsArgumentsReference(declaration)) { + function maybeAddJsSyntheticRestParameter(declaration: SignatureDeclaration | JSDocSignature, parameters: Symbol[]): boolean { + if (isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) { return false; } const lastParam = lastOrUndefined(declaration.parameters); @@ -7157,9 +7304,9 @@ namespace ts { return true; } - function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration, isJSConstructSignature: boolean, classType: Type) { + function getSignatureReturnTypeFromDeclaration(declaration: SignatureDeclaration | JSDocSignature, isJSConstructSignature: boolean, classType: Type) { if (isJSConstructSignature) { - return getTypeFromTypeNode(declaration.parameters[0].type); + return getTypeFromTypeNode((declaration.parameters[0] as ParameterDeclaration).type); } else if (classType) { return classType; @@ -7573,11 +7720,11 @@ namespace ts { const missingAugmentsTag = isJs && node.parent.kind !== SyntaxKind.JSDocAugmentsTag; const diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag - ? Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + ? Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag + : Diagnostics.Generic_type_0_requires_1_type_argument_s + : missingAugmentsTag + ? Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag + : Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; const typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -7592,7 +7739,7 @@ namespace ts { return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : unknownType; - } + } function getTypeAliasInstantiation(symbol: Symbol, typeArguments: Type[]): Type { const type = getDeclaredTypeOfSymbol(symbol); @@ -7619,18 +7766,18 @@ namespace ts { const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { error(node, - minTypeArgumentCount === typeParameters.length - ? Diagnostics.Generic_type_0_requires_1_type_argument_s - : Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, - symbolToString(symbol), - minTypeArgumentCount, - typeParameters.length); + minTypeArgumentCount === typeParameters.length + ? Diagnostics.Generic_type_0_requires_1_type_argument_s + : Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, + symbolToString(symbol), + minTypeArgumentCount, + typeParameters.length); return unknownType; } return getTypeAliasInstantiation(symbol, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : unknownType; - } + } function getTypeReferenceName(node: TypeReferenceType): EntityNameOrEntityNameExpression | undefined { switch (node.kind) { @@ -7745,7 +7892,7 @@ namespace ts { function getConstrainedTypeVariable(typeVariable: TypeVariable, node: Node) { let constraints: Type[]; - while (node && !isStatement(node)) { + while (node && !isStatement(node) && node.kind !== SyntaxKind.JSDocComment) { const parent = node.parent; if (parent.kind === SyntaxKind.ConditionalType && node === (parent).trueType) { const constraint = getImpliedConstraint(typeVariable, (parent).checkType, (parent).extendsType); @@ -8244,7 +8391,7 @@ namespace ts { includes & TypeFlags.Undefined ? includes & TypeFlags.NonWideningType ? undefinedType : undefinedWideningType : neverType; } - return getUnionTypeFromSortedList(typeSet, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & TypeFlags.NotUnit ? 0 : TypeFlags.UnionOfUnitTypes, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures: ReadonlyArray): TypePredicate { @@ -8284,7 +8431,7 @@ namespace ts { } // This function assumes the constituent type list is sorted and deduplicated. - function getUnionTypeFromSortedList(types: Type[], aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type { + function getUnionTypeFromSortedList(types: Type[], unionOfUnitTypes: TypeFlags, aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type { if (types.length === 0) { return neverType; } @@ -8295,7 +8442,7 @@ namespace ts { let type = unionTypes.get(id); if (!type) { const propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); - type = createType(TypeFlags.Union | propagatedFlags); + type = createType(TypeFlags.Union | propagatedFlags | unionOfUnitTypes); unionTypes.set(id, type); type.types = types; /* @@ -8313,8 +8460,9 @@ namespace ts { function getTypeFromUnionTypeNode(node: UnionTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { + const aliasSymbol = getAliasSymbolForTypeNode(node); links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), UnionReduction.Literal, - getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); + aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } @@ -8366,6 +8514,29 @@ namespace ts { } } + // When intersecting unions of unit types we can simply intersect based on type identity. + // Here we remove all unions of unit types from the given list and replace them with a + // a single union containing an intersection of the unit types. + function intersectUnionsOfUnitTypes(types: Type[]) { + const unionIndex = findIndex(types, t => (t.flags & TypeFlags.UnionOfUnitTypes) !== 0); + const unionType = types[unionIndex]; + let intersection = unionType.types; + let i = types.length - 1; + while (i > unionIndex) { + const t = types[i]; + if (t.flags & TypeFlags.UnionOfUnitTypes) { + intersection = filter(intersection, u => containsType((t).types, u)); + orderedRemoveItemAt(types, i); + } + i--; + } + if (intersection === unionType.types) { + return false; + } + types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & TypeFlags.UnionOfUnitTypes); + return true; + } + // We normalize combinations of intersection and union types based on the distributive property of the '&' // operator. Specifically, because X & (A | B) is equivalent to X & A | X & B, we can transform intersection // types with union type constituents into equivalent union types with intersection type constituents and @@ -8400,6 +8571,12 @@ namespace ts { return typeSet[0]; } if (includes & TypeFlags.Union) { + if (includes & TypeFlags.UnionOfUnitTypes && intersectUnionsOfUnitTypes(typeSet)) { + // When the intersection creates a reduced set (which might mean that *all* union types have + // disappeared), we restart the operation to get a new set of combined flags. Once we have + // reduced we'll never reduce again, so this occurs at most once. + return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); + } // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. const unionIndex = findIndex(typeSet, t => (t.flags & TypeFlags.Union) !== 0); @@ -8423,8 +8600,9 @@ namespace ts { function getTypeFromIntersectionTypeNode(node: IntersectionTypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { + const aliasSymbol = getAliasSymbolForTypeNode(node); links.resolvedType = getIntersectionType(map(node.types, getTypeFromTypeNode), - getAliasSymbolForTypeNode(node), getAliasTypeArgumentsForTypeNode(node)); + aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } @@ -8617,6 +8795,10 @@ namespace ts { // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return // the type itself if no transformation is possible. function getSimplifiedIndexedAccessType(type: IndexedAccessType): Type { + if (type.simplified) { + return type.simplified === circularConstraintType ? type : type.simplified; + } + type.simplified = circularConstraintType; const objectType = type.objectType; if (objectType.flags & TypeFlags.Intersection && isGenericObjectType(objectType)) { // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or @@ -8634,7 +8816,7 @@ namespace ts { regularTypes.push(t); } } - return getUnionType([ + return type.simplified = getUnionType([ getSimplifiedType(getIndexedAccessType(getIntersectionType(regularTypes), type.indexType)), getIntersectionType(stringIndexTypes) ]); @@ -8645,7 +8827,7 @@ namespace ts { // eventually anyway, but it easier to reason about. if (some((objectType).types, isMappedTypeToNever)) { const nonNeverTypes = filter((objectType).types, t => !isMappedTypeToNever(t)); - return getSimplifiedType(getIndexedAccessType(getIntersectionType(nonNeverTypes), type.indexType)); + return type.simplified = getSimplifiedType(getIndexedAccessType(getIntersectionType(nonNeverTypes), type.indexType)); } } // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper @@ -8653,15 +8835,15 @@ namespace ts { // construct the type Box. We do not further simplify the result because mapped types can be recursive // and we might never terminate. if (isGenericMappedType(objectType)) { - return substituteIndexedMappedType(objectType, type); + return type.simplified = substituteIndexedMappedType(objectType, type); } if (objectType.flags & TypeFlags.TypeParameter) { const constraint = getConstraintFromTypeParameter(objectType as TypeParameter); if (constraint && isGenericMappedType(constraint)) { - return substituteIndexedMappedType(constraint, type); + return type.simplified = substituteIndexedMappedType(constraint, type); } } - return type; + return type.simplified = type; } function substituteIndexedMappedType(objectType: MappedType, type: IndexedAccessType) { @@ -8729,7 +8911,7 @@ namespace ts { const type = createObjectType(ObjectFlags.Mapped, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); - type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); + type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); links.resolvedType = type; // Eagerly resolve the constraint type which forces an error if the constraint type circularly // references itself through one or more type aliases. @@ -8837,7 +9019,8 @@ namespace ts { const links = getNodeLinks(node); if (!links.resolvedType) { const checkType = getTypeFromTypeNode(node.checkType); - const aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); + const aliasSymbol = getAliasSymbolForTypeNode(node); + const aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); const allOuterTypeParameters = getOuterTypeParameters(node, /*includeThisTypes*/ true); const outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : filter(allOuterTypeParameters, tp => isPossiblyReferencedInConditionalType(tp, node)); const root: ConditionalRoot = { @@ -8850,7 +9033,7 @@ namespace ts { inferTypeParameters: getInferTypeParameters(node), outerTypeParameters, instantiations: undefined, - aliasSymbol: getAliasSymbolForTypeNode(node), + aliasSymbol, aliasTypeArguments }; links.resolvedType = getConditionalType(root, /*mapper*/ undefined); @@ -8954,7 +9137,7 @@ namespace ts { else { let type = createObjectType(ObjectFlags.Anonymous, node.symbol); type.aliasSymbol = aliasSymbol; - type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); + type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (isJSDocTypeLiteral(node) && node.isArrayType) { type = createArrayType(type); } @@ -8965,11 +9148,10 @@ namespace ts { } function getAliasSymbolForTypeNode(node: TypeNode) { - return node.parent.kind === SyntaxKind.TypeAliasDeclaration ? getSymbolOfNode(node.parent) : undefined; + return isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; } - function getAliasTypeArgumentsForTypeNode(node: TypeNode) { - const symbol = getAliasSymbolForTypeNode(node); + function getTypeArgumentsForAliasSymbol(symbol: Symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } @@ -9227,6 +9409,7 @@ namespace ts { case SyntaxKind.TypeLiteral: case SyntaxKind.JSDocTypeLiteral: case SyntaxKind.JSDocFunctionType: + case SyntaxKind.JSDocSignature: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case SyntaxKind.TypeOperator: return getTypeFromTypeOperatorNode(node); @@ -9436,7 +9619,16 @@ namespace ts { // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - const declaration = symbol.declarations[0]; + let declaration = symbol.declarations[0]; + if (isInJavaScriptFile(declaration)) { + const paramTag = findAncestor(declaration, isJSDocParameterTag); + if (paramTag) { + const paramSymbol = getParameterSymbolFromJSDoc(paramTag); + if (paramSymbol) { + declaration = paramSymbol.valueDeclaration; + } + } + } let outerTypeParameters = getOuterTypeParameters(declaration, /*includeThisTypes*/ true); if (isJavaScriptConstructor(declaration)) { const templateTagParameters = getTypeParametersFromDeclaration(declaration as DeclarationWithTypeParameters); @@ -9904,8 +10096,8 @@ namespace ts { function compareTypePredicateRelatedTo( source: TypePredicate, target: TypePredicate, - sourceDeclaration: SignatureDeclaration, - targetDeclaration: SignatureDeclaration, + sourceDeclaration: SignatureDeclaration | JSDocSignature, + targetDeclaration: SignatureDeclaration | JSDocSignature, reportErrors: boolean, errorReporter: ErrorReporter, compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary { @@ -10762,9 +10954,12 @@ namespace ts { return result; } } - else if (result = isRelatedTo(constraint, target, reportErrors)) { - errorInfo = saveErrorInfo; - return result; + else { + const instantiated = getTypeWithThisArgument(constraint, source); + if (result = isRelatedTo(instantiated, target, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } else if (source.flags & TypeFlags.Index) { @@ -13159,7 +13354,7 @@ namespace ts { if (type.flags & TypeFlags.Union) { const types = (type).types; const filtered = filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & TypeFlags.UnionOfUnitTypes); } return f(type) ? type : neverType; } @@ -15274,8 +15469,18 @@ namespace ts { } } - if (context.typeArguments) { - signatures = mapDefined(signatures, s => getJsxSignatureTypeArgumentInstantiation(s, context, isJs)); + const links = getNodeLinks(context); + if (!links.resolvedSignatures) { + links.resolvedSignatures = createMap(); + } + const cacheKey = "" + getTypeId(valueType); + const cachedResolved = links.resolvedSignatures.get(cacheKey); + if (cachedResolved && cachedResolved !== resolvingSignaturesArray) { + signatures = cachedResolved; + } + else if (!cachedResolved) { + links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); + links.resolvedSignatures.set(cacheKey, signatures = instantiateJsxSignatures(context, signatures)); } return getUnionType(map(signatures, ctor ? t => getJsxPropsTypeFromClassType(t, isJs, context, /*reportErrors*/ false) : t => getJsxPropsTypeFromCallSignature(t, context)), UnionReduction.None); @@ -16256,6 +16461,40 @@ namespace ts { return undefined; } + function getInstantiatedJsxSignatures(openingLikeElement: JsxOpeningLikeElement, elementType: Type, reportErrors?: boolean) { + const links = getNodeLinks(openingLikeElement); + if (!links.resolvedSignatures) { + links.resolvedSignatures = createMap(); + } + const cacheKey = "" + getTypeId(elementType); + if (links.resolvedSignatures.get(cacheKey) && links.resolvedSignatures.get(cacheKey) === resolvingSignaturesArray) { + return; + } + else if (links.resolvedSignatures.get(cacheKey)) { + return links.resolvedSignatures.get(cacheKey); + } + + links.resolvedSignatures.set(cacheKey, resolvingSignaturesArray); + // Resolve the signatures, preferring constructor + let signatures = getSignaturesOfType(elementType, SignatureKind.Construct); + if (signatures.length === 0) { + // No construct signatures, try call signatures + signatures = getSignaturesOfType(elementType, SignatureKind.Call); + if (signatures.length === 0) { + // We found no signatures at all, which is an error + if (reportErrors) { + error(openingLikeElement.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(openingLikeElement.tagName)); + } + return; + } + } + + // Instantiate in context of source type + const results = instantiateJsxSignatures(openingLikeElement, signatures); + links.resolvedSignatures.set(cacheKey, results); + return results; + } + /** * Resolve attributes type of the given opening-like element. The attributes type is a type of attributes associated with the given elementType. * For instance: @@ -16318,20 +16557,10 @@ namespace ts { // Get the element instance type (the result of newing or invoking this tag) - // Resolve the signatures, preferring constructor - let signatures = getSignaturesOfType(elementType, SignatureKind.Construct); - if (signatures.length === 0) { - // No construct signatures, try call signatures - signatures = getSignaturesOfType(elementType, SignatureKind.Call); - if (signatures.length === 0) { - // We found no signatures at all, which is an error - error(openingLikeElement.tagName, Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, getTextOfNode(openingLikeElement.tagName)); - return unknownType; - } + const instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); + if (!length(instantiatedSignatures)) { + return unknownType; } - - // Instantiate in context of source type - const instantiatedSignatures = instantiateJsxSignatures(openingLikeElement, signatures); const elemInstanceType = getUnionType(map(instantiatedSignatures, getReturnTypeOfSignature), UnionReduction.Subtype); // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. @@ -18021,11 +18250,11 @@ namespace ts { let typeArguments: NodeArray; - if (!isDecorator && !isJsxOpeningOrSelfClosingElement) { + if (!isDecorator) { typeArguments = (node).typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || (node).expression.kind !== SyntaxKind.SuperKeyword) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || (node).expression.kind !== SyntaxKind.SuperKeyword) { forEach(typeArguments, checkSourceElement); } } @@ -18614,30 +18843,6 @@ namespace ts { */ function getResolvedJsxStatelessFunctionSignature(openingLikeElement: JsxOpeningLikeElement, elementType: Type, candidatesOutArray: Signature[]): Signature | undefined { Debug.assert(!(elementType.flags & TypeFlags.Union)); - return resolveStatelessJsxOpeningLikeElement(openingLikeElement, elementType, candidatesOutArray); - } - - /** - * Try treating a given opening-like element as stateless function component and resolve a tagName to a function signature. - * @param openingLikeElement an JSX opening-like element we want to try resolve its stateless function if possible - * @param elementType a type of the opening-like JSX element, a result of resolving tagName in opening-like element. - * @param candidatesOutArray an array of signature to be filled in by the function. It is passed by signature help in the language service; - * the function will fill it up with appropriate candidate signatures - * @return a resolved signature if we can find function matching function signature through resolve call or a first signature in the list of functions. - * otherwise return undefined if tag-name of the opening-like element doesn't have call signatures - */ - function resolveStatelessJsxOpeningLikeElement(openingLikeElement: JsxOpeningLikeElement, elementType: Type, candidatesOutArray: Signature[]): Signature | undefined { - // If this function is called from language service, elementType can be a union type. This is not possible if the function is called from compiler (see: resolveCustomJsxElementAttributesType) - if (elementType.flags & TypeFlags.Union) { - const types = (elementType as UnionType).types; - let result: Signature; - for (const type of types) { - result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); - } - - return result; - } - const callSignatures = elementType && getSignaturesOfType(elementType, SignatureKind.Call); if (callSignatures && callSignatures.length > 0) { return resolveCall(openingLikeElement, callSignatures, candidatesOutArray); @@ -18659,7 +18864,18 @@ namespace ts { case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxSelfClosingElement: // This code-path is called by language service - return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray) || unknownSignature; + const exprTypes = checkExpression(node.tagName); + return forEachType(exprTypes, exprType => { + const sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray); + if (sfcResult && sfcResult !== unknownSignature) { + return sfcResult; + } + const sigs = getInstantiatedJsxSignatures(node, exprType); + if (candidatesOutArray && length(sigs)) { + candidatesOutArray.push(...sigs); + } + return length(sigs) ? sigs[0] : unknownSignature; + }) || unknownSignature; } Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } @@ -19382,7 +19598,7 @@ namespace ts { } const links = getNodeLinks(node); - const type = getTypeOfSymbol(node.symbol); + const type = getTypeOfSymbol(getMergedSymbol(node.symbol)); if (isTypeAny(type)) { return type; } @@ -21654,8 +21870,9 @@ namespace ts { switch (d.kind) { case SyntaxKind.InterfaceDeclaration: case SyntaxKind.TypeAliasDeclaration: - // A jsdoc typedef is, by definition, a type alias + // A jsdoc typedef and callback are, by definition, type aliases case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JSDocCallbackTag: return DeclarationSpaces.ExportType; case SyntaxKind.ModuleDeclaration: return isAmbientModule(d as ModuleDeclaration) || getModuleInstanceState(d as ModuleDeclaration) !== ModuleInstanceState.NonInstantiated @@ -22190,7 +22407,7 @@ namespace ts { } } - function checkJSDocTypedefTag(node: JSDocTypedefTag) { + function checkJSDocTypeAliasTag(node: JSDocTypedefTag | JSDocCallbackTag) { if (!node.typeExpression) { // If the node had `@property` tags, `typeExpression` would have been set to the first property tag. error(node.name, Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags); @@ -22337,7 +22554,13 @@ namespace ts { function registerForUnusedIdentifiersCheck(node: PotentiallyUnusedIdentifier): void { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (potentiallyUnusedIdentifiers) { + if (produceDiagnostics) { + const sourceFile = getSourceFileOfNode(node); + let potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); + if (!potentiallyUnusedIdentifiers) { + potentiallyUnusedIdentifiers = []; + allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers); + } // TODO: GH#22580 // Debug.assert(addToSeen(seenPotentiallyUnusedIdentifiers, getNodeId(node)), "Adding potentially-unused identifier twice"); potentiallyUnusedIdentifiers.push(node); @@ -22459,7 +22682,7 @@ namespace ts { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. const typeParameters = getEffectiveTypeParameterDeclarations(node); - if (!(node.flags & NodeFlags.Ambient) && typeParameters && last(getSymbolOfNode(node)!.declarations) === node) { + 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))); @@ -22538,11 +22761,11 @@ namespace ts { const kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? UnusedKind.Parameter : UnusedKind.Local; if (!bindingPattern.elements.every(e => contains(bindingElements, e))) { for (const e of bindingElements) { - addDiagnostic(kind, createDiagnosticForNode(e, Diagnostics._0_is_declared_but_its_value_is_never_read, getBindingElementNameText(e))); + addDiagnostic(kind, createDiagnosticForNode(e, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(e.name, isIdentifier)))); } } else if (bindingElements.length === 1) { - addDiagnostic(kind, createDiagnosticForNode(bindingPattern, Diagnostics._0_is_declared_but_its_value_is_never_read, getBindingElementNameText(first(bindingElements)))); + addDiagnostic(kind, createDiagnosticForNode(bindingPattern, Diagnostics._0_is_declared_but_its_value_is_never_read, idText(cast(first(bindingElements).name, isIdentifier)))); } else { addDiagnostic(kind, createDiagnosticForNode(bindingPattern, Diagnostics.All_destructured_elements_are_unused)); @@ -23827,7 +24050,7 @@ namespace ts { /** * Check each type parameter and check that type parameters have no duplicate type parameter declarations */ - function checkTypeParameters(typeParameterDeclarations: ReadonlyArray) { + function checkTypeParameters(typeParameterDeclarations: ReadonlyArray | undefined) { if (typeParameterDeclarations) { let seenDefault = false; for (let i = 0; i < typeParameterDeclarations.length; i++) { @@ -23883,7 +24106,7 @@ namespace ts { for (const declaration of declarations) { // If this declaration has too few or too many type parameters, we report an error const sourceParameters = getEffectiveTypeParameterDeclarations(declaration); - const numTypeParameters = length(sourceParameters); + const numTypeParameters = sourceParameters.length; if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { return false; } @@ -25105,7 +25328,8 @@ namespace ts { case SyntaxKind.JSDocAugmentsTag: return checkJSDocAugmentsTag(node as JSDocAugmentsTag); case SyntaxKind.JSDocTypedefTag: - return checkJSDocTypedefTag(node as JSDocTypedefTag); + case SyntaxKind.JSDocCallbackTag: + return checkJSDocTypeAliasTag(node as JSDocTypedefTag); case SyntaxKind.JSDocParameterTag: return checkJSDocParameterTag(node as JSDocParameterTag); case SyntaxKind.JSDocFunctionType: @@ -25318,6 +25542,10 @@ namespace ts { } } + function getPotentiallyUnusedIdentifiers(sourceFile: SourceFile): ReadonlyArray { + return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || emptyArray; + } + // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node: SourceFile) { const links = getNodeLinks(node); @@ -25336,11 +25564,6 @@ namespace ts { clear(potentialNewTargetCollisions); deferredNodes = []; - if (produceDiagnostics) { - Debug.assert(!allPotentiallyUnusedIdentifiers.has(node.fileName)); - allPotentiallyUnusedIdentifiers.set(node.fileName, potentiallyUnusedIdentifiers = []); - } - forEach(node.statements, checkSourceElement); checkDeferredNodes(); @@ -25350,7 +25573,7 @@ namespace ts { } if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { - checkUnusedIdentifiers(potentiallyUnusedIdentifiers, (kind, diag) => { + checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), (kind, diag) => { if (unusedIsError(kind)) { diagnostics.add(diag); } @@ -25358,8 +25581,6 @@ namespace ts { } deferredNodes = undefined; - seenPotentiallyUnusedIdentifiers.clear(); - potentiallyUnusedIdentifiers = undefined; if (isExternalOrCommonJsModule(node)) { checkExternalModuleExports(node); @@ -26316,9 +26537,10 @@ namespace ts { return false; } - function isRequiredInitializedParameter(parameter: ParameterDeclaration) { + function isRequiredInitializedParameter(parameter: ParameterDeclaration | JSDocParameterTag) { return strictNullChecks && !isOptionalParameter(parameter) && + !isJSDocParameterTag(parameter) && parameter.initializer && !hasModifier(parameter, ModifierFlags.ParameterPropertyModifier); } @@ -26594,7 +26816,22 @@ namespace ts { const symbol = node && getSymbolOfNode(node); return !!(symbol && getCheckFlags(symbol) & CheckFlags.Late); }, - getJsxFactoryEntity: location => location ? (getJsxNamespace(location), (getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity + getJsxFactoryEntity: location => location ? (getJsxNamespace(location), (getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity, + getAllAccessorDeclarations(accessor: AccessorDeclaration): AllAccessorDeclarations { + accessor = getParseTreeNode(accessor, isGetOrSetAccessorDeclaration); + const otherKind = accessor.kind === SyntaxKind.SetAccessor ? SyntaxKind.GetAccessor : SyntaxKind.SetAccessor; + const otherAccessor = getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); + const firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; + const secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; + const setAccessor = accessor.kind === SyntaxKind.SetAccessor ? accessor : otherAccessor; + const getAccessor = accessor.kind === SyntaxKind.GetAccessor ? accessor : otherAccessor; + return { + firstAccessor, + secondAccessor, + setAccessor, + getAccessor + }; + } }; function isInHeritageClause(node: PropertyAccessEntityNameExpression) { @@ -27134,7 +27371,7 @@ namespace ts { } } - function checkGrammarTypeParameterList(typeParameters: NodeArray, file: SourceFile): boolean { + function checkGrammarTypeParameterList(typeParameters: NodeArray | undefined, file: SourceFile): boolean { if (typeParameters && typeParameters.length === 0) { const start = typeParameters.pos - "<".length; const end = skipTrivia(file.text, typeParameters.end) + ">".length; @@ -27190,7 +27427,7 @@ namespace ts { function checkGrammarClassLikeDeclaration(node: ClassLikeDeclaration): boolean { const file = getSourceFileOfNode(node); - return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(getEffectiveTypeParameterDeclarations(node), file); + return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); } function checkGrammarArrowFunction(node: Node, file: SourceFile): boolean { @@ -27962,8 +28199,8 @@ namespace ts { function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) { const typeParameters = getEffectiveTypeParameterDeclarations(node); - if (typeParameters) { - const { pos, end } = isNodeArray(typeParameters) ? typeParameters : first(typeParameters); + if (isNodeArray(typeParameters)) { + const { pos, end } = typeParameters; return grammarErrorAtPos(node, pos, end - pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } @@ -28127,7 +28364,7 @@ namespace ts { function checkGrammarImportCallExpression(node: ImportCall): boolean { if (moduleKind === ModuleKind.ES2015) { - return grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_be_used_when_targeting_ECMAScript_2015_modules); + return grammarErrorOnNode(node, Diagnostics.Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext); } if (node.typeArguments) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 395fe633a03..9048e401da1 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1605,10 +1605,12 @@ namespace ts { createCompilerDiagnosticOnlyIfJson(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array"); } } - else { - const outDir = raw.compilerOptions && raw.compilerOptions.outDir; - if (outDir) { - excludeSpecs = [outDir]; + else if (raw.compilerOptions) { + const outDir = raw.compilerOptions.outDir; + const declarationDir = raw.compilerOptions.declarationDir; + + if (outDir || declarationDir) { + excludeSpecs = [outDir, declarationDir].filter(d => !!d); } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 9cc7d0680e6..41e754a689e 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -311,8 +311,17 @@ namespace ts { } /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */ - export function findIndex(array: ReadonlyArray, predicate: (element: T, index: number) => boolean): number { - for (let i = 0; i < array.length; i++) { + export function findIndex(array: ReadonlyArray, predicate: (element: T, index: number) => boolean, startIndex?: number): number { + for (let i = startIndex || 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + + export function findLastIndex(array: ReadonlyArray, predicate: (element: T, index: number) => boolean, startIndex?: number): number { + for (let i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) { if (predicate(array[i], i)) { return i; } @@ -696,6 +705,23 @@ namespace ts { return false; } + /** Calls the callback with (start, afterEnd) index pairs for each range where 'pred' is true. */ + export function getRangesWhere(arr: ReadonlyArray, pred: (t: T) => boolean, cb: (start: number, afterEnd: number) => void): void { + let start: number | undefined; + for (let i = 0; i < arr.length; i++) { + if (pred(arr[i])) { + start = start === undefined ? i : start; + } + else { + if (start !== undefined) { + cb(start, i); + start = undefined; + } + } + } + if (start !== undefined) cb(start, arr.length); + } + export function concatenate(array1: T[], array2: T[]): T[]; export function concatenate(array1: ReadonlyArray, array2: ReadonlyArray): ReadonlyArray; export function concatenate(array1: T[], array2: T[]): T[] { @@ -951,6 +977,21 @@ namespace ts { return to; } + /** + * 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. + */ + export function prependRange(to: T[], from: ReadonlyArray | undefined): T[] | undefined { + if (from === undefined || from.length === 0) return to; + if (to === undefined) return from.slice(); + to.unshift(...from); + return to; + } + /** * @return Whether the value was added. */ @@ -2294,20 +2335,24 @@ namespace ts { return ["", ...relative, ...components]; } + export function getRelativePathFromFile(from: string, to: string, getCanonicalFileName: GetCanonicalFileName) { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); + } + /** * Gets a relative path that can be used to traverse between `from` and `to`. */ - export function getRelativePath(from: string, to: string, ignoreCase: boolean): string; + export function getRelativePathFromDirectory(from: string, to: string, ignoreCase: boolean): string; /** * Gets a relative path that can be used to traverse between `from` and `to`. */ // tslint:disable-next-line:unified-signatures - export function getRelativePath(from: string, to: string, getCanonicalFileName: GetCanonicalFileName): string; - export function getRelativePath(from: string, to: string, getCanonicalFileNameOrIgnoreCase: GetCanonicalFileName | boolean) { - Debug.assert((getRootLength(from) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); + export function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileName: GetCanonicalFileName): string; + export function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileNameOrIgnoreCase: GetCanonicalFileName | boolean) { + Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); const getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : identity; const ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; - const pathComponents = getPathComponentsRelativeTo(from, to, ignoreCase ? equateStringsCaseInsensitive : equateStringsCaseSensitive, getCanonicalFileName); + const pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? equateStringsCaseInsensitive : equateStringsCaseSensitive, getCanonicalFileName); return getPathFromPathComponents(pathComponents); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f96c950d8a9..b363fceb932 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -895,7 +895,7 @@ "category": "Error", "code": 1322 }, - "Dynamic import cannot be used when targeting ECMAScript 2015 modules.": { + "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'.": { "category": "Error", "code": 1323 }, @@ -4245,5 +4245,29 @@ "Convert all 'require' to 'import'": { "category": "Message", "code": 95048 + }, + "Move to a new file": { + "category": "Message", + "code": 95049 + }, + "Remove unreachable code": { + "category": "Message", + "code": 95050 + }, + "Remove all unreachable code": { + "category": "Message", + "code": 95051 + }, + "Add missing 'typeof'": { + "category": "Message", + "code": 95052 + }, + "Remove unused label": { + "category": "Message", + "code": 95053 + }, + "Remove all unused labels": { + "category": "Message", + "code": 95054 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b4ff2617a0d..f4d1d85456d 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1132,6 +1132,7 @@ namespace ts { } function emitMethodSignature(node: MethodSignature) { + pushNameGenerationScope(node); emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); @@ -1140,6 +1141,7 @@ namespace ts { emitParameters(node, node.parameters); emitTypeAnnotation(node.type); writeSemicolon(); + popNameGenerationScope(node); } function emitMethodDeclaration(node: MethodDeclaration) { @@ -1167,15 +1169,18 @@ namespace ts { } function emitCallSignature(node: CallSignatureDeclaration) { + pushNameGenerationScope(node); emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); writeSemicolon(); + popNameGenerationScope(node); } function emitConstructSignature(node: ConstructSignatureDeclaration) { + pushNameGenerationScope(node); emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); writeKeyword("new"); @@ -1184,6 +1189,7 @@ namespace ts { emitParameters(node, node.parameters); emitTypeAnnotation(node.type); writeSemicolon(); + popNameGenerationScope(node); } function emitIndexSignature(node: IndexSignatureDeclaration) { @@ -1216,12 +1222,14 @@ namespace ts { } function emitFunctionType(node: FunctionTypeNode) { + pushNameGenerationScope(node); emitTypeParameters(node, node.typeParameters); emitParametersForArrow(node, node.parameters); writeSpace(); writePunctuation("=>"); writeSpace(); emit(node.type); + popNameGenerationScope(node); } function emitJSDocFunctionType(node: JSDocFunctionType) { @@ -1248,6 +1256,7 @@ namespace ts { } function emitConstructorType(node: ConstructorTypeNode) { + pushNameGenerationScope(node); writeKeyword("new"); writeSpace(); emitTypeParameters(node, node.typeParameters); @@ -1256,6 +1265,7 @@ namespace ts { writePunctuation("=>"); writeSpace(); emit(node.type); + popNameGenerationScope(node); } function emitTypeQuery(node: TypeQueryNode) { @@ -3241,7 +3251,7 @@ namespace ts { if (isGeneratedIdentifier(node)) { return generateName(node); } - else if (isIdentifier(node) && (nodeIsSynthesized(node) || !node.parent)) { + else if (isIdentifier(node) && (nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && getSourceFileOfNode(node) !== getOriginalNode(currentSourceFile)))) { return idText(node); } else if (node.kind === SyntaxKind.StringLiteral && (node).textSourceNode) { @@ -3415,7 +3425,7 @@ namespace ts { if ((name.autoGenerateFlags & GeneratedIdentifierFlags.KindMask) === GeneratedIdentifierFlags.Node) { // Node names generate unique names based on their original node // and are cached based on that node's id. - return generateNameCached(getNodeForGeneratedName(name)); + return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); } else { // Auto, Loop, and Unique names are cached based on their unique @@ -3425,9 +3435,9 @@ namespace ts { } } - function generateNameCached(node: Node) { + function generateNameCached(node: Node, flags?: GeneratedIdentifierFlags) { const nodeId = getNodeId(node); - return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = generateNameForNode(node)); + return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = generateNameForNode(node, flags)); } /** @@ -3444,7 +3454,7 @@ namespace ts { * Returns a value indicating whether a name is unique globally or within the current file. */ function isFileLevelUniqueName(name: string) { - return ts.isFileLevelUniqueName(currentSourceFile, name, hasGlobalName); + return currentSourceFile ? ts.isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) : true; } /** @@ -3504,10 +3514,15 @@ namespace ts { * makeUniqueName are guaranteed to never conflict. * If `optimistic` is set, the first instance will use 'baseName' verbatim instead of 'baseName_1' */ - function makeUniqueName(baseName: string, checkFn: (name: string) => boolean = isUniqueName, optimistic?: boolean): string { + function makeUniqueName(baseName: string, checkFn: (name: string) => boolean = isUniqueName, optimistic?: boolean, scoped?: boolean): string { if (optimistic) { if (checkFn(baseName)) { - generatedNames.set(baseName, true); + if (scoped) { + reserveNameInNestedScopes(baseName); + } + else { + generatedNames.set(baseName, true); + } return baseName; } } @@ -3519,7 +3534,12 @@ namespace ts { while (true) { const generatedName = baseName + i; if (checkFn(generatedName)) { - generatedNames.set(generatedName, true); + if (scoped) { + reserveNameInNestedScopes(generatedName); + } + else { + generatedNames.set(generatedName, true); + } return generatedName; } i++; @@ -3573,10 +3593,15 @@ namespace ts { /** * Generates a unique name from a node. */ - function generateNameForNode(node: Node): string { + function generateNameForNode(node: Node, flags?: GeneratedIdentifierFlags): string { switch (node.kind) { case SyntaxKind.Identifier: - return makeUniqueName(getTextOfNode(node)); + return makeUniqueName( + getTextOfNode(node), + isUniqueName, + !!(flags & GeneratedIdentifierFlags.Optimistic), + !!(flags & GeneratedIdentifierFlags.ReservedInNestedScopes) + ); case SyntaxKind.ModuleDeclaration: case SyntaxKind.EnumDeclaration: return generateNameForModuleOrEnum(node); @@ -3611,7 +3636,8 @@ namespace ts { return makeUniqueName( idText(name), (name.autoGenerateFlags & GeneratedIdentifierFlags.FileLevel) ? isFileLevelUniqueName : isUniqueName, - !!(name.autoGenerateFlags & GeneratedIdentifierFlags.Optimistic) + !!(name.autoGenerateFlags & GeneratedIdentifierFlags.Optimistic), + !!(name.autoGenerateFlags & GeneratedIdentifierFlags.ReservedInNestedScopes) ); } @@ -3631,7 +3657,7 @@ namespace ts { // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (isIdentifier(node) - && node.autoGenerateFlags === GeneratedIdentifierFlags.Node + && !!(node.autoGenerateFlags & GeneratedIdentifierFlags.Node) && node.autoGenerateId !== autoGenerateId) { break; } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index e8916ac62e5..a286c9fae35 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -93,12 +93,18 @@ namespace ts { return node; } - function createStringLiteral(text: string): StringLiteral { + export function createStringLiteral(text: string): StringLiteral { const node = createSynthesizedNode(SyntaxKind.StringLiteral); node.text = text; return node; } + export function createRegularExpressionLiteral(text: string): RegularExpressionLiteral { + const node = createSynthesizedNode(SyntaxKind.RegularExpressionLiteral); + node.text = text; + return node; + } + function createLiteralFromNode(sourceNode: PropertyNameLiteral): StringLiteral { const node = createStringLiteral(getTextOfIdentifierOrLiteral(sourceNode)); node.textSourceNode = sourceNode; @@ -186,9 +192,11 @@ namespace ts { } /** Create a unique name generated for a node. */ - export function getGeneratedNameForNode(node: Node): Identifier { - const name = createIdentifier(""); - name.autoGenerateFlags = GeneratedIdentifierFlags.Node; + export function getGeneratedNameForNode(node: Node): Identifier; + /* @internal */ export function getGeneratedNameForNode(node: Node, flags: GeneratedIdentifierFlags): Identifier; // tslint:disable-line unified-signatures + export function getGeneratedNameForNode(node: Node, flags?: GeneratedIdentifierFlags): Identifier { + const name = createIdentifier(isIdentifier(node) ? idText(node) : ""); + name.autoGenerateFlags = GeneratedIdentifierFlags.Node | flags; name.autoGenerateId = nextAutoGenerateId; name.original = node; nextAutoGenerateId++; @@ -1497,6 +1505,13 @@ 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) @@ -1523,9 +1538,7 @@ namespace ts { } export function createStatement(expression: Expression) { - const node = createSynthesizedNode(SyntaxKind.ExpressionStatement); - node.expression = parenthesizeExpressionForExpressionStatement(expression); - return node; + return createExpressionStatement(parenthesizeExpressionForExpressionStatement(expression)); } export function updateStatement(node: ExpressionStatement, expression: Expression) { @@ -2887,6 +2900,15 @@ namespace ts { return setSyntheticTrailingComments(node, append(getSyntheticTrailingComments(node), { kind, pos: -1, end: -1, hasTrailingNewLine, text })); } + export function moveSyntheticComments(node: T, original: Node): T { + setSyntheticLeadingComments(node, getSyntheticLeadingComments(original)); + setSyntheticTrailingComments(node, getSyntheticTrailingComments(original)); + const emit = getOrCreateEmitNode(original); + emit.leadingComments = undefined; + emit.trailingComments = undefined; + return node; + } + /** * Gets the constant value to emit for an expression. */ @@ -4240,6 +4262,7 @@ namespace ts { switch (member.kind) { case SyntaxKind.TypeQuery: case SyntaxKind.TypeOperator: + case SyntaxKind.InferType: return createParenthesizedType(member); } return parenthesizeElementTypeMember(member); diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 8bb65e57616..510fc096297 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1012,8 +1012,10 @@ namespace ts { } else { const jsPath = tryReadPackageJsonFields(/*readTypes*/ false, packageJsonContent, nodeModuleDirectory, state); - if (typeof jsPath === "string") { - subModuleName = removeExtension(removeExtension(jsPath.substring(nodeModuleDirectory.length + 1), Extension.Js), Extension.Jsx) + Extension.Dts; + if (typeof jsPath === "string" && jsPath.length > nodeModuleDirectory.length) { + const potentialSubModule = jsPath.substring(nodeModuleDirectory.length + 1); + subModuleName = (forEach(supportedJavascriptExtensions, extension => + tryRemoveExtension(potentialSubModule, extension)) || potentialSubModule) + Extension.Dts; } else { subModuleName = "index.d.ts"; @@ -1047,9 +1049,18 @@ namespace ts { } function loadModuleFromPackageJson(jsonContent: PackageJsonPathFields, extensions: Extensions, candidate: string, failedLookupLocations: Push, state: ModuleResolutionState): PathAndExtension | undefined { - const file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript && extensions !== Extensions.Json, jsonContent, candidate, state); + let file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript && extensions !== Extensions.Json, jsonContent, candidate, state); if (!file) { - return undefined; + if (extensions === Extensions.TypeScript) { + // When resolving typescript modules, try resolving using main field as well + file = tryReadPackageJsonFields(/*readTypes*/ false, jsonContent, candidate, state); + if (!file) { + return undefined; + } + } + else { + return undefined; + } } const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(file), state.host); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ad3f80710db..3a7adbc2609 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -489,6 +489,15 @@ namespace ts { return visitNode(cbNode, (node).fullName) || visitNode(cbNode, (node).typeExpression); } + case SyntaxKind.JSDocCallbackTag: + return visitNode(cbNode, (node as JSDocCallbackTag).fullName) || + visitNode(cbNode, (node as JSDocCallbackTag).typeExpression); + 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); case SyntaxKind.JSDocTypeLiteral: if ((node as JSDocTypeLiteral).jsDocPropertyTags) { for (const tag of (node as JSDocTypeLiteral).jsDocPropertyTags) { @@ -2436,20 +2445,24 @@ namespace ts { return finishNode(node); } + /** + * @returns If return type parsing succeeds + */ function fillSignature( returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, flags: SignatureFlags, - signature: SignatureDeclaration): void { + signature: SignatureDeclaration): boolean { if (!(flags & SignatureFlags.JSDoc)) { signature.typeParameters = parseTypeParameters(); } signature.parameters = parseParameterList(flags); - signature.type = parseReturnType(returnToken, !!(flags & SignatureFlags.Type)); + if (shouldParseReturnType(returnToken, !!(flags & SignatureFlags.Type))) { + signature.type = parseTypeOrTypePredicate(); + return signature.type !== undefined; + } + return true; } - function parseReturnType(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, isType: boolean): TypeNode | undefined { - return shouldParseReturnType(returnToken, isType) ? parseTypeOrTypePredicate() : undefined; - } function shouldParseReturnType(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, isType: boolean): boolean { if (returnToken === SyntaxKind.EqualsGreaterThanToken) { parseExpected(returnToken); @@ -2758,6 +2771,9 @@ namespace ts { const node = createNode(SyntaxKind.ParenthesizedType); parseExpected(SyntaxKind.OpenParenToken); node.type = parseType(); + if (!node.type) { + return undefined; + } parseExpected(SyntaxKind.CloseParenToken); return finishNode(node); } @@ -2767,7 +2783,12 @@ namespace ts { if (kind === SyntaxKind.ConstructorType) { parseExpected(SyntaxKind.NewKeyword); } - fillSignature(SyntaxKind.EqualsGreaterThanToken, SignatureFlags.Type, node); + if (!fillSignature(SyntaxKind.EqualsGreaterThanToken, SignatureFlags.Type | (sourceFile.languageVariant === LanguageVariant.JSX ? SignatureFlags.RequireCompleteParameterList : 0), node)) { + return undefined; + } + if (!node.parameters) { + return undefined; + } return finishNode(node); } @@ -3598,7 +3619,9 @@ namespace ts { // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(SyntaxKind.ColonToken, isAsync | (allowAmbiguity ? SignatureFlags.None : SignatureFlags.RequireCompleteParameterList), node); + if (!fillSignature(SyntaxKind.ColonToken, isAsync | (allowAmbiguity ? SignatureFlags.None : SignatureFlags.RequireCompleteParameterList), node)) { + return undefined; + } // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { @@ -6317,8 +6340,9 @@ namespace ts { } const enum PropertyLikeParse { - Property, - Parameter, + Property = 1 << 0, + Parameter = 1 << 1, + CallbackParameter = 1 << 2, } export function parseJSDocCommentWorker(start: number, length: number): JSDoc { @@ -6372,7 +6396,7 @@ namespace ts { case SyntaxKind.AtToken: if (state === JSDocState.BeginningOfLine || state === JSDocState.SawAsterisk) { removeTrailingNewlines(comments); - parseTag(indent); + addTag(parseTag(indent)); // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` @@ -6457,7 +6481,25 @@ namespace ts { return finishNode(result, end); } + function isNextNonwhitespaceTokenEndOfFile(): boolean { + // We must use infinite lookahead, as there could be any number of newlines :( + while (true) { + nextJSDocToken(); + if (token() === SyntaxKind.EndOfFileToken) { + return true; + } + if (!(token() === SyntaxKind.WhitespaceTrivia || token() === SyntaxKind.NewLineTrivia)) { + return false; + } + } + } + function skipWhitespace(): void { + if (token() === SyntaxKind.WhitespaceTrivia || token() === SyntaxKind.NewLineTrivia) { + if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { + return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range + } + } while (token() === SyntaxKind.WhitespaceTrivia || token() === SyntaxKind.NewLineTrivia) { nextJSDocToken(); } @@ -6489,8 +6531,7 @@ namespace ts { case "arg": case "argument": case "param": - addTag(parseParameterOrPropertyTag(atToken, tagName, PropertyLikeParse.Parameter, indent)); - return; + return parseParameterOrPropertyTag(atToken, tagName, PropertyLikeParse.Parameter, indent); case "return": case "returns": tag = parseReturnTag(atToken, tagName); @@ -6502,7 +6543,10 @@ namespace ts { tag = parseTypeTag(atToken, tagName); break; case "typedef": - tag = parseTypedefTag(atToken, tagName); + tag = parseTypedefTag(atToken, tagName, indent); + break; + case "callback": + tag = parseCallbackTag(atToken, tagName, indent); break; default: tag = parseUnknownTag(atToken, tagName); @@ -6517,8 +6561,11 @@ namespace ts { // a badly malformed tag should not be added to the list of tags return; } - tag.comment = parseTagComments(indent + tag.end - tag.pos); - addTag(tag); + if (!tag.comment) { + // some tags, like typedef and callback, have already parsed their comments earlier + tag.comment = parseTagComments(indent + tag.end - tag.pos); + } + return tag; } function parseTagComments(indent: number): string | undefined { @@ -6591,6 +6638,9 @@ namespace ts { } function addTag(tag: JSDocTag): void { + if (!tag) { + return; + } if (!tags) { tags = [tag]; tagsPos = tag.pos; @@ -6651,9 +6701,9 @@ namespace ts { typeExpression = tryParseTypeExpression(); } - const result = target === PropertyLikeParse.Parameter ? - createNode(SyntaxKind.JSDocParameterTag, atToken.pos) : - createNode(SyntaxKind.JSDocPropertyTag, atToken.pos); + const result = target === PropertyLikeParse.Property ? + createNode(SyntaxKind.JSDocPropertyTag, atToken.pos) : + createNode(SyntaxKind.JSDocParameterTag, atToken.pos); let comment: string | undefined; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); const nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target); @@ -6757,29 +6807,20 @@ namespace ts { return finishNode(tag); } - function parseTypedefTag(atToken: AtToken, tagName: Identifier): JSDocTypedefTag { + function parseTypedefTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocTypedefTag { const typeExpression = tryParseTypeExpression(); skipWhitespace(); const typedefTag = createNode(SyntaxKind.JSDocTypedefTag, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; - typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); - if (typedefTag.fullName) { - let rightNode = typedefTag.fullName; - while (true) { - if (rightNode.kind === SyntaxKind.Identifier || !rightNode.body) { - // if node is identifier - use it as name - // otherwise use name of the rightmost part that we were able to parse - typedefTag.name = rightNode.kind === SyntaxKind.Identifier ? rightNode : rightNode.name; - break; - } - rightNode = rightNode.body; - } - } + typedefTag.fullName = parseJSDocTypeNameWithNamespace(); + typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); skipWhitespace(); + typedefTag.comment = parseTagComments(indent); typedefTag.typeExpression = typeExpression; + let end: number; if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { let child: JSDocTypeTag | JSDocPropertyTag | false; let jsdocTypeLiteral: JSDocTypeLiteral; @@ -6808,27 +6849,75 @@ namespace ts { typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : finishNode(jsdocTypeLiteral); + end = typedefTag.typeExpression.end; } } - return finishNode(typedefTag); + // Only include the characters between the name end and the next token if a comment was actually parsed out - otherwise it's just whitespace + return finishNode(typedefTag, end || typedefTag.comment !== undefined ? scanner.getStartPos() : (typedefTag.fullName || typedefTag.typeExpression || typedefTag.tagName).end); + } - function parseJSDocTypeNameWithNamespace(flags: NodeFlags) { - const pos = scanner.getTokenPos(); - const typeNameOrNamespaceName = parseJSDocIdentifierName(); + function parseJSDocTypeNameWithNamespace(nested?: boolean) { + const pos = scanner.getTokenPos(); + const typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (typeNameOrNamespaceName && parseOptional(SyntaxKind.DotToken)) { - const jsDocNamespaceNode = createNode(SyntaxKind.ModuleDeclaration, pos); - jsDocNamespaceNode.flags |= flags; - jsDocNamespaceNode.name = typeNameOrNamespaceName; - jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(NodeFlags.NestedNamespace); - return finishNode(jsDocNamespaceNode); + if (typeNameOrNamespaceName && parseOptional(SyntaxKind.DotToken)) { + const jsDocNamespaceNode = createNode(SyntaxKind.ModuleDeclaration, pos); + if (nested) { + jsDocNamespaceNode.flags |= NodeFlags.NestedNamespace; } + jsDocNamespaceNode.name = typeNameOrNamespaceName; + jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(/*nested*/ true); + return finishNode(jsDocNamespaceNode); + } - if (typeNameOrNamespaceName && flags & NodeFlags.NestedNamespace) { - typeNameOrNamespaceName.isInJSDocNamespace = true; + if (typeNameOrNamespaceName && nested) { + typeNameOrNamespaceName.isInJSDocNamespace = true; + } + return typeNameOrNamespaceName; + } + + function parseCallbackTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocCallbackTag { + const callbackTag = createNode(SyntaxKind.JSDocCallbackTag, atToken.pos) as JSDocCallbackTag; + callbackTag.atToken = atToken; + callbackTag.tagName = tagName; + callbackTag.fullName = parseJSDocTypeNameWithNamespace(); + callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); + skipWhitespace(); + callbackTag.comment = parseTagComments(indent); + + let child: JSDocParameterTag | false; + const start = scanner.getStartPos(); + const jsdocSignature = createNode(SyntaxKind.JSDocSignature, start) as JSDocSignature; + jsdocSignature.parameters = []; + while (child = tryParse(() => parseChildParameterOrPropertyTag(PropertyLikeParse.CallbackParameter) as JSDocParameterTag)) { + jsdocSignature.parameters = append(jsdocSignature.parameters as MutableNodeArray, child); + } + const returnTag = tryParse(() => { + if (token() === SyntaxKind.AtToken) { + nextJSDocToken(); + const tag = parseTag(indent); + if (tag && tag.kind === SyntaxKind.JSDocReturnTag) { + return tag as JSDocReturnTag; + } + } + }); + if (returnTag) { + jsdocSignature.type = returnTag; + } + callbackTag.typeExpression = finishNode(jsdocSignature); + return finishNode(callbackTag); + } + + function getJSDocTypeAliasName(fullName: JSDocNamespaceBody | undefined) { + if (fullName) { + let rightNode = fullName; + while (true) { + if (ts.isIdentifier(rightNode) || !rightNode.body) { + return ts.isIdentifier(rightNode) ? rightNode : rightNode.name; + } + rightNode = rightNode.body; } - return typeNameOrNamespaceName; } } @@ -6858,6 +6947,7 @@ namespace ts { if (canParseTag) { const child = tryParseChildTag(target); if (child && child.kind === SyntaxKind.JSDocParameterTag && + target !== PropertyLikeParse.CallbackParameter && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -6906,12 +6996,12 @@ namespace ts { case "arg": case "argument": case "param": - t = PropertyLikeParse.Parameter; + t = PropertyLikeParse.Parameter | PropertyLikeParse.CallbackParameter; break; default: return false; } - if (target !== t) { + if (!(target & t)) { return false; } const tag = parseParameterOrPropertyTag(atToken, tagName, target, /*indent*/ undefined); @@ -7006,7 +7096,7 @@ namespace ts { const pos = scanner.getTokenPos(); const end = scanner.getTextPos(); const result = createNode(SyntaxKind.Identifier, pos); - result.escapedText = escapeLeadingUnderscores(content.substring(pos, end)); + result.escapedText = escapeLeadingUnderscores(scanner.getTokenText()); finishNode(result, end); nextJSDocToken(); diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 9e0f3712ab9..dea5463b2ff 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -6,6 +6,7 @@ namespace ts { finishRecordingFilesWithChangedResolutions(): Path[]; resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined): ResolvedModuleFull[]; + getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations; resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; invalidateResolutionOfFile(filePath: Path): void; @@ -73,7 +74,7 @@ namespace ts { export const maxNumberOfFilesToIterateForInvalidation = 256; type GetResolutionWithResolvedFileName = - (resolution: T) => R; + (resolution: T) => R | undefined; export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootDirForResolution: string, logChangesWhenResolvingModule: boolean): ResolutionCache { let filesWithChangedSetOfUnresolvedImports: Path[] | undefined; @@ -124,6 +125,7 @@ namespace ts { startCachingPerDirectoryResolution: clearPerDirectoryResolutions, finishCachingPerDirectoryResolution, resolveModuleNames, + getResolvedModuleWithFailedLookupLocationsFromCache, resolveTypeReferenceDirectives, removeResolutionsOfFile, invalidateResolutionOfFile, @@ -320,7 +322,7 @@ namespace ts { } function resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[] { - return resolveNamesWithLocalCache( + return resolveNamesWithLocalCache( typeDirectiveNames, containingFile, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, @@ -329,7 +331,7 @@ namespace ts { } function resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined): ResolvedModuleFull[] { - return resolveNamesWithLocalCache( + return resolveNamesWithLocalCache( moduleNames, containingFile, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, @@ -337,6 +339,11 @@ namespace ts { ); } + function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined { + const cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); + return cache && cache.get(moduleName); + } + function isNodeModulesDirectory(dirPath: Path) { return endsWith(dirPath, "/node_modules"); } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index f2a01d22c24..1f0c097d22a 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1928,13 +1928,11 @@ namespace ts { } function scanJSDocToken(): JsDocSyntaxKind { + startPos = tokenPos = pos; if (pos >= end) { return token = SyntaxKind.EndOfFileToken; } - startPos = pos; - tokenPos = pos; - const ch = text.charCodeAt(pos); pos++; switch (ch) { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 688400fc6d5..05620afadfc 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -448,10 +448,11 @@ namespace ts { readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; getModifiedTime?(path: string): Date; /** - * This should be cryptographically secure. * A good implementation is node.js' `crypto.createHash`. (https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) */ createHash?(data: string): string; + /** This must be cryptographically secure. Only implement this method using `crypto.createHash("sha256")`. */ + createSHA256Hash?(data: string): string; getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; @@ -527,7 +528,7 @@ namespace ts { const _path = require("path"); const _os = require("os"); // crypto can be absent on reduced node installations - let _crypto: any; + let _crypto: typeof import("crypto"); try { _crypto = require("crypto"); } @@ -590,6 +591,7 @@ namespace ts { readDirectory, getModifiedTime, createHash: _crypto ? createMD5HashUsingNativeCrypto : generateDjb2Hash, + createSHA256Hash: _crypto ? createSHA256Hash : undefined, getMemoryUsage() { if (global.gc) { global.gc(); @@ -1072,11 +1074,17 @@ namespace ts { return `${chars.reduce((prev, curr) => ((prev << 5) + prev) + curr, 5381)}`; } - function createMD5HashUsingNativeCrypto(data: string) { + function createMD5HashUsingNativeCrypto(data: string): string { const hash = _crypto.createHash("md5"); hash.update(data); return hash.digest("hex"); } + + function createSHA256Hash(data: string): string { + const hash = _crypto.createHash("sha256"); + hash.update(data); + return hash.digest("hex"); + } } function getChakraSystem(): System { diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 0a7cf397ddd..346f1343fab 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -9,7 +9,13 @@ namespace ts { return result.diagnostics; } - const declarationEmitNodeBuilderFlags = NodeBuilderFlags.MultilineObjectLiterals | TypeFormatFlags.WriteClassExpressionAsTypeLiteral | NodeBuilderFlags.UseTypeOfFunction | NodeBuilderFlags.UseStructuralFallback | NodeBuilderFlags.AllowEmptyTuple; + const declarationEmitNodeBuilderFlags = + NodeBuilderFlags.MultilineObjectLiterals | + TypeFormatFlags.WriteClassExpressionAsTypeLiteral | + NodeBuilderFlags.UseTypeOfFunction | + NodeBuilderFlags.UseStructuralFallback | + NodeBuilderFlags.AllowEmptyTuple | + NodeBuilderFlags.GenerateNamesForShadowedTypeParams; /** * Transforms a ts file into a .d.ts file @@ -28,23 +34,26 @@ namespace ts { let enclosingDeclaration: Node; let necessaryTypeRefernces: Map; let lateMarkedStatements: LateVisibilityPaintedStatement[]; - let lateStatementReplacementMap: Map; + let lateStatementReplacementMap: Map>; let suppressNewDiagnosticContexts: boolean; + const host = context.getEmitHost(); const symbolTracker: SymbolTracker = { trackSymbol, reportInaccessibleThisError, reportInaccessibleUniqueSymbolError, - reportPrivateInBaseOfClassExpression + reportPrivateInBaseOfClassExpression, + moduleResolverHost: host, + trackReferencedAmbientModule, }; let errorNameNode: DeclarationName | undefined; let currentSourceFile: SourceFile; + let refs: Map; const resolver = context.getEmitResolver(); const options = context.getCompilerOptions(); const newLine = getNewLineCharacter(options); const { noResolve, stripInternal } = options; - const host = context.getEmitHost(); return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives: string[]): void { @@ -57,6 +66,11 @@ namespace ts { } } + function trackReferencedAmbientModule(node: ModuleDeclaration) { + const container = getSourceFileOfNode(node); + refs.set("" + getOriginalNodeId(container), container); + } + function handleSymbolAccessibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) { if (symbolAccessibilityResult.accessibility === SymbolAccessibility.Accessible) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info @@ -95,6 +109,7 @@ namespace ts { } function trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) { + if (symbol.flags & SymbolFlags.TypeParameter) return; handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); } @@ -155,13 +170,13 @@ namespace ts { [], [createModifier(SyntaxKind.DeclareKeyword)], createLiteral(getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), - createModuleBlock(setTextRange(createNodeArray(filterCandidateImports(statements)), sourceFile.statements)) + createModuleBlock(setTextRange(createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)) )], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false); return newFile; } needsDeclare = true; const updated = visitNodes(sourceFile.statements, visitDeclarationStatements); - return updateSourceFileNode(sourceFile, filterCandidateImports(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false); + return updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false); } ), mapDefined(node.prepends, prepend => { if (prepend.kind === SyntaxKind.InputFiles) { @@ -190,13 +205,13 @@ namespace ts { lateMarkedStatements = undefined; lateStatementReplacementMap = createMap(); necessaryTypeRefernces = undefined; - const refs = collectReferences(currentSourceFile, createMap()); + refs = collectReferences(currentSourceFile, createMap()); const references: FileReference[] = []; const outputFilePath = getDirectoryPath(normalizeSlashes(getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); const referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - refs.forEach(referenceVisitor); const statements = visitNodes(node.statements, visitDeclarationStatements); - let combinedStatements = setTextRange(createNodeArray(filterCandidateImports(statements)), node.statements); + let combinedStatements = setTextRange(createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); const emittedImports = filter(combinedStatements, isAnyImportSyntax); if (isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { combinedStatements = setTextRange(createNodeArray([...combinedStatements, createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined)]), combinedStatements); @@ -210,16 +225,18 @@ namespace ts { function getFileReferenceForTypeName(typeName: string): FileReference | undefined { // Elide type references for which we have imports - for (const importStatement of emittedImports) { - if (isImportEqualsDeclaration(importStatement) && isExternalModuleReference(importStatement.moduleReference)) { - const expr = importStatement.moduleReference.expression; - if (isStringLiteralLike(expr) && expr.text === typeName) { + if (emittedImports) { + for (const importStatement of emittedImports) { + if (isImportEqualsDeclaration(importStatement) && isExternalModuleReference(importStatement.moduleReference)) { + const expr = importStatement.moduleReference.expression; + if (isStringLiteralLike(expr) && expr.text === typeName) { + return undefined; + } + } + else if (isImportDeclaration(importStatement) && isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) { return undefined; } } - else if (isImportDeclaration(importStatement) && isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) { - return undefined; - } } return { fileName: typeName, pos: -1, end: -1 }; } @@ -258,7 +275,7 @@ namespace ts { forEach(sourceFile.referencedFiles, f => { const elem = tryResolveScriptReference(host, sourceFile, f); if (elem) { - ret.set("" + getNodeId(elem), elem); + ret.set("" + getOriginalNodeId(elem), elem); } }); return ret; @@ -538,7 +555,7 @@ namespace ts { // Nothing visible } - function filterCandidateImports(statements: NodeArray): NodeArray { + function transformAndReplaceLatePaintedStatements(statements: NodeArray): NodeArray { // This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during // error handling which must now be included in the output and themselves checked for errors. // For example: @@ -553,65 +570,50 @@ namespace ts { // In such a scenario, only Q and D are initially visible, but we don't consider imports as private names - instead we say they if they are referenced they must // be recorded. So while checking D's visibility we mark C as visible, then we must check C which in turn marks B, completing the chain of // dependent imports and allowing a valid declaration file output. Today, this dependent alias marking only happens for internal import aliases. - const unconsideredStatements: LateVisibilityPaintedStatement[] = []; while (length(lateMarkedStatements)) { const i = lateMarkedStatements.shift(); - if ((isSourceFile(i.parent) ? i.parent : i.parent.parent) !== enclosingDeclaration) { // Filter to only declarations in the current scope - unconsideredStatements.push(i); - continue; - } if (!isLateVisibilityPaintedStatement(i)) { - return Debug.fail(`Late replaced statement was foudn which is not handled by the declaration transformer!: ${(ts as any).SyntaxKind ? (ts as any).SyntaxKind[(i as any).kind] : (i as any).kind}`); - } - switch (i.kind) { - case SyntaxKind.ImportEqualsDeclaration: { - const result = transformImportEqualsDeclaration(i); - lateStatementReplacementMap.set("" + getNodeId(i), result); - break; - } - case SyntaxKind.ImportDeclaration: { - const result = transformImportDeclaration(i); - lateStatementReplacementMap.set("" + getNodeId(i), result); - break; - } - case SyntaxKind.VariableStatement: { - const result = transformVariableStatement(i, /*privateDeclaration*/ true); // Transform the statement (potentially again, possibly revealing more sub-nodes) - lateStatementReplacementMap.set("" + getNodeId(i), result); - break; - } - default: Debug.assertNever(i, "Unhandled late painted statement!"); + return Debug.fail(`Late replaced statement was found which is not handled by the declaration transformer!: ${(ts as any).SyntaxKind ? (ts as any).SyntaxKind[(i as any).kind] : (i as any).kind}`); } + const result = transformTopLevelDeclaration(i, /*privateDeclaration*/ true); + lateStatementReplacementMap.set("" + getOriginalNodeId(i), result); } - // Filtering available imports is the last thing done within a scope, so the possible set becomes those which could not - // be considered in the child scope - lateMarkedStatements = unconsideredStatements; // And lastly, we need to get the final form of all those indetermine import declarations from before and add them to the output list // (and remove them from the set to examine for outter declarations) return visitNodes(statements, visitLateVisibilityMarkedStatements); - } - function visitLateVisibilityMarkedStatements(statement: Statement) { - if (isLateVisibilityPaintedStatement(statement)) { - const key = "" + getNodeId(statement); - if (lateStatementReplacementMap.has(key)) { - const result = lateStatementReplacementMap.get(key); - lateStatementReplacementMap.delete(key); - if (result && isSourceFile(statement.parent) && !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasModifier(result, ModifierFlags.Export)) { - // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier - needsScopeFixMarker = true; + function visitLateVisibilityMarkedStatements(statement: Statement) { + if (isLateVisibilityPaintedStatement(statement)) { + const key = "" + getOriginalNodeId(statement); + if (lateStatementReplacementMap.has(key)) { + const result = lateStatementReplacementMap.get(key); + lateStatementReplacementMap.delete(key); + if (result && isSourceFile(statement.parent)) { + if (isArray(result) ? some(result, needsScopeMarker) : needsScopeMarker(result)) { + // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier + needsScopeFixMarker = true; + } + if (isArray(result) ? some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result)) { + resultHasExternalModuleIndicator = true; + } + } + return result; } - return result; } - else { - return getParseTreeNode(statement) ? undefined : statement; - } - } - else { return statement; } } + function isExternalModuleIndicator(result: LateVisibilityPaintedStatement) { + // Exported top-level member indicates moduleness + return isAnyImportOrReExport(result) || isExportAssignment(result) || hasModifier(result, ModifierFlags.Export); + } + + function needsScopeMarker(result: LateVisibilityPaintedStatement) { + return !isAnyImportOrReExport(result) && !isExportAssignment(result) && !hasModifier(result, ModifierFlags.Export) && !isAmbientModule(result); + } + function visitDeclarationSubtree(input: Node): VisitResult { if (shouldStripInternal(input)) return; if (isDeclaration(input)) { @@ -866,13 +868,22 @@ namespace ts { return [statement, updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } - case SyntaxKind.ImportEqualsDeclaration: + } + + const result = transformTopLevelDeclaration(input); + // Don't actually transform yet; just leave as original node - will be elided/swapped by late pass + lateStatementReplacementMap.set("" + getOriginalNodeId(input), result); + return input; + } + + function transformTopLevelDeclaration(input: LateVisibilityPaintedStatement, isPrivate?: boolean) { + if (shouldStripInternal(input)) return; + switch (input.kind) { + case SyntaxKind.ImportEqualsDeclaration: { + return transformImportEqualsDeclaration(input); + } case SyntaxKind.ImportDeclaration: { - // Different parts of the import may be marked visible at different times (via visibility checking), so we defer our first look until later - // to reduce the likelihood we need to rewrite it - lateMarkedStatements = lateMarkedStatements || []; - pushIfUnique(lateMarkedStatements, input); - return input; + return transformImportDeclaration(input); } } if (isDeclaration(input) && isDeclarationAndNotVisible(input)) return; @@ -885,21 +896,20 @@ namespace ts { previousEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = input as Declaration; } - let previousNeedsDeclare: typeof needsDeclare; const canProdiceDiagnostic = canProduceDiagnostics(input); const oldDiag = getSymbolAccessibilityDiagnostic; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(input as DeclarationDiagnosticProducing); } - let oldPossibleImports: typeof lateMarkedStatements; + const previousNeedsDeclare = needsDeclare; switch (input.kind) { case SyntaxKind.TypeAliasDeclaration: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(updateTypeAliasDeclaration( input, /*decorators*/ undefined, - ensureModifiers(input), + ensureModifiers(input, isPrivate), input.name, visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration), visitNode(input.type, visitDeclarationSubtree, isTypeNode) @@ -908,7 +918,7 @@ namespace ts { return cleanup(updateInterfaceDeclaration( input, /*decorators*/ undefined, - ensureModifiers(input), + ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), @@ -920,7 +930,7 @@ namespace ts { return cleanup(updateFunctionDeclaration( input, /*decorators*/ undefined, - ensureModifiers(input), + ensureModifiers(input, isPrivate), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), @@ -930,16 +940,13 @@ namespace ts { )); } case SyntaxKind.ModuleDeclaration: { - previousNeedsDeclare = needsDeclare; needsDeclare = false; - oldPossibleImports = lateMarkedStatements; - lateMarkedStatements = undefined; const inner = input.body; if (inner && inner.kind === SyntaxKind.ModuleBlock) { const statements = visitNodes(inner.statements, visitDeclarationStatements); - const body = updateModuleBlock(inner, filterCandidateImports(statements)); + const body = updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; - const mods = ensureModifiers(input); + const mods = ensureModifiers(input, isPrivate); return cleanup(updateModuleDeclaration( input, /*decorators*/ undefined, @@ -950,19 +957,24 @@ namespace ts { } else { needsDeclare = previousNeedsDeclare; - const mods = ensureModifiers(input); + const mods = ensureModifiers(input, isPrivate); needsDeclare = false; + visitNode(inner, visitDeclarationStatements); + // eagerly transform nested namespaces (the nesting doesn't need any elision or painting done) + const id = "" + getOriginalNodeId(inner); + const body = lateStatementReplacementMap.get(id); + lateStatementReplacementMap.delete(id); return cleanup(updateModuleDeclaration( input, /*decorators*/ undefined, mods, input.name, - visitNode(inner, visitDeclarationStatements) + body as ModuleBody )); } } case SyntaxKind.ClassDeclaration: { - const modifiers = createNodeArray(ensureModifiers(input)); + const modifiers = createNodeArray(ensureModifiers(input, isPrivate)); const typeParameters = ensureTypeParams(input, input.typeParameters); const ctor = getFirstConstructorWithBody(input); let parameterProperties: PropertyDeclaration[]; @@ -1055,12 +1067,10 @@ namespace ts { } } case SyntaxKind.VariableStatement: { - const result = transformVariableStatement(input); - lateStatementReplacementMap.set("" + getNodeId(input), result); // Don't actually elide yet; just leave as original node - will be elided/swapped by late pass - return cleanup(input); + return cleanup(transformVariableStatement(input, isPrivate)); } case SyntaxKind.EnumDeclaration: { - return cleanup(updateEnumDeclaration(input, /*decorators*/ undefined, createNodeArray(ensureModifiers(input)), input.name, createNodeArray(mapDefined(input.members, m => { + return cleanup(updateEnumDeclaration(input, /*decorators*/ undefined, createNodeArray(ensureModifiers(input, isPrivate)), input.name, createNodeArray(mapDefined(input.members, m => { if (shouldStripInternal(m)) return; // Rewrite enum values to their constants, if available const constValue = resolver.getConstantValue(m); @@ -1068,31 +1078,23 @@ namespace ts { })))); } } - // Anything left unhandled is an error, so this should be unreachable return Debug.assertNever(input, `Unhandled top-level node in declaration emit: ${(ts as any).SyntaxKind[(input as any).kind]}`); - function cleanup(returnValue: T | undefined): T { + function cleanup(node: T | undefined): T { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; } - if (input.kind === SyntaxKind.ModuleDeclaration) { - needsDeclare = previousNeedsDeclare; - lateMarkedStatements = concatenate(oldPossibleImports, lateMarkedStatements); - } if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (returnValue && (!isLateVisibilityPaintedStatement(input) || lateStatementReplacementMap.get("" + getNodeId(input)))) { - if (!resultHasExternalModuleIndicator && hasModifier(input, ModifierFlags.Export) && isSourceFile(input.parent)) { - // Exported top-level member indicates moduleness - resultHasExternalModuleIndicator = true; - } + if (input.kind === SyntaxKind.ModuleDeclaration) { + needsDeclare = previousNeedsDeclare; } - if (returnValue === input) { - return returnValue; + if (node as Node === input) { + return node; } - return returnValue && setOriginalNode(preserveJsDoc(returnValue, input), input); + return node && setOriginalNode(preserveJsDoc(node, input), input); } } @@ -1175,7 +1177,7 @@ namespace ts { } function ensureAccessor(node: AccessorDeclaration): PropertyDeclaration | undefined { - const accessors = getAllAccessorDeclarations((node.parent as ClassDeclaration).members, node); + const accessors = resolver.getAllAccessorDeclarations(node); if (node.kind !== accessors.firstAccessor.kind) { return; } @@ -1333,4 +1335,4 @@ namespace ts { } return false; } -} \ No newline at end of file +} diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 76a7219b758..7e356ca4a3a 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -529,7 +529,7 @@ namespace ts { createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList(taggedTemplateStringDeclarations))); } - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, HierarchyFacts.None, HierarchyFacts.None); return updateSourceFileNode( node, @@ -836,7 +836,7 @@ namespace ts { setEmitFlags(statement, EmitFlags.NoComments | EmitFlags.NoTokenSourceMaps); statements.push(statement); - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); const block = createBlock(setTextRange(createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); setEmitFlags(block, EmitFlags.NoComments); @@ -979,7 +979,7 @@ namespace ts { ); } - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); @@ -1885,6 +1885,7 @@ namespace ts { const expression = visitNode(body, visitor, isExpression); const returnStatement = createReturn(expression); setTextRange(returnStatement, body); + moveSyntheticComments(returnStatement, body); setEmitFlags(returnStatement, EmitFlags.NoTokenSourceMaps | EmitFlags.NoTrailingSourceMap | EmitFlags.NoTrailingComments); statements.push(returnStatement); @@ -1894,7 +1895,7 @@ namespace ts { } const lexicalEnvironment = context.endLexicalEnvironment(); - addRange(statements, lexicalEnvironment); + prependRange(statements, lexicalEnvironment); prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); @@ -2712,7 +2713,7 @@ namespace ts { if (loopOutParameters.length) { copyOutParameters(loopOutParameters, CopyDirection.ToOutParameter, statements); } - addRange(statements, lexicalEnvironment); + prependRange(statements, lexicalEnvironment); loopBody = createBlock(statements, /*multiline*/ true); } @@ -3309,10 +3310,12 @@ namespace ts { // expression, but we will restore them later to preserve comments and source maps. const body = cast(cast(skipOuterExpressions(node.expression), isArrowFunction).body, isBlock); - // The class statements are the statements generated by visiting the first statement of the + // The class statements are the statements generated by visiting the first statement with initializer of the // body (1), while all other statements are added to remainingStatements (2) - const classStatements = visitNodes(body.statements, visitor, isStatement, 0, 1); - const remainingStatements = visitNodes(body.statements, visitor, isStatement, 1, body.statements.length - 1); + const isVariableStatementWithInitializer = (stmt: Statement) => isVariableStatement(stmt) && !!firstOrUndefined(stmt.declarationList.declarations).initializer; + const bodyStatements = visitNodes(body.statements, visitor, isStatement); + const classStatements = filter(bodyStatements, isVariableStatementWithInitializer); + const remainingStatements = filter(bodyStatements, stmt => !isVariableStatementWithInitializer(stmt)); const varStatement = cast(firstOrUndefined(classStatements), isVariableStatement); // We know there is only one variable declaration here as we verified this in an @@ -3324,6 +3327,7 @@ namespace ts { // we see as an assignment, for example: // // (function () { + // var C_1; // var C = C_1 = (function () { // function C() { // } @@ -3332,7 +3336,6 @@ namespace ts { // }()); // C = C_1 = __decorate([dec], C); // return C; - // var C_1; // }()) // const aliasAssignment = tryCast(initializer, isAssignmentExpression); diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index c61809b64e0..0316c90b250 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -412,7 +412,7 @@ namespace ts { ) ); - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); const block = createBlock(statements, /*multiLine*/ true); setTextRange(block, node.body); @@ -443,7 +443,7 @@ namespace ts { const declarations = endLexicalEnvironment(); if (some(declarations)) { const block = convertToFunctionBody(expression); - result = updateBlock(block, setTextRange(createNodeArray(concatenate(block.statements, declarations)), block.statements)); + result = updateBlock(block, setTextRange(createNodeArray(concatenate(declarations, block.statements)), block.statements)); } else { result = expression; diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index eec1463433a..d054aaaf909 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -663,7 +663,7 @@ namespace ts { ) ); - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); const block = updateBlock(node.body, statements); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. @@ -692,11 +692,11 @@ namespace ts { statementOffset = addPrologue(statements, body.statements, /*ensureUseStrict*/ false, visitor); } addRange(statements, appendObjectRestAssignmentsIfNeeded(/*statements*/ undefined, node)); - const trailingStatements = endLexicalEnvironment(); - if (statementOffset > 0 || some(statements) || some(trailingStatements)) { + const leadingStatements = endLexicalEnvironment(); + if (statementOffset > 0 || some(statements) || some(leadingStatements)) { const block = convertToFunctionBody(body, /*multiLine*/ true); + prependRange(statements, leadingStatements); addRange(statements, block.statements.slice(statementOffset)); - addRange(statements, trailingStatements); return updateBlock(block, setTextRange(createNodeArray(statements), block.statements)); } return body; @@ -924,7 +924,7 @@ namespace ts { return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -956,7 +956,7 @@ namespace ts { var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } };` }; @@ -979,8 +979,10 @@ namespace ts { text: ` var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } };` }; diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index a1d610280c0..04d131b20a9 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -586,7 +586,7 @@ namespace ts { transformAndEmitStatements(body.statements, statementOffset); const buildResult = build(); - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); statements.push(createReturn(buildResult)); // Restore previous generator state diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 503d662ad58..dbc29215e40 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); - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); const updated = updateSourceFileNode(node, setTextRange(createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { @@ -426,7 +426,7 @@ namespace ts { // End the lexical environment for the module body // and merge any new lexical declarations. - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); const body = createBlock(statements, /*multiLine*/ true); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 047b552415d..0e6f5afad18 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -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 - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); const exportStarFunction = addExportStarIfNeeded(statements); const moduleObject = createObjectLiteral([ diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 862b79dbf24..67c9ddfc788 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -669,7 +669,7 @@ namespace ts { setEmitFlags(statement, EmitFlags.NoComments | EmitFlags.NoTokenSourceMaps); statements.push(statement); - addRange(statements, context.endLexicalEnvironment()); + prependRange(statements, context.endLexicalEnvironment()); const iife = createImmediatelyInvokedArrowFunction(statements); setEmitFlags(iife, EmitFlags.TypeScriptClassWrapper); @@ -2534,6 +2534,11 @@ namespace ts { // we can safely elide the parentheses here, as a new synthetic // ParenthesizedExpression will be inserted if we remove parentheses too // aggressively. + // HOWEVER - if there are leading comments on the expression itself, to handle ASI + // correctly for return and throw, we must keep the parenthesis + if (length(getLeadingCommentRangesOfNode(expression, currentSourceFile))) { + return updateParen(node, expression); + } return createPartiallyEmittedExpression(expression, node); } @@ -2685,8 +2690,9 @@ namespace ts { const statements: Statement[] = []; startLexicalEnvironment(); - addRange(statements, map(node.members, transformEnumMember)); - addRange(statements, endLexicalEnvironment()); + const members = map(node.members, transformEnumMember); + prependRange(statements, endLexicalEnvironment()); + addRange(statements, members); currentNamespaceContainerName = savedCurrentNamespaceLocalName; return createBlock( @@ -3000,7 +3006,7 @@ namespace ts { statementsLocation = moveRangePos(moduleBlock.statements, -1); } - addRange(statements, endLexicalEnvironment()); + prependRange(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1ac84792152..19e526ba056 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -413,9 +413,11 @@ namespace ts { JSDocVariadicType, JSDocComment, JSDocTypeLiteral, + JSDocSignature, JSDocTag, JSDocAugmentsTag, JSDocClassTag, + JSDocCallbackTag, JSDocParameterTag, JSDocReturnTag, JSDocTypeTag, @@ -538,7 +540,7 @@ namespace ts { Abstract = 1 << 7, // Class/Method/ConstructSignature Async = 1 << 8, // Property/Method/Function Default = 1 << 9, // Function/Class (export default declaration) - Const = 1 << 11, // Variable declaration + Const = 1 << 11, // Const enum HasComputedFlags = 1 << 29, // Modifier flags have been computed AccessibilityModifier = Public | Private | Protected, @@ -2053,7 +2055,7 @@ namespace ts { export type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; + export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; @@ -2387,6 +2389,21 @@ namespace ts { typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; } + export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { + parent: JSDoc; + kind: SyntaxKind.JSDocCallbackTag; + fullName?: JSDocNamespaceDeclaration | Identifier; + name?: Identifier; + typeExpression: JSDocSignature; + } + + export interface JSDocSignature extends JSDocType, Declaration { + kind: SyntaxKind.JSDocSignature; + typeParameters?: ReadonlyArray; + parameters: ReadonlyArray; + type: JSDocReturnTag | undefined; + } + export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { parent: JSDoc; name: EntityName; @@ -3074,9 +3091,9 @@ namespace ts { // Options NoTruncation = 1 << 0, // Don't truncate result WriteArrayAsGenericType = 1 << 1, // Write Array instead T[] - // empty space + GenerateNamesForShadowedTypeParams = 1 << 2, // When a type parameter T is shadowing another T, generate a name for it so it can still be referenced UseStructuralFallback = 1 << 3, // When an alias cannot be named by its symbol, rather than report an error, fallback to a structural printout if possible - // empty space + ForbidIndexedAccessSymbolReferences = 1 << 4, // Forbid references like `I["a"]["b"]` - print `typeof I.a.b` instead WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type) UseOnlyExternalAliasing = 1 << 7, // Only use external aliases for a symbol @@ -3252,18 +3269,31 @@ namespace ts { /* @internal */ export type AnyImportOrReExport = AnyImportSyntax | ExportDeclaration; + /* @internal */ + export interface ValidImportTypeNode extends ImportTypeNode { + argument: LiteralTypeNode & { literal: StringLiteral }; + } + /* @internal */ export type AnyValidImportOrReExport = | (ImportDeclaration | ExportDeclaration) & { moduleSpecifier: StringLiteral } | ImportEqualsDeclaration & { moduleReference: ExternalModuleReference & { expression: StringLiteral } } | RequireOrImportCall - | ImportTypeNode & { argument: LiteralType }; + | ValidImportTypeNode; /* @internal */ export type RequireOrImportCall = CallExpression & { arguments: [StringLiteralLike] }; /* @internal */ - export type LateVisibilityPaintedStatement = AnyImportSyntax | VariableStatement; + export type LateVisibilityPaintedStatement = + | AnyImportSyntax + | VariableStatement + | ClassDeclaration + | FunctionDeclaration + | ModuleDeclaration + | TypeAliasDeclaration + | InterfaceDeclaration + | EnumDeclaration; /* @internal */ export interface SymbolVisibilityResult { @@ -3278,6 +3308,14 @@ namespace ts { errorModuleName?: string; // If the symbol is not visible from module, module's name } + /* @internal */ + export interface AllAccessorDeclarations { + firstAccessor: AccessorDeclaration; + secondAccessor: AccessorDeclaration; + getAccessor: AccessorDeclaration; + setAccessor: AccessorDeclaration; + } + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ export enum TypeReferenceSerializationKind { @@ -3334,6 +3372,7 @@ namespace ts { getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; getJsxFactoryEntity(location?: Node): EntityName; + getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations; } export const enum SymbolFlags { @@ -3603,6 +3642,7 @@ namespace ts { flags?: NodeCheckFlags; // Set of flags specific to Node resolvedType?: Type; // Cached type of type node resolvedSignature?: Signature; // Cached signature of signature node or call expression + resolvedSignatures?: Map; // Cached signatures of jsx node resolvedSymbol?: Symbol; // Cached name resolution result resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result maybeTypePredicate?: boolean; // Cached check whether call expression might reference a type predicate @@ -3652,6 +3692,8 @@ namespace ts { ContainsAnyFunctionType = 1 << 26, // Type is or contains the anyFunctionType NonPrimitive = 1 << 27, // intrinsic object type /* @internal */ + UnionOfUnitTypes = 1 << 28, // Type is union of unit types + /* @internal */ GenericMappedType = 1 << 29, // Flag used by maybeTypeOfKind /* @internal */ @@ -3689,6 +3731,8 @@ namespace ts { Narrowable = Any | StructuredOrInstantiable | StringLike | NumberLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive, NotUnionOrUnit = Any | ESSymbol | Object | NonPrimitive, /* @internal */ + NotUnit = Any | String | Number | Boolean | Enum | ESSymbol | Void | Never | StructuredOrInstantiable, + /* @internal */ RequiresWidening = ContainsWideningType | ContainsObjectLiteral, /* @internal */ PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType, @@ -3951,6 +3995,7 @@ namespace ts { objectType: Type; indexType: Type; constraint?: Type; + simplified?: Type; } export type TypeVariable = TypeParameter | IndexedAccessType; @@ -4008,7 +4053,7 @@ namespace ts { } export interface Signature { - declaration?: SignatureDeclaration; // Originating declaration + declaration?: SignatureDeclaration | JSDocSignature; // Originating declaration typeParameters?: TypeParameter[]; // Type parameters (undefined if non-generic) parameters: Symbol[]; // Parameters /* @internal */ @@ -5217,6 +5262,13 @@ namespace ts { isAtStartOfLine(): boolean; } + /* @internal */ + export interface ModuleNameResolverHost { + getCanonicalFileName(f: string): string; + getCommonSourceDirectory(): string; + getCurrentDirectory(): string; + } + /** @deprecated See comment on SymbolWriter */ // Note: this has non-deprecated internal uses. export interface SymbolTracker { @@ -5227,6 +5279,10 @@ namespace ts { reportInaccessibleThisError?(): void; reportPrivateInBaseOfClassExpression?(propertyName: string): void; reportInaccessibleUniqueSymbolError?(): void; + /* @internal */ + moduleResolverHost?: ModuleNameResolverHost; + /* @internal */ + trackReferencedAmbientModule?(decl: ModuleDeclaration): void; } export interface TextSpan { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7afc862bba4..df19a8948c7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -520,6 +520,9 @@ namespace ts { case SyntaxKind.SetAccessor: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: + case SyntaxKind.JSDocCallbackTag: + case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JSDocSignature: return true; default: assertTypeIsNever(node); @@ -542,6 +545,12 @@ namespace ts { case SyntaxKind.ImportDeclaration: case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.VariableStatement: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.EnumDeclaration: return true; default: return false; @@ -555,14 +564,7 @@ namespace ts { // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. export function getEnclosingBlockScopeContainer(node: Node): Node { - let current = node.parent; - while (current) { - if (isBlockScope(current, current.parent)) { - return current; - } - - current = current.parent; - } + return findAncestor(node.parent, current => isBlockScope(current, current.parent)); } // Return display name of an identifier @@ -1722,6 +1724,10 @@ namespace ts { } export function importFromModuleSpecifier(node: StringLiteralLike): AnyValidImportOrReExport { + return tryGetImportFromModuleSpecifier(node) || Debug.fail(Debug.showSyntaxKind(node.parent)); + } + + export function tryGetImportFromModuleSpecifier(node: StringLiteralLike): AnyValidImportOrReExport | undefined { switch (node.parent.kind) { case SyntaxKind.ImportDeclaration: case SyntaxKind.ExportDeclaration: @@ -1731,9 +1737,10 @@ namespace ts { case SyntaxKind.CallExpression: return node.parent as AnyValidImportOrReExport; case SyntaxKind.LiteralType: - return cast(node.parent.parent, isImportTypeNode) as ImportTypeNode & { argument: LiteralType }; + Debug.assert(isStringLiteral(node)); + return tryCast(node.parent.parent, isImportTypeNode) as ValidImportTypeNode | undefined; default: - return Debug.fail(Debug.showSyntaxKind(node.parent)); + return undefined; } } @@ -1792,6 +1799,14 @@ namespace ts { ((node as JSDocFunctionType).parameters[0].name as Identifier).escapedText === "new"; } + export function isJSDocTypeAlias(node: Node): node is JSDocTypedefTag | JSDocCallbackTag { + return node.kind === SyntaxKind.JSDocTypedefTag || node.kind === SyntaxKind.JSDocCallbackTag; + } + + export function isTypeAlias(node: Node): node is JSDocTypedefTag | JSDocCallbackTag | TypeAliasDeclaration { + return isJSDocTypeAlias(node) || isTypeAliasDeclaration(node); + } + function getSourceOfAssignment(node: Node): Node { return isExpressionStatement(node) && node.expression && isBinaryExpression(node.expression) && @@ -1815,6 +1830,8 @@ namespace ts { return v && v.initializer; case SyntaxKind.PropertyDeclaration: return (node as PropertyDeclaration).initializer; + case SyntaxKind.PropertyAssignment: + return (node as PropertyAssignment).initializer; } } @@ -1831,9 +1848,9 @@ namespace ts { (node as ModuleDeclaration).body; } - export function getJSDocCommentsAndTags(node: Node): ReadonlyArray { + export function getJSDocCommentsAndTags(hostNode: Node): ReadonlyArray { let result: (JSDoc | JSDocTag)[] | undefined; - getJSDocCommentsAndTagsWorker(node); + getJSDocCommentsAndTagsWorker(hostNode); return result || emptyArray; function getJSDocCommentsAndTagsWorker(node: Node): void { @@ -1848,8 +1865,7 @@ namespace ts { // * @returns {number} // */ // var x = function(name) { return name.length; } - if (parent.parent && - (getSingleVariableOfVariableStatement(parent.parent) === node || getSourceOfAssignment(parent.parent))) { + if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { getJSDocCommentsAndTagsWorker(parent.parent); } if (parent.parent && parent.parent.parent && @@ -1858,8 +1874,8 @@ namespace ts { getSourceOfDefaultedAssignment(parent.parent.parent))) { getJSDocCommentsAndTagsWorker(parent.parent.parent); } - if (isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) !== SpecialPropertyAssignmentKind.None || - isBinaryExpression(parent) && getSpecialPropertyAssignmentKind(parent) !== SpecialPropertyAssignmentKind.None || + if (isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.EqualsToken || + isBinaryExpression(parent) && parent.operatorToken.kind === SyntaxKind.EqualsToken || node.kind === SyntaxKind.PropertyAccessExpression && node.parent && node.parent.kind === SyntaxKind.ExpressionStatement) { getJSDocCommentsAndTagsWorker(parent); } @@ -1869,7 +1885,7 @@ namespace ts { result = addRange(result, getJSDocParameterTags(node as ParameterDeclaration)); } - if (isVariableLike(node) && hasInitializer(node) && hasJSDocNodes(node.initializer)) { + if (isVariableLike(node) && hasInitializer(node) && node.initializer !== hostNode && hasJSDocNodes(node.initializer)) { result = addRange(result, node.initializer.jsDoc); } @@ -1896,8 +1912,11 @@ namespace ts { return parameter && parameter.symbol; } - export function getHostSignatureFromJSDoc(node: JSDocParameterTag): SignatureDeclaration | undefined { - const host = getJSDocHost(node); + export function getHostSignatureFromJSDoc(node: Node): SignatureDeclaration | undefined { + return getHostSignatureFromJSDocHost(getJSDocHost(node)); + } + + export function getHostSignatureFromJSDocHost(host: HasJSDoc): SignatureDeclaration | undefined { const decl = getSourceOfDefaultedAssignment(host) || getSourceOfAssignment(host) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) || @@ -1907,18 +1926,8 @@ namespace ts { return decl && isFunctionLike(decl) ? decl : undefined; } - export function getJSDocHost(node: JSDocTag): HasJSDoc { - while (node.parent.kind === SyntaxKind.JSDocTypeLiteral) { - if (node.parent.parent.kind === SyntaxKind.JSDocTypedefTag) { - node = node.parent.parent as JSDocTypedefTag; - } - else { - // node.parent.parent is a type expression, child of a parameter type - node = node.parent.parent.parent as JSDocParameterTag; - } - } - Debug.assert(node.parent!.kind === SyntaxKind.JSDocComment); - return node.parent!.parent!; + export function getJSDocHost(node: Node): HasJSDoc { + return Debug.assertDefined(findAncestor(node.parent, isJSDoc)).parent; } export function getTypeParameterFromJsDoc(node: TypeParameterDeclaration & { parent: JSDocTemplateTag }): TypeParameterDeclaration | undefined { @@ -1927,13 +1936,14 @@ namespace ts { return find(typeParameters, p => p.name.escapedText === name); } - export function hasRestParameter(s: SignatureDeclaration): boolean { - const last = lastOrUndefined(s.parameters); + export function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean { + const last = lastOrUndefined(s.parameters); return last && isRestParameter(last); } - export function isRestParameter(node: ParameterDeclaration): boolean { - return node.dotDotDotToken !== undefined || node.type && node.type.kind === SyntaxKind.JSDocVariadicType; + export function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): boolean { + const type = isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; + return (node as ParameterDeclaration).dotDotDotToken !== undefined || type && type.kind === SyntaxKind.JSDocVariadicType; } export const enum AssignmentKind { @@ -2864,11 +2874,11 @@ namespace ts { }; } - export function getResolvedExternalModuleName(host: EmitHost, file: SourceFile): string { - return file.moduleName || getExternalModuleNameFromPath(host, file.fileName); + export function getResolvedExternalModuleName(host: ModuleNameResolverHost, file: SourceFile, referenceFile?: SourceFile): string { + return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } - export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): string { + export function getExternalModuleNameFromDeclaration(host: ModuleNameResolverHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode): string { const file = resolver.getExternalModuleFileFromDeclaration(declaration); if (!file || file.isDeclarationFile) { return undefined; @@ -2879,12 +2889,13 @@ namespace ts { /** * Resolves a local path to a path which is absolute to the base of the emit */ - export function getExternalModuleNameFromPath(host: EmitHost, fileName: string): string { + export function getExternalModuleNameFromPath(host: ModuleNameResolverHost, fileName: string, referencePath?: string): string { const getCanonicalFileName = (f: string) => host.getCanonicalFileName(f); - const dir = toPath(host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + const dir = toPath(referencePath ? getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); const filePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); const relativePath = getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - return removeFileExtension(relativePath); + const extensionless = removeFileExtension(relativePath); + return referencePath ? ensurePathIsNonModuleName(extensionless) : extensionless; } export function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string) { @@ -2987,8 +2998,9 @@ namespace ts { return parameter && parameter.type; } - export function getThisParameter(signature: SignatureDeclaration): ParameterDeclaration | undefined { - if (signature.parameters.length) { + export function getThisParameter(signature: SignatureDeclaration | JSDocSignature): ParameterDeclaration | undefined { + // callback tags do not currently support this parameters + if (signature.parameters.length && !isJSDocSignature(signature)) { const thisParameter = signature.parameters[0]; if (parameterIsThisKeyword(thisParameter)) { return thisParameter; @@ -3008,13 +3020,6 @@ namespace ts { return id.originalKeywordKind === SyntaxKind.ThisKeyword; } - export interface AllAccessorDeclarations { - firstAccessor: AccessorDeclaration; - secondAccessor: AccessorDeclaration; - getAccessor: AccessorDeclaration; - setAccessor: AccessorDeclaration; - } - export function getAllAccessorDeclarations(declarations: NodeArray, accessor: AccessorDeclaration): AllAccessorDeclarations { let firstAccessor: AccessorDeclaration; let secondAccessor: AccessorDeclaration; @@ -3081,7 +3086,10 @@ namespace ts { * 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. */ - export function getEffectiveReturnTypeNode(node: SignatureDeclaration): TypeNode | undefined { + export function getEffectiveReturnTypeNode(node: SignatureDeclaration | JSDocSignature): TypeNode | undefined { + if (isJSDocSignature(node)) { + return node.type && node.type.typeExpression && node.type.typeExpression.type; + } return node.type || (isInJavaScriptFile(node) ? getJSDocReturnType(node) : undefined); } @@ -3089,13 +3097,27 @@ namespace ts { * 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) { - return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined); + export function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray { + if (isJSDocSignature(node)) { + return emptyArray; + } + if (isJSDocTypeAlias(node)) { + Debug.assert(node.parent.kind === SyntaxKind.JSDocComment); + const templateTags = flatMap(filter(node.parent.tags, isJSDocTemplateTag), tag => tag.typeParameters) as ReadonlyArray; + const templateTagNodes = templateTags as NodeArray; + templateTagNodes.pos = templateTagNodes.length > 0 ? first(templateTagNodes).pos : node.pos; + templateTagNodes.end = templateTagNodes.length > 0 ? last(templateTagNodes).end : node.end; + templateTagNodes.hasTrailingComma = false; + return templateTagNodes; + } + return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : emptyArray); } - export function getJSDocTypeParameterDeclarations(node: DeclarationWithTypeParameters) { - const templateTag = getJSDocTemplateTag(node); - return templateTag && templateTag.typeParameters; + export function getJSDocTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray { + // template tags are only available when a typedef isn't already using them + const tag = find(getJSDocTags(node), (tag): tag is JSDocTemplateTag => + isJSDocTemplateTag(tag) && !(tag.parent.kind === SyntaxKind.JSDocComment && tag.parent.tags!.some(isJSDocTypeAlias))); + return (tag && tag.typeParameters) || emptyArray; } /** @@ -4632,6 +4654,8 @@ namespace ts { return undefined; } } + case SyntaxKind.JSDocCallbackTag: + return (declaration as JSDocCallbackTag).name; case SyntaxKind.JSDocTypedefTag: return getNameOfJSDocTypedef(declaration as JSDocTypedefTag); case SyntaxKind.ExportAssignment: { @@ -4767,7 +4791,9 @@ namespace ts { let tags = (node as JSDocContainer).jsDocCache; // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. if (tags === undefined) { - (node as JSDocContainer).jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); + const comments = getJSDocCommentsAndTags(node); + Debug.assert(comments.length < 2 || comments[0] !== comments[1]); + (node as JSDocContainer).jsDocCache = tags = flatMap(comments, j => isJSDoc(j) ? j.tags : j); } return tags; } @@ -4890,6 +4916,11 @@ namespace ts { return node.kind === SyntaxKind.IndexSignature; } + /* @internal */ + export function isGetOrSetAccessorDeclaration(node: Node): node is AccessorDeclaration { + return node.kind === SyntaxKind.SetAccessor || node.kind === SyntaxKind.GetAccessor; + } + // Type export function isTypePredicateNode(node: Node): node is TypePredicateNode { @@ -5462,6 +5493,14 @@ namespace ts { export function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral { return node.kind === SyntaxKind.JSDocTypeLiteral; } + + export function isJSDocCallbackTag(node: Node): node is JSDocCallbackTag { + return node.kind === SyntaxKind.JSDocCallbackTag; + } + + export function isJSDocSignature(node: Node): node is JSDocSignature { + return node.kind === SyntaxKind.JSDocSignature; + } } // Node tests @@ -5623,6 +5662,7 @@ namespace ts { switch (kind) { case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: + case SyntaxKind.JSDocSignature: case SyntaxKind.ConstructSignature: case SyntaxKind.IndexSignature: case SyntaxKind.FunctionType: @@ -6091,6 +6131,7 @@ namespace ts { || kind === SyntaxKind.TypeParameter || kind === SyntaxKind.VariableDeclaration || kind === SyntaxKind.JSDocTypedefTag + || kind === SyntaxKind.JSDocCallbackTag || kind === SyntaxKind.JSDocPropertyTag; } @@ -6241,7 +6282,7 @@ namespace ts { /** True if node is of a kind that may contain comment text. */ export function isJSDocCommentContainingNode(node: Node): boolean { - return node.kind === SyntaxKind.JSDocComment || isJSDocTag(node) || isJSDocTypeLiteral(node); + return node.kind === SyntaxKind.JSDocComment || isJSDocTag(node) || isJSDocTypeLiteral(node) || isJSDocSignature(node); } // TODO: determine what this does before making it public. diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 284d870caa1..6c1864cd627 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -145,7 +145,7 @@ namespace ts { statements = setTextRange(createNodeArray([createStatement(createLiteral("use strict")), ...statements]), statements); } const declarations = context.endLexicalEnvironment(); - return setTextRange(createNodeArray(concatenate(statements, declarations)), statements); + return setTextRange(createNodeArray(concatenate(declarations, statements)), statements); } /** @@ -1468,8 +1468,8 @@ namespace ts { } return isNodeArray(statements) - ? setTextRange(createNodeArray(concatenate(statements, declarations)), statements) - : addRange(statements, declarations); + ? setTextRange(createNodeArray(concatenate(declarations, statements)), statements) + : prependRange(statements, declarations); } /** diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 1ffa2fc63a7..b899f3107c5 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -12,6 +12,10 @@ const enum CompilerTestType { Test262 } +interface CompilerFileBasedTest extends Harness.FileBasedTest { + payload?: Harness.TestCaseParser.TestCaseContent; +} + class CompilerBaselineRunner extends RunnerBase { private basePath = "tests/cases"; private testSuiteName: TestRunnerKind; @@ -42,7 +46,8 @@ class CompilerBaselineRunner extends RunnerBase { } public enumerateTestFiles() { - return this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }); + // see also: `enumerateTestFiles` in tests/webTestServer.ts + return this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }).map(CompilerTest.getConfigurations); } public initializeTests() { @@ -52,24 +57,32 @@ class CompilerBaselineRunner extends RunnerBase { }); // this will set up a series of describe/it blocks to run between the setup and cleanup phases - const files = this.tests.length > 0 ? this.tests : this.enumerateTestFiles(); - files.forEach(file => { this.checkTestCodeOutput(vpath.normalizeSeparators(file)); }); + const files = this.tests.length > 0 ? this.tests : Harness.IO.enumerateTestFiles(this); + files.forEach(test => { + const file = typeof test === "string" ? test : test.file; + this.checkTestCodeOutput(vpath.normalizeSeparators(file), typeof test === "string" ? CompilerTest.getConfigurations(test) : test); + }); }); } - public checkTestCodeOutput(fileName: string) { - for (const { name, payload } of CompilerTest.getConfigurations(fileName)) { - describe(`${this.testSuiteName} tests for ${fileName}${name ? ` (${name})` : ``}`, () => { - this.runSuite(fileName, payload); + public checkTestCodeOutput(fileName: string, test?: CompilerFileBasedTest) { + if (test && test.configurations) { + test.configurations.forEach(configuration => { + describe(`${this.testSuiteName} tests for ${fileName}${configuration ? ` (${Harness.getFileBasedTestConfigurationDescription(configuration)})` : ``}`, () => { + this.runSuite(fileName, test, configuration); + }); }); } + describe(`${this.testSuiteName} tests for ${fileName}`, () => { + this.runSuite(fileName, test); + }); } - private runSuite(fileName: string, testCaseContent: Harness.TestCaseParser.TestCaseContent) { + private runSuite(fileName: string, test?: CompilerFileBasedTest, configuration?: Harness.FileBasedTestConfiguration) { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Everything declared here should be cleared out in the "after" callback. let compilerTest: CompilerTest | undefined; - before(() => { compilerTest = new CompilerTest(fileName, testCaseContent); }); + before(() => { compilerTest = new CompilerTest(fileName, test && test.payload, configuration); }); it(`Correct errors for ${fileName}`, () => { compilerTest.verifyDiagnostics(); }); it(`Correct module resolution tracing for ${fileName}`, () => { compilerTest.verifyModuleResolution(); }); it(`Correct sourcemap content for ${fileName}`, () => { compilerTest.verifySourceMapRecord(); }); @@ -97,11 +110,6 @@ class CompilerBaselineRunner extends RunnerBase { } } -interface CompilerTestConfiguration { - name: string; - payload: Harness.TestCaseParser.TestCaseContent; -} - class CompilerTest { private fileName: string; private justName: string; @@ -116,10 +124,20 @@ class CompilerTest { // equivalent to other files on the file system not directly passed to the compiler (ie things that are referenced by other files) private otherFiles: Harness.Compiler.TestFile[]; - constructor(fileName: string, testCaseContent: Harness.TestCaseParser.TestCaseContent) { + constructor(fileName: string, testCaseContent?: Harness.TestCaseParser.TestCaseContent, configurationOverrides?: Harness.TestCaseParser.CompilerSettings) { this.fileName = fileName; this.justName = vpath.basename(fileName); + const rootDir = fileName.indexOf("conformance") === -1 ? "tests/cases/compiler/" : ts.getDirectoryPath(fileName) + "/"; + + if (testCaseContent === undefined) { + testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(Harness.IO.readFile(fileName), fileName, rootDir); + } + + if (configurationOverrides) { + testCaseContent = { ...testCaseContent, settings: { ...testCaseContent.settings, ...configurationOverrides } }; + } + const units = testCaseContent.testUnitData; this.harnessSettings = testCaseContent.settings; let tsConfigOptions: ts.CompilerOptions; @@ -174,32 +192,14 @@ class CompilerTest { this.options = this.result.options; } - public static getConfigurations(fileName: string) { - const content = Harness.IO.readFile(fileName); - const rootDir = fileName.indexOf("conformance") === -1 ? "tests/cases/compiler/" : ts.getDirectoryPath(fileName) + "/"; - const testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, fileName, rootDir); - const configurations: CompilerTestConfiguration[] = []; - const scriptTargets = this._split(testCaseContent.settings.target); - const moduleKinds = this._split(testCaseContent.settings.module); - for (const scriptTarget of scriptTargets) { - for (const moduleKind of moduleKinds) { - let name = ""; - if (moduleKinds.length > 1) { - name += `@module: ${moduleKind || "none"}`; - } - if (scriptTargets.length > 1) { - if (name) name += ", "; - name += `@target: ${scriptTarget || "none"}`; - } - - const settings = { ...testCaseContent.settings }; - if (scriptTarget) settings.target = scriptTarget; - if (moduleKind) settings.module = moduleKind; - configurations.push({ name, payload: { ...testCaseContent, settings } }); - } - } - - return configurations; + public static getConfigurations(file: string): CompilerFileBasedTest { + // also see `parseCompilerTestConfigurations` in tests/webTestServer.ts + const content = Harness.IO.readFile(file); + const rootDir = file.indexOf("conformance") === -1 ? "tests/cases/compiler/" : ts.getDirectoryPath(file) + "/"; + const payload = Harness.TestCaseParser.makeUnitsFromTest(content, file, rootDir); + const settings = Harness.TestCaseParser.extractCompilerSettings(content); + const configurations = Harness.getFileBasedTestConfigurations(settings, /*varyBy*/ ["module", "target"]); + return { file, payload, configurations }; } public verifyDiagnostics() { @@ -267,11 +267,6 @@ class CompilerTest { this.toBeCompiled.concat(this.otherFiles).filter(file => !!this.result.program.getSourceFile(file.unitName))); } - private static _split(text: string) { - const entries = text && text.split(",").map(s => s.toLowerCase().trim()).filter(s => s.length > 0); - return entries && entries.length > 0 ? entries : [""]; - } - private makeUnitName(name: string, root: string) { const path = ts.toPath(name, root, ts.identity); const pathStart = ts.toPath(Harness.IO.getCurrentDirectory(), "", ts.identity); diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 1d45351114d..8fed742d922 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -2,6 +2,7 @@ /// const fs = require("fs"); const path = require("path"); +const del = require("del"); interface ExecResult { stdout: Buffer; @@ -26,9 +27,12 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { // Read in and evaluate the test list const testList = this.tests && this.tests.length ? this.tests : this.enumerateTestFiles(); - describe(`${this.kind()} code samples`, () => { + // tslint:disable-next-line:no-this-assignment + const cls = this; + describe(`${this.kind()} code samples`, function(this: Mocha.ISuiteCallbackContext) { + this.timeout(600_000); // 10 minutes for (const test of testList) { - this.runTest(test); + cls.runTest(typeof test === "string" ? test : test.file); } }); } @@ -42,6 +46,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { it("should build successfully", () => { let cwd = path.join(Harness.IO.getWorkspaceRoot(), cls.testDir, directoryName); + const originalCwd = cwd; const stdio = isWorker ? "pipe" : "inherit"; let types: string[]; if (fs.existsSync(path.join(cwd, "test.json"))) { @@ -64,7 +69,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { fs.unlinkSync(path.join(cwd, "package-lock.json")); } if (fs.existsSync(path.join(cwd, "node_modules"))) { - require("del").sync(path.join(cwd, "node_modules"), { force: true }); + del.sync(path.join(cwd, "node_modules"), { force: true }); } const install = cp.spawnSync(`npm`, ["i", "--ignore-scripts"], { cwd, timeout: timeout / 2, shell: true, stdio }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure if (install.status !== 0) throw new Error(`NPM Install for ${directoryName} failed: ${install.stderr.toString()}`); @@ -72,6 +77,9 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { const args = [path.join(Harness.IO.getWorkspaceRoot(), "built/local/tsc.js")]; if (types) { args.push("--types", types.join(",")); + // Also actually install those types (for, eg, the js projects which need node) + const install = cp.spawnSync(`npm`, ["i", ...types.map(t => `@types/${t}`), "--no-save", "--ignore-scripts"], { cwd: originalCwd, timeout: timeout / 2, shell: true, stdio }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure + if (install.status !== 0) throw new Error(`NPM Install types for ${directoryName} failed: ${install.stderr.toString()}`); } args.push("--noEmit"); Harness.Baseline.runBaseline(`${cls.kind()}/${directoryName}.log`, () => { @@ -91,14 +99,50 @@ class UserCodeRunner extends ExternalCompileRunnerBase { // tslint:disable-next-line:no-null-keyword return result.status === 0 && !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status} Standard output: -${result.stdout.toString().replace(/\r\n/g, "\n")} +${sortErrors(stripAbsoluteImportPaths(result.stdout.toString().replace(/\r\n/g, "\n")))} Standard error: -${result.stderr.toString().replace(/\r\n/g, "\n")}`; +${stripAbsoluteImportPaths(result.stderr.toString().replace(/\r\n/g, "\n"))}`; } } +/** + * Import types and some other error messages use absolute paths in errors as they have no context to be written relative to; + * This is problematic for error baselines, so we grep for them and strip them out. + */ +function stripAbsoluteImportPaths(result: string) { + const workspaceRegexp = new RegExp(Harness.IO.getWorkspaceRoot().replace(/\\/g, "\\\\"), "g"); + return result + .replace(/import\(".*?\/tests\/cases\/user\//g, `import("/`) + .replace(/Module '".*?\/tests\/cases\/user\//g, `Module '"/`) + .replace(workspaceRegexp, "../../.."); +} + +function sortErrors(result: string) { + return ts.flatten(splitBy(result.split("\n"), s => /^\S+/.test(s)).sort(compareErrorStrings)).join("\n"); +} + +const errorRegexp = /^(.+\.[tj]sx?)\((\d+),(\d+)\)(: error TS.*)/; +function compareErrorStrings(a: string[], b: string[]) { + ts.Debug.assertGreaterThanOrEqual(a.length, 1); + ts.Debug.assertGreaterThanOrEqual(b.length, 1); + const matchA = a[0].match(errorRegexp); + if (!matchA) { + return -1; + } + const matchB = b[0].match(errorRegexp); + if (!matchB) { + return 1; + } + const [, errorFileA, lineNumberStringA, columnNumberStringA, remainderA] = matchA; + const [, errorFileB, lineNumberStringB, columnNumberStringB, remainderB] = matchB; + return ts.comparePathsCaseSensitive(errorFileA, errorFileB) || + ts.compareValues(parseInt(lineNumberStringA), parseInt(lineNumberStringB)) || + ts.compareValues(parseInt(columnNumberStringA), parseInt(columnNumberStringB)) || + ts.compareStringsCaseSensitive(remainderA, remainderB); +} + class DefinitelyTypedRunner extends ExternalCompileRunnerBase { readonly testDir = "../DefinitelyTyped/types/"; workingDirectory = this.testDir; diff --git a/src/harness/fakes.ts b/src/harness/fakes.ts index 79d3503cb80..4fdd30c940e 100644 --- a/src/harness/fakes.ts +++ b/src/harness/fakes.ts @@ -150,7 +150,7 @@ namespace fakes { private _getStats(path: string) { try { - return this.vfs.statSync(path); + return this.vfs.existsSync(path) ? this.vfs.statSync(path) : undefined; } catch { return undefined; @@ -332,7 +332,7 @@ namespace fakes { let fs = this.vfs; while (fs.shadowRoot) { try { - const shadowRootStats = fs.shadowRoot.statSync(canonicalFileName); + const shadowRootStats = fs.shadowRoot.existsSync(canonicalFileName) && fs.shadowRoot.statSync(canonicalFileName); if (shadowRootStats.dev !== stats.dev || shadowRootStats.ino !== stats.ino || shadowRootStats.mtimeMs !== stats.mtimeMs) { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5e7dede93ee..47f0a91b286 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -23,7 +23,7 @@ namespace FourSlash { ts.disableIncrementalParsing = false; - import ArrayOrSingle = FourSlashInterface.Many; + import ArrayOrSingle = FourSlashInterface.ArrayOrSingle; // Represents a parsed source file with metadata interface FourSlashFile { @@ -378,7 +378,6 @@ namespace FourSlash { "getCompletionEntryDetails", "getCompletionEntrySymbol", "getQuickInfoAtPosition", - "getSignatureHelpItems", "getReferencesAtPosition", "getDocumentHighlights", ]; @@ -899,7 +898,7 @@ namespace FourSlash { } else { const found = actualByName.get(exclude.name); - if (found.source === exclude.source) { + if (found && found.source === exclude.source) { this.raiseError(`Did not expect to get a completion named ${exclude.name} with source ${exclude.source}`); } } @@ -1062,8 +1061,8 @@ namespace FourSlash { if (tags !== undefined) { assert.equal(details.tags.length, tags.length, this.messageAtLastKnownMarker("QuickInfo tags")); ts.zipWith(tags, details.tags, (expectedTag, actualTag) => { - assert.equal(expectedTag.name, actualTag.name); - assert.equal(expectedTag.text, actualTag.text, this.messageAtLastKnownMarker("QuickInfo tag " + actualTag.name)); + assert.equal(actualTag.name, expectedTag.name); + assert.equal(actualTag.text, expectedTag.text, this.messageAtLastKnownMarker("QuickInfo tag " + actualTag.name)); }); } } @@ -1446,83 +1445,91 @@ Actual: ${stringify(fullActual)}`); } } - public verifyCurrentSignatureHelpIs(expected: string) { - const help = this.getActiveSignatureHelpItem(); - assert.equal( - ts.displayPartsToString(help.prefixDisplayParts) + - help.parameters.map(p => ts.displayPartsToString(p.displayParts)).join(ts.displayPartsToString(help.separatorDisplayParts)) + - ts.displayPartsToString(help.suffixDisplayParts), expected); + public verifyNoSignatureHelp(markers: ReadonlyArray) { + if (markers.length) { + for (const marker of markers) { + this.goToMarker(marker); + this.verifyNoSignatureHelp(ts.emptyArray); + } + return; + } + + const actual = this.getSignatureHelp(); + if (actual) { + this.raiseError(`Expected no signature help, but got "${stringify(actual)}"`); + } } - public verifyCurrentParameterIsVariable(isVariable: boolean) { - const signature = this.getActiveSignatureHelpItem(); - assert.isOk(signature); - assert.equal(isVariable, signature.isVariadic); + public verifySignatureHelp(optionses: ReadonlyArray) { + for (const options of optionses) { + if (options.marker === undefined) { + this.verifySignatureHelpWorker(options); + } + else { + for (const marker of toArray(options.marker)) { + this.goToMarker(marker); + this.verifySignatureHelpWorker(options); + } + } + } } - public verifyCurrentParameterHelpName(name: string) { - const activeParameter = this.getActiveParameter(); - const activeParameterName = activeParameter.name; - assert.equal(activeParameterName, name); - } + private verifySignatureHelpWorker(options: FourSlashInterface.VerifySignatureHelpOptions) { + const help = this.getSignatureHelp(); + const selectedItem = help.items[help.selectedItemIndex]; + // Argument index may exceed number of parameters + const currentParameter: ts.SignatureHelpParameter | undefined = selectedItem.parameters[help.argumentIndex]; - public verifyCurrentParameterSpanIs(parameter: string) { - const activeParameter = this.getActiveParameter(); - assert.equal(ts.displayPartsToString(activeParameter.displayParts), parameter); - } + assert.equal(help.items.length, options.overloadsCount || 1, this.assertionMessageAtLastKnownMarker("signature help overloads count")); - public verifyCurrentParameterHelpDocComment(docComment: string) { - const activeParameter = this.getActiveParameter(); - const activeParameterDocComment = activeParameter.documentation; - assert.equal(ts.displayPartsToString(activeParameterDocComment), docComment, this.assertionMessageAtLastKnownMarker("current parameter Help DocComment")); - } + assert.equal(ts.displayPartsToString(selectedItem.documentation), options.docComment || "", this.assertionMessageAtLastKnownMarker("current signature help doc comment")); - public verifyCurrentSignatureHelpParameterCount(expectedCount: number) { - assert.equal(this.getActiveSignatureHelpItem().parameters.length, expectedCount); - } + if (options.text !== undefined) { + assert.equal( + ts.displayPartsToString(selectedItem.prefixDisplayParts) + + selectedItem.parameters.map(p => ts.displayPartsToString(p.displayParts)).join(ts.displayPartsToString(selectedItem.separatorDisplayParts)) + + ts.displayPartsToString(selectedItem.suffixDisplayParts), options.text); + } + if (options.parameterName !== undefined) { + assert.equal(currentParameter!.name, options.parameterName); + } + if (options.parameterSpan !== undefined) { + assert.equal(ts.displayPartsToString(currentParameter!.displayParts), options.parameterSpan); + } + if (currentParameter) { + assert.equal(ts.displayPartsToString(currentParameter.documentation), options.parameterDocComment || "", this.assertionMessageAtLastKnownMarker("current parameter Help DocComment")); + } + if (options.parameterCount !== undefined) { + assert.equal(selectedItem.parameters.length, options.parameterCount); + } + if (options.argumentCount !== undefined) { + assert.equal(help.argumentCount, options.argumentCount); + } - public verifyCurrentSignatureHelpIsVariadic(expected: boolean) { - assert.equal(this.getActiveSignatureHelpItem().isVariadic, expected); - } + assert.equal(selectedItem.isVariadic, !!options.isVariadic); - public verifyCurrentSignatureHelpDocComment(docComment: string) { - const actualDocComment = this.getActiveSignatureHelpItem().documentation; - assert.equal(ts.displayPartsToString(actualDocComment), docComment, this.assertionMessageAtLastKnownMarker("current signature help doc comment")); - } - - public verifyCurrentSignatureHelpTags(tags: ts.JSDocTagInfo[]) { - const actualTags = this.getActiveSignatureHelpItem().tags; - - assert.equal(actualTags.length, tags.length, this.assertionMessageAtLastKnownMarker("signature help tags")); - ts.zipWith(tags, actualTags, (expectedTag, actualTag) => { + const actualTags = selectedItem.tags; + assert.equal(actualTags.length, (options.tags || ts.emptyArray).length, this.assertionMessageAtLastKnownMarker("signature help tags")); + ts.zipWith((options.tags || ts.emptyArray), actualTags, (expectedTag, actualTag) => { assert.equal(expectedTag.name, actualTag.name); assert.equal(expectedTag.text, actualTag.text, this.assertionMessageAtLastKnownMarker("signature help tag " + actualTag.name)); }); - } - public verifySignatureHelpCount(expected: number) { - const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - const actual = help && help.items ? help.items.length : 0; - assert.equal(actual, expected); - } - - public verifySignatureHelpArgumentCount(expected: number) { - const signatureHelpItems = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - const actual = signatureHelpItems.argumentCount; - assert.equal(actual, expected); - } - - public verifySignatureHelpPresent(shouldBePresent = true) { - const actual = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - if (shouldBePresent) { - if (!actual) { - this.raiseError("Expected signature help to be present, but it wasn't"); - } - } - else { - if (actual) { - this.raiseError(`Expected no signature help, but got "${stringify(actual)}"`); - } + const allKeys: ReadonlyArray = [ + "marker", + "overloadsCount", + "docComment", + "text", + "parameterName", + "parameterSpan", + "parameterDocComment", + "parameterCount", + "isVariadic", + "tags", + "argumentCount", + ]; + for (const key in options) { + ts.Debug.assert(ts.contains(allKeys, key)); } } @@ -1564,19 +1571,6 @@ Actual: ${stringify(fullActual)}`); this.validate("error", message, renameInfo.localizedErrorMessage); } - private getActiveSignatureHelpItem() { - const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - const index = help.selectedItemIndex; - return help.items[index]; - } - - private getActiveParameter(): ts.SignatureHelpParameter { - const help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - const item = help.items[help.selectedItemIndex]; - const currentParam = help.argumentIndex; - return item.parameters[currentParam]; - } - private alignmentForExtraInfo = 50; private spanInfoToString(spanInfo: ts.TextSpan, prefixString: string) { @@ -1790,8 +1784,12 @@ Actual: ${stringify(fullActual)}`); } public printCurrentSignatureHelp() { - const sigHelp = this.getActiveSignatureHelpItem(); - Harness.IO.log(stringify(sigHelp)); + const help = this.getSignatureHelp(); + Harness.IO.log(stringify(help.items[help.selectedItemIndex])); + } + + private getSignatureHelp(): ts.SignatureHelpItems | undefined { + return this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); } public printCompletionListMembers(preferences: ts.UserPreferences | undefined) { @@ -2295,9 +2293,13 @@ Actual: ${stringify(fullActual)}`); } public verifyCurrentFileContent(text: string) { - const actual = this.getFileContent(this.activeFile.fileName); + this.verifyFileContent(this.activeFile.fileName, text); + } + + private verifyFileContent(fileName: string, text: string) { + const actual = this.getFileContent(fileName); if (actual !== text) { - throw new Error(`verifyCurrentFileContent failed:\n${showTextDiff(text, actual)}`); + throw new Error(`verifyFileContent failed:\n${showTextDiff(text, actual)}`); } } @@ -2485,7 +2487,7 @@ Actual: ${stringify(fullActual)}`); this.applyCodeActions(details.codeActions); - this.verifyNewContent(options); + this.verifyNewContent(options, ts.flatMap(details.codeActions, a => a.changes.map(c => c.fileName))); } public verifyRangeIs(expectedText: string, includeWhiteSpace?: boolean) { @@ -2572,13 +2574,25 @@ Actual: ${stringify(fullActual)}`); this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false); } - this.verifyNewContent(options); + this.verifyNewContent(options, action.changes.map(c => c.fileName)); } - private verifyNewContent(options: FourSlashInterface.NewContentOptions) { + private verifyNewContent(options: FourSlashInterface.NewContentOptions, changedFiles: ReadonlyArray) { + const assertedChangedFiles = !options.newFileContent || typeof options.newFileContent === "string" + ? [this.activeFile.fileName] + : ts.getOwnKeys(options.newFileContent); + assert.deepEqual(assertedChangedFiles, changedFiles); + if (options.newFileContent !== undefined) { assert(!options.newRangeContent); - this.verifyCurrentFileContent(options.newFileContent); + if (typeof options.newFileContent === "string") { + this.verifyCurrentFileContent(options.newFileContent); + } + else { + for (const fileName in options.newFileContent) { + this.verifyFileContent(fileName, options.newFileContent[fileName]); + } + } } else { this.verifyRangeIs(options.newRangeContent, /*includeWhitespace*/ true); @@ -3005,9 +3019,7 @@ Actual: ${stringify(fullActual)}`); } public verifyApplicableRefactorAvailableAtMarker(negative: boolean, markerName: string) { - const marker = this.getMarkerByName(markerName); - const applicableRefactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, marker.position, ts.defaultPreferences); - const isAvailable = applicableRefactors && applicableRefactors.length > 0; + const isAvailable = this.getApplicableRefactors(this.getMarkerByName(markerName).position).length > 0; if (negative && isAvailable) { this.raiseError(`verifyApplicableRefactorAvailableAtMarker failed - expected no refactor at marker ${markerName} but found some.`); } @@ -3024,9 +3036,7 @@ Actual: ${stringify(fullActual)}`); } public verifyRefactorAvailable(negative: boolean, name: string, actionName?: string) { - const selection = this.getSelection(); - - let refactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, selection, ts.defaultPreferences) || []; + let refactors = this.getApplicableRefactors(this.getSelection()); refactors = refactors.filter(r => r.name === name && (actionName === undefined || r.actions.some(a => a.name === actionName))); const isAvailable = refactors.length > 0; @@ -3046,10 +3056,7 @@ Actual: ${stringify(fullActual)}`); } public verifyRefactor({ name, actionName, refactors }: FourSlashInterface.VerifyRefactorOptions) { - const selection = this.getSelection(); - - const actualRefactors = (this.languageService.getApplicableRefactors(this.activeFile.fileName, selection, ts.defaultPreferences) || ts.emptyArray) - .filter(r => r.name === name && r.actions.some(a => a.name === actionName)); + const actualRefactors = this.getApplicableRefactors(this.getSelection()).filter(r => r.name === name && r.actions.some(a => a.name === actionName)); this.assertObjectsEqual(actualRefactors, refactors); } @@ -3059,8 +3066,7 @@ Actual: ${stringify(fullActual)}`); throw new Error("Exactly one refactor range is allowed per test."); } - const applicableRefactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, ts.first(ranges), ts.defaultPreferences); - const isAvailable = applicableRefactors && applicableRefactors.length > 0; + const isAvailable = this.getApplicableRefactors(ts.first(ranges)).length > 0; if (negative && isAvailable) { this.raiseError(`verifyApplicableRefactorAvailableForRange failed - expected no refactor but found some.`); } @@ -3071,7 +3077,7 @@ Actual: ${stringify(fullActual)}`); public applyRefactor({ refactorName, actionName, actionDescription, newContent: newContentWithRenameMarker }: FourSlashInterface.ApplyRefactorOptions) { const range = this.getSelection(); - const refactors = this.languageService.getApplicableRefactors(this.activeFile.fileName, range, ts.defaultPreferences); + const refactors = this.getApplicableRefactors(range); const refactorsWithName = refactors.filter(r => r.name === refactorName); if (refactorsWithName.length === 0) { this.raiseError(`The expected refactor: ${refactorName} is not available at the marker location.\nAvailable refactors: ${refactors.map(r => r.name)}`); @@ -3117,7 +3123,48 @@ Actual: ${stringify(fullActual)}`); return { renamePosition, newContent }; } } + } + public noMoveToNewFile() { + for (const range of this.getRanges()) { + for (const refactor of this.getApplicableRefactors(range, { allowTextChangesInNewFiles: true })) { + if (refactor.name === "Move to a new file") { + ts.Debug.fail("Did not expect to get 'move to a new file' refactor"); + } + } + } + } + + public moveToNewFile(options: FourSlashInterface.MoveToNewFileOptions): void { + assert(this.getRanges().length === 1); + const range = this.getRanges()[0]; + const refactor = ts.find(this.getApplicableRefactors(range, { allowTextChangesInNewFiles: true }), r => r.name === "Move to a new file"); + assert(refactor.actions.length === 1); + 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, ts.defaultPreferences); + for (const edit of editInfo.edits) { + const newContent = options.newFileContents[edit.fileName]; + if (newContent === undefined) { + this.raiseError(`There was an edit in ${edit.fileName} but new content was not specified.`); + } + if (this.testData.files.some(f => f.fileName === edit.fileName)) { + this.applyEdits(edit.fileName, edit.textChanges, /*isFormattingEdit*/ false); + this.openFile(edit.fileName); + this.verifyCurrentFileContent(newContent); + } + else { + assert(edit.textChanges.length === 1); + const change = ts.first(edit.textChanges); + assert.deepEqual(change.span, ts.createTextSpan(0, 0)); + assert.equal(change.newText, newContent, `Content for ${edit.fileName}`); + } + } + + for (const fileName in options.newFileContents) { + assert(editInfo.edits.some(e => e.fileName === fileName)); + } } public verifyFileAfterApplyingRefactorAtMarker( @@ -3333,6 +3380,10 @@ Actual: ${stringify(fullActual)}`); this.verifyCurrentFileContent(options.newFileContents[fileName]); } } + + private getApplicableRefactors(positionOrRange: number | ts.TextRange, preferences = ts.defaultPreferences): ReadonlyArray { + return this.languageService.getApplicableRefactors(this.activeFile.fileName, positionOrRange, preferences) || ts.emptyArray; + } } export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) { @@ -4005,8 +4056,12 @@ namespace FourSlashInterface { this.state.verifyCompletionListAllowsNewIdentifier(this.negative); } - public signatureHelpPresent() { - this.state.verifySignatureHelpPresent(!this.negative); + public noSignatureHelp(...markers: string[]): void { + this.state.verifyNoSignatureHelp(markers); + } + + public signatureHelp(...options: VerifySignatureHelpOptions[]): void { + this.state.verifySignatureHelp(options); } public errorExistsBetweenMarkers(startMarker: string, endMarker: string) { @@ -4071,7 +4126,7 @@ namespace FourSlashInterface { super(state); } - public completionsAt(markerName: Many, completions: ReadonlyArray, options?: CompletionsAtOptions) { + public completionsAt(markerName: ArrayOrSingle, completions: ReadonlyArray, options?: CompletionsAtOptions) { this.state.verifyCompletionsAt(markerName, completions, options); } @@ -4126,19 +4181,19 @@ namespace FourSlashInterface { this.state.verifyCurrentFileContent(text); } - public goToDefinitionIs(endMarkers: Many) { + public goToDefinitionIs(endMarkers: ArrayOrSingle) { this.state.verifyGoToDefinitionIs(endMarkers); } - public goToDefinition(startMarkerName: Many, endMarkerName: Many, range?: FourSlash.Range): void; - public goToDefinition(startsAndEnds: [Many, Many][] | { [startMarkerName: string]: Many }): void; - public goToDefinition(arg0: any, endMarkerName?: Many) { + public goToDefinition(startMarkerName: ArrayOrSingle, endMarkerName: ArrayOrSingle, range?: FourSlash.Range): void; + public goToDefinition(startsAndEnds: [ArrayOrSingle, ArrayOrSingle][] | { [startMarkerName: string]: ArrayOrSingle }): void; + public goToDefinition(arg0: any, endMarkerName?: ArrayOrSingle) { this.state.verifyGoToDefinition(arg0, endMarkerName); } - public goToType(startMarkerName: Many, endMarkerName: Many): void; - public goToType(startsAndEnds: [Many, Many][] | { [startMarkerName: string]: Many }): void; - public goToType(arg0: any, endMarkerName?: Many) { + public goToType(startMarkerName: ArrayOrSingle, endMarkerName: ArrayOrSingle): void; + public goToType(startsAndEnds: [ArrayOrSingle, ArrayOrSingle][] | { [startMarkerName: string]: ArrayOrSingle }): void; + public goToType(arg0: any, endMarkerName?: ArrayOrSingle) { this.state.verifyGoToType(arg0, endMarkerName); } @@ -4166,7 +4221,7 @@ namespace FourSlashInterface { this.state.verifyTypeOfSymbolAtLocation(range, symbol, expected); } - public referenceGroups(starts: Many | Many, parts: ReferenceGroup[]) { + public referenceGroups(starts: ArrayOrSingle | ArrayOrSingle, parts: ReferenceGroup[]) { this.state.verifyReferenceGroups(starts, parts); } @@ -4186,46 +4241,6 @@ namespace FourSlashInterface { this.state.verifyDisplayPartsOfReferencedSymbol(expected); } - public currentParameterHelpArgumentNameIs(name: string) { - this.state.verifyCurrentParameterHelpName(name); - } - - public currentParameterSpanIs(parameter: string) { - this.state.verifyCurrentParameterSpanIs(parameter); - } - - public currentParameterHelpArgumentDocCommentIs(docComment: string) { - this.state.verifyCurrentParameterHelpDocComment(docComment); - } - - public currentSignatureHelpDocCommentIs(docComment: string) { - this.state.verifyCurrentSignatureHelpDocComment(docComment); - } - - public currentSignatureHelpTagsAre(tags: ts.JSDocTagInfo[]) { - this.state.verifyCurrentSignatureHelpTags(tags); - } - - public signatureHelpCountIs(expected: number) { - this.state.verifySignatureHelpCount(expected); - } - - public signatureHelpCurrentArgumentListIsVariadic(expected: boolean) { - this.state.verifyCurrentSignatureHelpIsVariadic(expected); - } - - public signatureHelpArgumentCountIs(expected: number) { - this.state.verifySignatureHelpArgumentCount(expected); - } - - public currentSignatureParameterCountIs(expected: number) { - this.state.verifyCurrentSignatureHelpParameterCount(expected); - } - - public currentSignatureHelpIs(expected: string) { - this.state.verifyCurrentSignatureHelpIs(expected); - } - public noErrors() { this.state.verifyNoErrors(); } @@ -4398,7 +4413,7 @@ namespace FourSlashInterface { this.state.verifyRenameInfoFailed(message); } - public renameLocations(startRanges: Many, options: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: FourSlash.Range[] }) { + public renameLocations(startRanges: ArrayOrSingle, options: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges: FourSlash.Range[] }) { this.state.verifyRenameLocations(startRanges, options); } @@ -4430,6 +4445,13 @@ namespace FourSlashInterface { public getEditsForFileRename(options: GetEditsForFileRenameOptions) { this.state.getEditsForFileRename(options); } + + public moveToNewFile(options: MoveToNewFileOptions): void { + this.state.moveToNewFile(options); + } + public noMoveToNewFile(): void { + this.state.noMoveToNewFile(); + } } export class Edit { @@ -4731,16 +4753,35 @@ namespace FourSlashInterface { } export interface VerifyCompletionsOptions { - readonly marker?: Many; + readonly marker?: ArrayOrSingle; readonly isNewIdentifierLocation?: boolean; - readonly exact?: Many; - readonly includes?: Many; - readonly excludes?: Many; + readonly exact?: ArrayOrSingle; + readonly includes?: ArrayOrSingle; + readonly excludes?: ArrayOrSingle; readonly preferences: ts.UserPreferences; readonly triggerCharacter?: ts.CompletionsTriggerCharacter; } - export type Many = T | ReadonlyArray; + export interface VerifySignatureHelpOptions { + readonly marker?: ArrayOrSingle; + /** @default 1 */ + readonly overloadsCount?: number; + /** @default undefined */ + readonly docComment?: string; + readonly text?: string; + readonly parameterName?: string; + readonly parameterSpan?: string; + /** @default undefined */ + readonly parameterDocComment?: string; + readonly parameterCount?: number; + readonly argumentCount?: number; + /** @default false */ + readonly isVariadic?: boolean; + /** @default ts.emptyArray */ + readonly tags?: ReadonlyArray; + } + + export type ArrayOrSingle = T | ReadonlyArray; export interface VerifyCompletionListContainsOptions extends ts.UserPreferences { triggerCharacter?: ts.CompletionsTriggerCharacter; @@ -4756,7 +4797,7 @@ namespace FourSlashInterface { export interface NewContentOptions { // Exactly one of these should be defined. - newFileContent?: string; + newFileContent?: string | { readonly [filename: string]: string }; newRangeContent?: string; } @@ -4803,4 +4844,8 @@ namespace FourSlashInterface { readonly newPath: string; readonly newFileContents: { readonly [fileName: string]: string }; } + + export interface MoveToNewFileOptions { + readonly newFileContents: { readonly [fileName: string]: string }; + } } diff --git a/src/harness/fourslashRunner.ts b/src/harness/fourslashRunner.ts index d835054a868..d0ad139205a 100644 --- a/src/harness/fourslashRunner.ts +++ b/src/harness/fourslashRunner.ts @@ -36,6 +36,7 @@ class FourSlashRunner extends RunnerBase { } public enumerateTestFiles() { + // see also: `enumerateTestFiles` in tests/webTestServer.ts return this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false }); } @@ -45,22 +46,23 @@ class FourSlashRunner extends RunnerBase { public initializeTests() { if (this.tests.length === 0) { - this.tests = this.enumerateTestFiles(); + this.tests = Harness.IO.enumerateTestFiles(this); } describe(this.testSuiteName + " tests", () => { - this.tests.forEach((fn: string) => { - describe(fn, () => { - fn = ts.normalizeSlashes(fn); - const justName = fn.replace(/^.*[\\\/]/, ""); + this.tests.forEach(test => { + const file = typeof test === "string" ? test : test.file; + describe(file, () => { + let fn = ts.normalizeSlashes(file); + const justName = fn.replace(/^.*[\\\/]/, ""); - // Convert to relative path - const testIndex = fn.indexOf("tests/"); - if (testIndex >= 0) fn = fn.substr(testIndex); + // Convert to relative path + const testIndex = fn.indexOf("tests/"); + if (testIndex >= 0) fn = fn.substr(testIndex); - if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { - it(this.testSuiteName + " test " + justName + " runs correctly", () => { - FourSlash.runFourSlashTest(this.basePath, this.testType, fn); + if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { + it(this.testSuiteName + " test " + justName + " runs correctly", () => { + FourSlash.runFourSlashTest(this.basePath, this.testType, fn); }); } }); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index d73bfd2ed63..28233b797da 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -514,6 +514,7 @@ namespace Harness { fileExists(fileName: string): boolean; directoryExists(path: string): boolean; deleteFile(fileName: string): void; + enumerateTestFiles(runner: RunnerBase): (string | FileBasedTest)[]; listFiles(path: string, filter?: RegExp, options?: { recursive?: boolean }): string[]; log(text: string): void; args(): string[]; @@ -559,6 +560,10 @@ namespace Harness { return dirPath === path ? undefined : dirPath; } + function enumerateTestFiles(runner: RunnerBase) { + return runner.enumerateTestFiles(); + } + function listFiles(path: string, spec: RegExp, options?: { recursive?: boolean }) { options = options || {}; @@ -639,6 +644,7 @@ namespace Harness { directoryExists: path => ts.sys.directoryExists(path), deleteFile, listFiles, + enumerateTestFiles, log: s => console.log(s), args: () => ts.sys.args, getExecutingFilePath: () => ts.sys.getExecutingFilePath(), @@ -913,6 +919,11 @@ namespace Harness { return ts.getDirectoryPath(ts.normalizeSlashes(url.pathname || "/")); } + function enumerateTestFiles(runner: RunnerBase): (string | FileBasedTest)[] { + const response = send(HttpRequestMessage.post(new URL("/api/enumerateTestFiles", serverRoot), HttpContent.text(runner.kind()))); + return hasJsonContent(response) ? JSON.parse(response.content.content) : []; + } + function listFiles(dirname: string, spec?: RegExp, options?: { recursive?: boolean }): string[] { if (spec || (options && !options.recursive)) { let results = IO.listFiles(dirname); @@ -959,6 +970,7 @@ namespace Harness { directoryExists, deleteFile, listFiles: Utils.memoize(listFiles, (path, spec, options) => `${path}|${spec}|${options ? options.recursive === true : true}`), + enumerateTestFiles: Utils.memoize(enumerateTestFiles, runner => runner.kind()), log: s => console.log(s), args: () => [], getExecutingFilePath: () => "", @@ -1761,6 +1773,74 @@ namespace Harness { } } + export interface FileBasedTest { + file: string; + configurations?: FileBasedTestConfiguration[]; + } + + export interface FileBasedTestConfiguration { + [key: string]: string; + } + + function splitVaryBySettingValue(text: string): string[] | undefined { + if (!text) return undefined; + const entries = text.split(/,/).map(s => s.trim().toLowerCase()).filter(s => s.length > 0); + return entries && entries.length > 1 ? entries : undefined; + } + + function computeFileBasedTestConfigurationVariations(configurations: FileBasedTestConfiguration[], variationState: FileBasedTestConfiguration, varyByEntries: [string, string[]][], offset: number) { + if (offset >= varyByEntries.length) { + // make a copy of the current variation state + configurations.push({ ...variationState }); + return; + } + + const [varyBy, entries] = varyByEntries[offset]; + for (const entry of entries) { + // set or overwrite the variation, then compute the next variation + variationState[varyBy] = entry; + computeFileBasedTestConfigurationVariations(configurations, variationState, varyByEntries, offset + 1); + } + } + + /** + * Compute FileBasedTestConfiguration variations based on a supplied list of variable settings. + */ + export function getFileBasedTestConfigurations(settings: TestCaseParser.CompilerSettings, varyBy: string[]): FileBasedTestConfiguration[] | undefined { + let varyByEntries: [string, string[]][] | undefined; + for (const varyByKey of varyBy) { + if (ts.hasProperty(settings, varyByKey)) { + // we only consider variations when there are 2 or more variable entries. + const entries = splitVaryBySettingValue(settings[varyByKey]); + if (entries) { + if (!varyByEntries) varyByEntries = []; + varyByEntries.push([varyByKey, entries]); + } + } + } + + if (!varyByEntries) return undefined; + + const configurations: FileBasedTestConfiguration[] = []; + computeFileBasedTestConfigurationVariations(configurations, /*variationState*/ {}, varyByEntries, /*offset*/ 0); + return configurations; + } + + /** + * Compute a description for this configuration based on its entries + */ + export function getFileBasedTestConfigurationDescription(configuration: FileBasedTestConfiguration) { + let name = ""; + if (configuration) { + const keys = Object.keys(configuration).sort(); + for (const key of keys) { + if (name) name += ", "; + name += `@${key}: ${configuration[key]}`; + } + } + return name; + } + export namespace TestCaseParser { /** all the necessary information to set the right compiler settings */ export interface CompilerSettings { @@ -1779,7 +1859,7 @@ namespace Harness { // Regex for parsing options in the format "@Alpha: Value of any sort" const optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*([^\r\n]*)/gm; // multiple matches on multiple lines - function extractCompilerSettings(content: string): CompilerSettings { + export function extractCompilerSettings(content: string): CompilerSettings { const opts: CompilerSettings = {}; let match: RegExpExecArray; @@ -1800,9 +1880,7 @@ namespace Harness { } /** Given a test file containing // @FileName directives, return an array of named units of code to be added to an existing compiler instance */ - export function makeUnitsFromTest(code: string, fileName: string, rootDir?: string): TestCaseContent { - const settings = extractCompilerSettings(code); - + export function makeUnitsFromTest(code: string, fileName: string, rootDir?: string, settings = extractCompilerSettings(code)): TestCaseContent { // List of all the subfiles we've parsed out const testUnitData: TestUnitData[] = []; diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts index 75712bc7d9b..6a8b21c9702 100644 --- a/src/harness/parallel/host.ts +++ b/src/harness/parallel/host.ts @@ -81,7 +81,8 @@ namespace Harness.Parallel.Host { const { statSync }: { statSync(path: string): { size: number }; } = require("fs"); const path: { join: (...args: string[]) => string } = require("path"); for (const runner of runners) { - for (const file of runner.enumerateTestFiles()) { + for (const test of runner.enumerateTestFiles()) { + const file = typeof test === "string" ? test : test.file; let size: number; if (!perfData) { try { @@ -126,6 +127,7 @@ namespace Harness.Parallel.Host { let passingFiles = 0; let failingFiles = 0; let errorResults: ErrorInfo[] = []; + let passingResults: { name: string[] }[] = []; let totalPassing = 0; const startTime = Date.now(); @@ -197,9 +199,11 @@ namespace Harness.Parallel.Host { totalPassing += data.payload.passing; if (data.payload.errors.length) { errorResults = errorResults.concat(data.payload.errors); + passingResults = passingResults.concat(data.payload.passes); failingFiles++; } else { + passingResults = passingResults.concat(data.payload.passes); passingFiles++; } newPerfData[hashName(data.payload.runner, data.payload.file)] = data.payload.duration; @@ -366,21 +370,55 @@ namespace Harness.Parallel.Host { IO.writeFile(perfdataFileName(configOption), JSON.stringify(newPerfData, null, 4)); // tslint:disable-line:no-null-keyword - process.exit(errorResults.length); + if (Utils.getExecutionEnvironment() !== Utils.ExecutionEnvironment.Browser && process.env.CI === "true") { + const xunitReport = new xunit({ on: ts.noop, once: ts.noop }, { reporterOptions: { output: "./TEST-results.xml" } }); + xunitReport.stats = reporter.stats; + xunitReport.failures = reporter.failures; + const rootAttrs: {[index: string]: any} = { + name: "Tests", + tests: stats.tests, + failures: stats.failures, + errors: stats.failures, + skipped: stats.tests - stats.failures - stats.passes, + timestamp: (new Date()).toUTCString(), + time: (stats.duration / 1000) || 0 + }; + xunitReport.write(`` + "\n"); + xunitReport.write(` `${k}="${escape("" + rootAttrs[k])}"`).join(" ")}>`); + [...failures, ...ts.map(passingResults, makeMochaTest)].forEach(t => { + xunitReport.test(t); + }); + xunitReport.write(""); + xunitReport.done(failures, (f: any[]) => { + process.exit(f.length); + }); + } + else { + process.exit(failures.length); + } + } - function makeMochaTest(test: ErrorInfo) { + function makeMochaTest(test: ErrorInfo | TestInfo) { return { + state: (test as ErrorInfo).error ? "failed" : "passed", + parent: { + fullTitle: () => { + return test.name.slice(0, test.name.length - 1).join(" "); + } + }, + title: test.name[test.name.length - 1], fullTitle: () => { return test.name.join(" "); }, titlePath: () => { return test.name; }, - err: { - message: test.error, - stack: test.stack - } + isPending: () => false, + err: (test as ErrorInfo).error ? { + message: (test as ErrorInfo).error, + stack: (test as ErrorInfo).stack + } : undefined }; } @@ -391,6 +429,7 @@ namespace Harness.Parallel.Host { let mocha: any; let base: any; + let xunit: any; let color: any; let cursor: any; let readline: any; @@ -433,6 +472,7 @@ namespace Harness.Parallel.Host { function initializeProgressBarsDependencies() { mocha = require("mocha"); base = mocha.reporters.Base; + xunit = mocha.reporters.xunit; color = base.color; cursor = base.cursor; readline = require("readline"); diff --git a/src/harness/parallel/shared.ts b/src/harness/parallel/shared.ts index 26b03ac6234..46904fac896 100644 --- a/src/harness/parallel/shared.ts +++ b/src/harness/parallel/shared.ts @@ -7,8 +7,9 @@ namespace Harness.Parallel { export type ParallelHostMessage = ParallelTestMessage | ParallelCloseMessage | ParallelBatchMessage; export type ParallelErrorMessage = { type: "error", payload: { error: string, stack: string, name?: string[] } } | never; - export type ErrorInfo = ParallelErrorMessage["payload"] & { name: string[] }; - export type ParallelResultMessage = { type: "result", payload: { passing: number, errors: ErrorInfo[], duration: number, runner: TestRunnerKind | "unittest", file: string } } | never; + export type TestInfo = { name: string[] } | never; + export type ErrorInfo = ParallelErrorMessage["payload"] & TestInfo; + export type ParallelResultMessage = { type: "result", payload: { passing: number, errors: ErrorInfo[], passes: TestInfo[], duration: number, runner: TestRunnerKind | "unittest", file: string } } | never; export type ParallelBatchProgressMessage = { type: "progress", payload: ParallelResultMessage["payload"] } | never; export type ParallelTimeoutChangeMessage = { type: "timeout", payload: { duration: number | "reset" } } | never; export type ParallelClientMessage = ParallelErrorMessage | ParallelResultMessage | ParallelBatchProgressMessage | ParallelTimeoutChangeMessage; diff --git a/src/harness/parallel/worker.ts b/src/harness/parallel/worker.ts index 4a0f297eee6..d9053364745 100644 --- a/src/harness/parallel/worker.ts +++ b/src/harness/parallel/worker.ts @@ -1,5 +1,6 @@ namespace Harness.Parallel.Worker { let errors: ErrorInfo[] = []; + let passes: TestInfo[] = []; let passing = 0; type MochaCallback = (this: Mocha.ISuiteCallbackContext, done: MochaDone) => void; @@ -9,12 +10,13 @@ namespace Harness.Parallel.Worker { function resetShimHarnessAndExecute(runner: RunnerBase) { errors = []; + passes = []; passing = 0; testList.length = 0; const start = +(new Date()); runner.initializeTests(); testList.forEach(({ name, callback, kind }) => executeCallback(name, callback, kind)); - return { errors, passing, duration: +(new Date()) - start }; + return { errors, passes, passing, duration: +(new Date()) - start }; } @@ -152,6 +154,7 @@ namespace Harness.Parallel.Worker { try { // TODO: If we ever start using async test completions, polyfill promise return handling callback.call(fakeContext); + passes.push({ name: [...namestack] }); } catch (error) { errors.push({ error: error.message, stack: error.stack, name: [...namestack] }); @@ -178,6 +181,7 @@ namespace Harness.Parallel.Worker { errors.push({ error: err.toString(), stack: "", name: [...namestack] }); } else { + passes.push({ name: [...namestack] }); passing++; } completed = true; @@ -294,11 +298,12 @@ namespace Harness.Parallel.Worker { } if (unitTests[name]) { errors = []; + passes = []; passing = 0; const start = +(new Date()); executeSuiteCallback(name, unitTests[name]); delete unitTests[name]; - return { file: name, runner: unittest, errors, passing, duration: +(new Date()) - start }; + return { file: name, runner: unittest, errors, passes, passing, duration: +(new Date()) - start }; } throw new Error(`Unit test with name "${name}" was asked to be run, but such a test does not exist!`); } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 8c396ec44f1..08e92a73be2 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -51,7 +51,7 @@ namespace project { describe("projects tests", () => { const tests = this.tests.length === 0 ? this.enumerateTestFiles() : this.tests; for (const test of tests) { - this.runProjectTestCase(test); + this.runProjectTestCase(typeof test === "string" ? test : test.file); } }); } diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index 80532d30b6f..b29ebb7f920 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -1,13 +1,10 @@ -/// - - type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user" | "dt"; type CompilerTestKind = "conformance" | "compiler"; type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server"; abstract class RunnerBase { // contains the tests to run - public tests: string[] = []; + public tests: (string | Harness.FileBasedTest)[] = []; /** Add a source file to the runner's list of tests that need to be initialized with initializeTests */ public addTest(fileName: string) { @@ -20,7 +17,7 @@ abstract class RunnerBase { abstract kind(): TestRunnerKind; - abstract enumerateTestFiles(): string[]; + abstract enumerateTestFiles(): (string | Harness.FileBasedTest)[]; /** The working directory where tests are found. Needed for batch testing where the input path will differ from the output path inside baselines */ public workingDirectory = ""; diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index cc1e5466115..d0fe3a04c1f 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -89,29 +89,29 @@ namespace RWC { const uniqueNames = ts.createMap(); for (const fileName of fileNames) { // Must maintain order, build result list while checking map - const normalized = ts.normalizeSlashes(fileName); + const normalized = ts.normalizeSlashes(Harness.IO.resolvePath(fileName)); if (!uniqueNames.has(normalized)) { uniqueNames.set(normalized, true); // Load the file - inputFiles.push(getHarnessCompilerInputUnit(fileName)); + inputFiles.push(getHarnessCompilerInputUnit(normalized)); } } // Add files to compilation for (const fileRead of ioLog.filesRead) { - const normalized = ts.normalizeSlashes(fileRead.path); - if (!uniqueNames.has(normalized) && !Harness.isDefaultLibraryFile(fileRead.path)) { - uniqueNames.set(normalized, true); - otherFiles.push(getHarnessCompilerInputUnit(fileRead.path)); + const unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path)); + if (!uniqueNames.has(unitName) && !Harness.isDefaultLibraryFile(fileRead.path)) { + uniqueNames.set(unitName, true); + otherFiles.push(getHarnessCompilerInputUnit(unitName)); } - else if (!opts.options.noLib && Harness.isDefaultLibraryFile(fileRead.path) && !uniqueNames.has(normalized) && useCustomLibraryFile) { + else if (!opts.options.noLib && Harness.isDefaultLibraryFile(fileRead.path) && !uniqueNames.has(unitName) && useCustomLibraryFile) { // If useCustomLibraryFile is true, we will use lib.d.ts from json object // otherwise use the lib.d.ts from built/local // Majority of RWC code will be using built/local/lib.d.ts instead of // lib.d.ts inside json file. However, some RWC cases will still use // their own version of lib.d.ts because they have customized lib.d.ts - uniqueNames.set(normalized, true); - inputFiles.push(getHarnessCompilerInputUnit(fileRead.path)); + uniqueNames.set(unitName, true); + inputFiles.push(getHarnessCompilerInputUnit(unitName)); } } }); @@ -126,7 +126,7 @@ namespace RWC { compilerResult = Harness.Compiler.compileFiles( inputFiles, otherFiles, - /* harnessOptions */ undefined, + { useCaseSensitiveFileNames: "" + (ioLog.useCaseSensitiveFileNames || false) }, opts.options, // Since each RWC json file specifies its current directory in its json file, we need // to pass this information in explicitly instead of acquiring it from the process. @@ -212,6 +212,7 @@ namespace RWC { class RWCRunner extends RunnerBase { public enumerateTestFiles() { + // see also: `enumerateTestFiles` in tests/webTestServer.ts return Harness.IO.getDirectories("internal/cases/rwc/"); } @@ -225,7 +226,7 @@ class RWCRunner extends RunnerBase { public initializeTests(): void { // Read in and evaluate the test list for (const test of this.tests && this.tests.length ? this.tests : this.enumerateTestFiles()) { - this.runTest(test); + this.runTest(typeof test === "string" ? test : test.file); } } diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index 08a42ed2ff7..7f83d9101bd 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -101,6 +101,7 @@ class Test262BaselineRunner extends RunnerBase { } public enumerateTestFiles() { + // see also: `enumerateTestFiles` in tests/webTestServer.ts return ts.map(this.enumerateFiles(Test262BaselineRunner.basePath, Test262BaselineRunner.testFileExtensionRegex, { recursive: true }), ts.normalizePath); } @@ -113,7 +114,7 @@ class Test262BaselineRunner extends RunnerBase { }); } else { - this.tests.forEach(test => this.runTest(test)); + this.tests.forEach(test => this.runTest(typeof test === "string" ? test : test.file)); } } } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index fd1d66f394d..359701a02cb 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -105,6 +105,8 @@ "../services/codefixes/fixExtendsInterfaceBecomesImplements.ts", "../services/codefixes/fixForgottenThisPropertyAccess.ts", "../services/codefixes/fixUnusedIdentifier.ts", + "../services/codefixes/fixUnreachableCode.ts", + "../services/codefixes/fixUnusedLabel.ts", "../services/codefixes/fixJSDocTypes.ts", "../services/codefixes/fixAwaitInSyncFunction.ts", "../services/codefixes/disableJsDiagnostics.ts", @@ -112,10 +114,13 @@ "../services/codefixes/inferFromUsage.ts", "../services/codefixes/fixInvalidImportSyntax.ts", "../services/codefixes/fixStrictClassInitialization.ts", + "../services/codefixes/moduleSpecifiers.ts", "../services/codefixes/requireInTs.ts", "../services/codefixes/useDefaultImport.ts", + "../services/codefixes/fixAddModuleReferTypeMissingTypeof.ts", "../services/refactors/extractSymbol.ts", "../services/refactors/generateGetAccessorAndSetAccessor.ts", + "../services/refactors/moveToNewFile.ts", "../services/sourcemaps.ts", "../services/services.ts", "../services/breakpoints.ts", diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index fc1811420d3..b5c527aa246 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -181,6 +181,13 @@ namespace ts { "/a/b/foo.ts", "/a/b/foo.tsx", "/a/b/foo.d.ts", + "/c/d", + "/c/d.ts", + "/c/d.tsx", + "/c/d.d.ts", + "/c/d/index.ts", + "/c/d/index.tsx", + "/c/d/index.d.ts", "/a/b/foo/index.ts", "/a/b/foo/index.tsx", ]); diff --git a/src/harness/unittests/organizeImports.ts b/src/harness/unittests/organizeImports.ts index ebd5a7925a2..94f99856777 100644 --- a/src/harness/unittests/organizeImports.ts +++ b/src/harness/unittests/organizeImports.ts @@ -23,6 +23,15 @@ namespace ts { `import x from "./lib";`); }); + it("Sort - case-insensitive", () => { + assertSortsBefore( + `import y from "a";`, + `import x from "Z";`); + assertSortsBefore( + `import y from "A";`, + `import x from "z";`); + }); + function assertSortsBefore(importString1: string, importString2: string) { const [{moduleSpecifier: moduleSpecifier1}, {moduleSpecifier: moduleSpecifier2}] = parseImports(importString1, importString2); assert.equal(OrganizeImports.compareModuleSpecifiers(moduleSpecifier1, moduleSpecifier2), Comparison.LessThan); @@ -35,10 +44,10 @@ namespace ts { assert.isEmpty(OrganizeImports.coalesceImports([])); }); - it("Sort specifiers", () => { - const sortedImports = parseImports(`import { default as m, a as n, b, y, z as o } from "lib";`); + it("Sort specifiers - case-insensitive", () => { + const sortedImports = parseImports(`import { default as M, a as n, B, y, Z as O } from "lib";`); const actualCoalescedImports = OrganizeImports.coalesceImports(sortedImports); - const expectedCoalescedImports = parseImports(`import { a as n, b, default as m, y, z as o } from "lib";`); + const expectedCoalescedImports = parseImports(`import { a as n, B, default as M, y, Z as O } from "lib";`); assertListEqual(actualCoalescedImports, expectedCoalescedImports); }); @@ -165,6 +174,78 @@ namespace ts { }); }); + describe("Coalesce exports", () => { + it("No exports", () => { + assert.isEmpty(OrganizeImports.coalesceExports([])); + }); + + it("Sort specifiers - case-insensitive", () => { + const sortedExports = parseExports(`export { default as M, a as n, B, y, Z as O } from "lib";`); + const actualCoalescedExports = OrganizeImports.coalesceExports(sortedExports); + const expectedCoalescedExports = parseExports(`export { a as n, B, default as M, y, Z as O } from "lib";`); + assertListEqual(actualCoalescedExports, expectedCoalescedExports); + }); + + it("Combine namespace re-exports", () => { + const sortedExports = parseExports( + `export * from "lib";`, + `export * from "lib";`); + const actualCoalescedExports = OrganizeImports.coalesceExports(sortedExports); + const expectedCoalescedExports = parseExports(`export * from "lib";`); + assertListEqual(actualCoalescedExports, expectedCoalescedExports); + }); + + it("Combine property exports", () => { + const sortedExports = parseExports( + `export { x };`, + `export { y as z };`); + const actualCoalescedExports = OrganizeImports.coalesceExports(sortedExports); + const expectedCoalescedExports = parseExports(`export { x, y as z };`); + assertListEqual(actualCoalescedExports, expectedCoalescedExports); + }); + + it("Combine property re-exports", () => { + const sortedExports = parseExports( + `export { x } from "lib";`, + `export { y as z } from "lib";`); + const actualCoalescedExports = OrganizeImports.coalesceExports(sortedExports); + const expectedCoalescedExports = parseExports(`export { x, y as z } from "lib";`); + assertListEqual(actualCoalescedExports, expectedCoalescedExports); + }); + + it("Combine namespace re-export with property re-export", () => { + const sortedExports = parseExports( + `export * from "lib";`, + `export { y } from "lib";`); + const actualCoalescedExports = OrganizeImports.coalesceExports(sortedExports); + const expectedCoalescedExports = sortedExports; + assertListEqual(actualCoalescedExports, expectedCoalescedExports); + }); + + it("Combine many exports", () => { + const sortedExports = parseExports( + `export { x };`, + `export { y as w, z as default };`, + `export { w as q };`); + const actualCoalescedExports = OrganizeImports.coalesceExports(sortedExports); + const expectedCoalescedExports = parseExports( + `export { w as q, x, y as w, z as default };`); + assertListEqual(actualCoalescedExports, expectedCoalescedExports); + }); + + it("Combine many re-exports", () => { + const sortedExports = parseExports( + `export { x as a, y } from "lib";`, + `export * from "lib";`, + `export { z as b } from "lib";`); + const actualCoalescedExports = OrganizeImports.coalesceExports(sortedExports); + const expectedCoalescedExports = parseExports( + `export * from "lib";`, + `export { x as a, y, z as b } from "lib";`); + assertListEqual(actualCoalescedExports, expectedCoalescedExports); + }); + }); + describe("Baselines", () => { const libFile = { @@ -243,6 +324,15 @@ D(); import { F1, F2 } from "lib"; import * as NS from "lib"; import D from "lib"; +`, + }, + libFile); + + testOrganizeImports("Unused_Empty", + { + path: "/test.ts", + content: ` +import { } from "lib"; `, }, libFile); @@ -446,6 +536,154 @@ import { React, Other } from "react"; }, reactLibFile); + describe("Exports", () => { + + testOrganizeExports("MoveToTop", + { + path: "/test.ts", + content: ` +export { F1, F2 } from "lib"; +1; +export * from "lib"; +2; +`, + }, + libFile); + + // tslint:disable no-invalid-template-strings + testOrganizeExports("MoveToTop_Invalid", + { + path: "/test.ts", + content: ` +export { F1, F2 } from "lib"; +1; +export * from "lib"; +2; +export { b } from ${"`${'lib'}`"}; +export { a } from ${"`${'lib'}`"}; +export { D } from "lib"; +3; +`, + }, + libFile); + // tslint:enable no-invalid-template-strings + + testOrganizeExports("MoveToTop_WithImportsFirst", + { + path: "/test.ts", + content: ` +import { F1, F2 } from "lib"; +1; +export { F1, F2 } from "lib"; +2; +import * as NS from "lib"; +3; +export * from "lib"; +4; +F1(); F2(); NS.F1(); +`, + }, + libFile); + + testOrganizeExports("MoveToTop_WithExportsFirst", + { + path: "/test.ts", + content: ` +export { F1, F2 } from "lib"; +1; +import { F1, F2 } from "lib"; +2; +export * from "lib"; +3; +import * as NS from "lib"; +4; +F1(); F2(); NS.F1(); +`, + }, + libFile); + + testOrganizeExports("CoalesceMultipleModules", + { + path: "/test.ts", + content: ` +export { d } from "lib1"; +export { b } from "lib1"; +export { c } from "lib2"; +export { a } from "lib2"; +`, + }, + { path: "/lib1.ts", content: "export const b = 1, d = 2;" }, + { path: "/lib2.ts", content: "export const a = 3, c = 4;" }); + + testOrganizeExports("CoalesceTrivia", + { + path: "/test.ts", + content: ` +/*A*/export /*B*/ { /*C*/ F2 /*D*/ } /*E*/ from /*F*/ "lib" /*G*/;/*H*/ //I +/*J*/export /*K*/ { /*L*/ F1 /*M*/ } /*N*/ from /*O*/ "lib" /*P*/;/*Q*/ //R +`, + }, + libFile); + + testOrganizeExports("SortTrivia", + { + path: "/test.ts", + content: ` +/*A*/export /*B*/ * /*C*/ from /*D*/ "lib2" /*E*/;/*F*/ //G +/*H*/export /*I*/ * /*J*/ from /*K*/ "lib1" /*L*/;/*M*/ //N +`, + }, + { path: "/lib1.ts", content: "" }, + { path: "/lib2.ts", content: "" }); + + testOrganizeExports("SortHeaderComment", + { + path: "/test.ts", + content: ` +// Header +export * from "lib2"; +export * from "lib1"; +`, + }, + { path: "/lib1.ts", content: "" }, + { path: "/lib2.ts", content: "" }); + + testOrganizeExports("AmbientModule", + { + path: "/test.ts", + content: ` +declare module "mod" { + export { F1 } from "lib"; + export * from "lib"; + export { F2 } from "lib"; +} + `, + }, + libFile); + + testOrganizeExports("TopLevelAndAmbientModule", + { + path: "/test.ts", + content: ` +export { D } from "lib"; + +declare module "mod" { + export { F1 } from "lib"; + export * from "lib"; + export { F2 } from "lib"; +} + +export { E } from "lib"; +export * from "lib"; +`, + }, + libFile); + }); + + function testOrganizeExports(testName: string, testFile: TestFSWithWatch.File, ...otherFiles: TestFSWithWatch.File[]) { + testOrganizeImports(`${testName}.exports`, testFile, ...otherFiles); + } + function testOrganizeImports(testName: string, testFile: TestFSWithWatch.File, ...otherFiles: TestFSWithWatch.File[]) { it(testName, () => runBaseline(`organizeImports/${testName}.ts`, testFile, ...otherFiles)); } @@ -484,6 +722,13 @@ import { React, Other } from "react"; return imports; } + function parseExports(...exportStrings: string[]): ReadonlyArray { + const sourceFile = createSourceFile("a.ts", exportStrings.join("\n"), ScriptTarget.ES2015, /*setParentNodes*/ true, ScriptKind.TS); + const exports = filter(sourceFile.statements, isExportDeclaration); + assert.equal(exports.length, exportStrings.length); + return exports; + } + function assertEqual(node1?: Node, node2?: Node) { if (node1 === undefined) { assert.isUndefined(node2); @@ -525,6 +770,23 @@ import { React, Other } from "react"; assertEqual(is1.name, is2.name); assertEqual(is1.propertyName, is2.propertyName); break; + case SyntaxKind.ExportDeclaration: + const ed1 = node1 as ExportDeclaration; + const ed2 = node2 as ExportDeclaration; + assertEqual(ed1.exportClause, ed2.exportClause); + assertEqual(ed1.moduleSpecifier, ed2.moduleSpecifier); + break; + case SyntaxKind.NamedExports: + const ne1 = node1 as NamedExports; + const ne2 = node2 as NamedExports; + assertListEqual(ne1.elements, ne2.elements); + break; + case SyntaxKind.ExportSpecifier: + const es1 = node1 as ExportSpecifier; + const es2 = node2 as ExportSpecifier; + assertEqual(es1.name, es2.name); + assertEqual(es1.propertyName, es2.propertyName); + break; case SyntaxKind.Identifier: const id1 = node1 as Identifier; const id2 = node2 as Identifier; diff --git a/src/harness/unittests/paths.ts b/src/harness/unittests/paths.ts index 0cd90be0483..0b28bedc929 100644 --- a/src/harness/unittests/paths.ts +++ b/src/harness/unittests/paths.ts @@ -268,25 +268,25 @@ describe("core paths", () => { assert.strictEqual(ts.resolvePath("a", "b", "../c"), "a/c"); }); it("getPathRelativeTo", () => { - assert.strictEqual(ts.getRelativePath("/", "/", /*ignoreCase*/ false), ""); - assert.strictEqual(ts.getRelativePath("/a", "/a", /*ignoreCase*/ false), ""); - assert.strictEqual(ts.getRelativePath("/a/", "/a", /*ignoreCase*/ false), ""); - assert.strictEqual(ts.getRelativePath("/a", "/", /*ignoreCase*/ false), ".."); - assert.strictEqual(ts.getRelativePath("/a", "/b", /*ignoreCase*/ false), "../b"); - assert.strictEqual(ts.getRelativePath("/a/b", "/b", /*ignoreCase*/ false), "../../b"); - assert.strictEqual(ts.getRelativePath("/a/b/c", "/b", /*ignoreCase*/ false), "../../../b"); - assert.strictEqual(ts.getRelativePath("/a/b/c", "/b/c", /*ignoreCase*/ false), "../../../b/c"); - assert.strictEqual(ts.getRelativePath("/a/b/c", "/a/b", /*ignoreCase*/ false), ".."); - assert.strictEqual(ts.getRelativePath("c:", "d:", /*ignoreCase*/ false), "d:/"); - assert.strictEqual(ts.getRelativePath("file:///", "file:///", /*ignoreCase*/ false), ""); - assert.strictEqual(ts.getRelativePath("file:///a", "file:///a", /*ignoreCase*/ false), ""); - assert.strictEqual(ts.getRelativePath("file:///a/", "file:///a", /*ignoreCase*/ false), ""); - assert.strictEqual(ts.getRelativePath("file:///a", "file:///", /*ignoreCase*/ false), ".."); - assert.strictEqual(ts.getRelativePath("file:///a", "file:///b", /*ignoreCase*/ false), "../b"); - assert.strictEqual(ts.getRelativePath("file:///a/b", "file:///b", /*ignoreCase*/ false), "../../b"); - assert.strictEqual(ts.getRelativePath("file:///a/b/c", "file:///b", /*ignoreCase*/ false), "../../../b"); - assert.strictEqual(ts.getRelativePath("file:///a/b/c", "file:///b/c", /*ignoreCase*/ false), "../../../b/c"); - assert.strictEqual(ts.getRelativePath("file:///a/b/c", "file:///a/b", /*ignoreCase*/ false), ".."); - assert.strictEqual(ts.getRelativePath("file:///c:", "file:///d:", /*ignoreCase*/ false), "file:///d:/"); + assert.strictEqual(ts.getRelativePathFromDirectory("/", "/", /*ignoreCase*/ false), ""); + assert.strictEqual(ts.getRelativePathFromDirectory("/a", "/a", /*ignoreCase*/ false), ""); + assert.strictEqual(ts.getRelativePathFromDirectory("/a/", "/a", /*ignoreCase*/ false), ""); + assert.strictEqual(ts.getRelativePathFromDirectory("/a", "/", /*ignoreCase*/ false), ".."); + assert.strictEqual(ts.getRelativePathFromDirectory("/a", "/b", /*ignoreCase*/ false), "../b"); + assert.strictEqual(ts.getRelativePathFromDirectory("/a/b", "/b", /*ignoreCase*/ false), "../../b"); + assert.strictEqual(ts.getRelativePathFromDirectory("/a/b/c", "/b", /*ignoreCase*/ false), "../../../b"); + assert.strictEqual(ts.getRelativePathFromDirectory("/a/b/c", "/b/c", /*ignoreCase*/ false), "../../../b/c"); + assert.strictEqual(ts.getRelativePathFromDirectory("/a/b/c", "/a/b", /*ignoreCase*/ false), ".."); + assert.strictEqual(ts.getRelativePathFromDirectory("c:", "d:", /*ignoreCase*/ false), "d:/"); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///", "file:///", /*ignoreCase*/ false), ""); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///a", "file:///a", /*ignoreCase*/ false), ""); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///a/", "file:///a", /*ignoreCase*/ false), ""); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///a", "file:///", /*ignoreCase*/ false), ".."); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///a", "file:///b", /*ignoreCase*/ false), "../b"); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///a/b", "file:///b", /*ignoreCase*/ false), "../../b"); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///a/b/c", "file:///b", /*ignoreCase*/ false), "../../../b"); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///a/b/c", "file:///b/c", /*ignoreCase*/ false), "../../../b/c"); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///a/b/c", "file:///a/b", /*ignoreCase*/ false), ".."); + assert.strictEqual(ts.getRelativePathFromDirectory("file:///c:", "file:///d:", /*ignoreCase*/ false), "file:///d:/"); }); }); \ No newline at end of file diff --git a/src/harness/unittests/telemetry.ts b/src/harness/unittests/telemetry.ts index 2e3e299ac3b..53025e15a9c 100644 --- a/src/harness/unittests/telemetry.ts +++ b/src/harness/unittests/telemetry.ts @@ -42,7 +42,7 @@ namespace ts.projectSystem { const et = new TestServerEventManager([...files, notIncludedFile, tsconfig]); et.service.openClientFile(files[0].path); et.assertProjectInfoTelemetryEvent({ - fileStats: { ts: 2, tsx: 1, js: 1, jsx: 1, dts: 1 }, + fileStats: fileStats({ ts: 2, tsx: 1, js: 1, jsx: 1, dts: 1 }), compilerOptions, include: true, }); @@ -59,7 +59,6 @@ namespace ts.projectSystem { // TODO: Apparently compilerOptions is mutated, so have to repeat it here! et.assertProjectInfoTelemetryEvent({ - projectId: Harness.mockHash("/hunter2/foo.csproj"), compilerOptions: { strict: true }, compileOnSave: true, // These properties can't be present for an external project, so they are undefined instead of false. @@ -69,7 +68,7 @@ namespace ts.projectSystem { exclude: undefined, configFileName: "other", projectType: "external", - }); + }, "/hunter2/foo.csproj"); // Also test that opening an external project only sends an event once. @@ -202,7 +201,6 @@ namespace ts.projectSystem { const et = new TestServerEventManager([jsconfig, file]); et.service.openClientFile(file.path); et.assertProjectInfoTelemetryEvent({ - projectId: Harness.mockHash("/jsconfig.json"), fileStats: fileStats({ js: 1 }), compilerOptions: autoJsCompilerOptions, typeAcquisition: { @@ -211,7 +209,7 @@ namespace ts.projectSystem { exclude: false, }, configFileName: "jsconfig.json", - }); + }, "/jsconfig.json"); }); it("detects whether language service was disabled", () => { @@ -222,7 +220,6 @@ namespace ts.projectSystem { et.service.openClientFile(file.path); et.getEvent(server.ProjectLanguageServiceStateEvent); et.assertProjectInfoTelemetryEvent({ - projectId: Harness.mockHash("/jsconfig.json"), fileStats: fileStats({ js: 1 }), compilerOptions: autoJsCompilerOptions, configFileName: "jsconfig.json", @@ -232,11 +229,46 @@ namespace ts.projectSystem { exclude: false, }, languageServiceEnabled: false, + }, "/jsconfig.json"); + }); + + describe("open files telemetry", () => { + it("sends event for inferred project", () => { + const ajs = makeFile("/a.js", "// @ts-check\nconst x = 0;"); + const bjs = makeFile("/b.js"); + const et = new TestServerEventManager([ajs, bjs]); + + et.service.openClientFile(ajs.path); + et.assertOpenFileTelemetryEvent({ checkJs: true }); + + et.service.openClientFile(bjs.path); + et.assertOpenFileTelemetryEvent({ checkJs: false }); + + // No repeated send for opening a file seen before. + et.service.openClientFile(bjs.path); + et.assertNoOpenFilesTelemetryEvent(); + }); + + it("not for '.ts' file", () => { + const ats = makeFile("/a.ts", ""); + const et = new TestServerEventManager([ats]); + + et.service.openClientFile(ats.path); + et.assertNoOpenFilesTelemetryEvent(); + }); + + it("even for project with 'ts-check' in config", () => { + const file = makeFile("/a.js"); + const compilerOptions: CompilerOptions = { checkJs: true }; + const jsconfig = makeFile("/jsconfig.json", { compilerOptions }); + const et = new TestServerEventManager([jsconfig, file]); + et.service.openClientFile(file.path); + et.assertOpenFileTelemetryEvent({ checkJs: false }); }); }); }); function makeFile(path: string, content: {} = ""): File { - return { path, content: isString(content) ? "" : JSON.stringify(content) }; + return { path, content: isString(content) ? content : JSON.stringify(content) }; } } diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index 14b9ccdbfb8..61d8dc04e18 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -270,6 +270,35 @@ namespace ts { program.emit(program.getSourceFiles()[1], (p, s, bom) => host.writeFile(p, s, bom), /*cancellationToken*/ undefined, /*onlyDts*/ true, opts.transformers); return fs.readFileSync("/.src/index.d.ts").toString(); } + + // https://github.com/Microsoft/TypeScript/issues/24096 + testBaseline("transformAddCommentToArrowReturnValue", () => { + return transpileModule(`const foo = () => + void 0 +`, { + transformers: { + before: [addSyntheticComment], + }, + 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); + } + } + }); }); } diff --git a/src/harness/unittests/tsconfigParsing.ts b/src/harness/unittests/tsconfigParsing.ts index f1b4d526581..7a47481b88d 100644 --- a/src/harness/unittests/tsconfigParsing.ts +++ b/src/harness/unittests/tsconfigParsing.ts @@ -217,6 +217,29 @@ namespace ts { assertParseFileList(tsconfigWithExclude, "tsconfig.json", rootDir, allFiles, allFiles); }); + it("exclude declarationDir unless overridden", () => { + const tsconfigWithoutExclude = + `{ + "compilerOptions": { + "declarationDir": "declarations" + } + }`; + const tsconfigWithExclude = + `{ + "compilerOptions": { + "declarationDir": "declarations" + }, + "exclude": [ "types" ] + }`; + + const rootDir = "/"; + const allFiles = ["/declarations/a.d.ts", "/a.ts"]; + const expectedFiles = ["/a.ts"]; + + assertParseFileList(tsconfigWithoutExclude, "tsconfig.json", rootDir, allFiles, expectedFiles); + assertParseFileList(tsconfigWithExclude, "tsconfig.json", rootDir, allFiles, allFiles); + }); + it("implicitly exclude common package folders", () => { assertParseFileList( `{}`, diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index f54bd56f1ba..7a5f97b06d5 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -164,7 +164,7 @@ namespace ts.projectSystem { } export function fileStats(nonZeroStats: Partial): server.FileStats { - return { ts: 0, tsx: 0, dts: 0, js: 0, jsx: 0, ...nonZeroStats }; + return { ts: 0, tsx: 0, dts: 0, js: 0, jsx: 0, deferred: 0, ...nonZeroStats }; } export class TestServerEventManager { @@ -214,9 +214,9 @@ namespace ts.projectSystem { assert.equal(eventData.triggerFile, triggerFile); } - assertProjectInfoTelemetryEvent(partial: Partial, configFile?: string): void { - assert.deepEqual(this.getEvent(server.ProjectInfoTelemetryEvent), { - projectId: Harness.mockHash(configFile || "/tsconfig.json"), + assertProjectInfoTelemetryEvent(partial: Partial, configFile = "/tsconfig.json"): void { + assert.deepEqual(this.getEvent(server.ProjectInfoTelemetryEvent), { + projectId: sys.createSHA256Hash(configFile), fileStats: fileStats({ ts: 1 }), compilerOptions: {}, extends: false, @@ -236,6 +236,13 @@ namespace ts.projectSystem { ...partial, }); } + + assertOpenFileTelemetryEvent(info: server.OpenFileInfo): void { + assert.deepEqual(this.getEvent(server.OpenFileInfoTelemetryEvent), { info }); + } + assertNoOpenFilesTelemetryEvent(): void { + this.hasZeroEvent(server.OpenFileInfoTelemetryEvent); + } } class TestSession extends server.Session { @@ -2755,7 +2762,7 @@ namespace ts.projectSystem { const session = createSession(host, { canUseEvents: true, eventHandler: e => { - if (e.eventName === server.ConfigFileDiagEvent || e.eventName === server.ProjectsUpdatedInBackgroundEvent || e.eventName === server.ProjectInfoTelemetryEvent) { + if (e.eventName === server.ConfigFileDiagEvent || e.eventName === server.ProjectsUpdatedInBackgroundEvent || e.eventName === server.ProjectInfoTelemetryEvent || e.eventName === server.OpenFileInfoTelemetryEvent) { return; } assert.equal(e.eventName, server.ProjectLanguageServiceStateEvent); @@ -2807,7 +2814,7 @@ namespace ts.projectSystem { const session = createSession(host, { canUseEvents: true, eventHandler: e => { - if (e.eventName === server.ConfigFileDiagEvent || e.eventName === server.ProjectInfoTelemetryEvent) { + if (e.eventName === server.ConfigFileDiagEvent || e.eventName === server.ProjectInfoTelemetryEvent || e.eventName === server.OpenFileInfoTelemetryEvent) { return; } assert.equal(e.eventName, server.ProjectLanguageServiceStateEvent); @@ -6241,14 +6248,14 @@ namespace ts.projectSystem { function verifyNoCall(callback: CalledMaps) { const calledMap = calledMaps[callback]; - assert.equal(calledMap.size, 0, `${callback} shouldnt be called: ${arrayFrom(calledMap.keys())}`); + assert.equal(calledMap.size, 0, `${callback} shouldn't be called: ${arrayFrom(calledMap.keys())}`); } function verifyCalledOnEachEntry(callback: CalledMaps, expectedKeys: Map) { TestFSWithWatch.checkMultiMapKeyCount(callback, calledMaps[callback], expectedKeys); } - function verifyCalledOnEachEntryNTimes(callback: CalledMaps, expectedKeys: string[], nTimes: number) { + function verifyCalledOnEachEntryNTimes(callback: CalledMaps, expectedKeys: ReadonlyArray, nTimes: number) { TestFSWithWatch.checkMultiMapEachKeyWithCount(callback, calledMaps[callback], expectedKeys, nTimes); } @@ -6256,7 +6263,7 @@ namespace ts.projectSystem { iterateOnCalledMaps(key => verifyNoCall(key)); } - function verifyNoHostCallsExceptFileExistsOnce(expectedKeys: string[]) { + function verifyNoHostCallsExceptFileExistsOnce(expectedKeys: ReadonlyArray) { verifyCalledOnEachEntryNTimes(CalledMapsWithSingleArg.fileExists, expectedKeys, 1); verifyNoCall(CalledMapsWithSingleArg.directoryExists); verifyNoCall(CalledMapsWithSingleArg.getDirectories); @@ -8376,4 +8383,35 @@ new C();` verifyCompletionListWithNewFileInSubFolder(TestFSWithWatch.Tsc_WatchDirectory.DynamicPolling); }); }); + + describe("tsserverProjectSystem getEditsForFileRename", () => { + it("works for host implementing 'resolveModuleNames' and 'getResolvedModuleWithFailedLookupLocationsFromCache'", () => { + const userTs: File = { + path: "/user.ts", + content: 'import { x } from "./old";', + }; + + const host = createServerHost([userTs]); + const projectService = createProjectService(host); + projectService.openClientFile(userTs.path); + const project = first(projectService.inferredProjects); + + Debug.assert(!!project.resolveModuleNames); + + const edits = project.getLanguageService().getEditsForFileRename("/old.ts", "/new.ts", testFormatOptions); + assert.deepEqual>(edits, [{ + fileName: "/user.ts", + textChanges: [{ + span: textSpanFromSubstring(userTs.content, "./old"), + newText: "./new", + }], + }]); + }); + }); + + function textSpanFromSubstring(str: string, substring: string): TextSpan { + const start = str.indexOf(substring); + Debug.assert(start !== -1); + return createTextSpan(start, substring.length); + } } diff --git a/src/harness/vfs.ts b/src/harness/vfs.ts index 698c8abd477..34a48f59091 100644 --- a/src/harness/vfs.ts +++ b/src/harness/vfs.ts @@ -332,35 +332,20 @@ namespace vfs { } } - private _depth: string[] = []; - /** * Make a directory and all of its parent paths (if they don't exist). */ public mkdirpSync(path: string) { - try { - this._depth.push(path); - path = this._resolve(path); - this.mkdirSync(path); - } - catch (e) { - if (e.code === "ENOENT") { - if (this._depth.length > 10) { - console.log(`path: ${path}`); - console.log(`dirname: ${vpath.dirname(path)}`); - console.log(this._depth); - throw e; - } - this.mkdirpSync(vpath.dirname(path)); - this.mkdirSync(path); + path = this._resolve(path); + const result = this._walk(path, /*noFollow*/ true, (error, result) => { + if (error.code === "ENOENT") { + this._mkdir(result); + return "retry"; } - else if (e.code !== "EEXIST") { - throw e; - } - } - finally { - this._depth.pop(); - } + return "throw"; + }); + + if (!result.node) this._mkdir(result); } /** @@ -399,6 +384,14 @@ namespace vfs { // POSIX API (aligns with NodeJS "fs" module API) + /** + * Determines whether a path exists. + */ + public existsSync(path: string) { + const result = this._walk(this._resolve(path), /*noFollow*/ true, () => "stop"); + return result !== undefined && result.node !== undefined; + } + /** * Get file status. If `path` is a symbolic link, it is dereferenced. * @@ -464,9 +457,11 @@ namespace vfs { public mkdirSync(path: string) { if (this.isReadonly) throw createIOError("EROFS"); - const { parent, links, node: existingNode, basename } = this._walk(this._resolve(path), /*noFollow*/ true); - if (existingNode) throw createIOError("EEXIST"); + this._mkdir(this._walk(this._resolve(path), /*noFollow*/ true)); + } + private _mkdir({ parent, links, node: existingNode, basename }: WalkResult) { + if (existingNode) throw createIOError("EEXIST"); const time = this.time(); const node = this._mknod(parent ? parent.dev : ++devCount, S_IFDIR, /*mode*/ 0o777, time); this._addLink(parent, links, basename, node, time); @@ -810,17 +805,18 @@ namespace vfs { * @param path The path to follow. * @param noFollow A value indicating whether to *not* dereference a symbolic link at the * end of a path. - * @param allowPartial A value indicating whether to return a partial result if the node - * at the end of the path cannot be found. * * @link http://man7.org/linux/man-pages/man7/path_resolution.7.html */ - private _walk(path: string, noFollow?: boolean): WalkResult { + private _walk(path: string, noFollow?: boolean, onError?: (error: NodeJS.ErrnoException, fragment: WalkResult) => "retry" | "throw"): WalkResult; + private _walk(path: string, noFollow?: boolean, onError?: (error: NodeJS.ErrnoException, fragment: WalkResult) => "stop" | "retry" | "throw"): WalkResult | undefined; + private _walk(path: string, noFollow?: boolean, onError?: (error: NodeJS.ErrnoException, fragment: WalkResult) => "stop" | "retry" | "throw"): WalkResult | undefined { let links = this._getRootLinks(); let parent: DirectoryInode | undefined; let components = vpath.parse(path); let step = 0; let depth = 0; + let retry = false; while (true) { if (depth >= 40) throw createIOError("ELOOP"); const lastStep = step === components.length - 1; @@ -830,7 +826,8 @@ namespace vfs { return { realpath: vpath.format(components), basename, parent, links, node }; } if (node === undefined) { - throw createIOError("ENOENT"); + if (trapError(createIOError("ENOENT"), node)) continue; + return undefined; } if (isSymlink(node)) { const dirname = vpath.format(components.slice(0, step)); @@ -840,15 +837,30 @@ namespace vfs { components = vpath.parse(symlink).concat(components.slice(step + 1)); step = 0; depth++; + retry = false; continue; } if (isDirectory(node)) { links = this._getLinks(node); parent = node; step++; + retry = false; continue; } - throw createIOError("ENOTDIR"); + if (trapError(createIOError("ENOTDIR"), node)) continue; + return undefined; + } + + function trapError(error: NodeJS.ErrnoException, node?: Inode) { + const realpath = vpath.format(components.slice(0, step + 1)); + const basename = components[step]; + const result = !retry && onError ? onError(error, { realpath, basename, parent, links, node }) : "throw"; + if (result === "stop") return false; + if (result === "retry") { + retry = true; + return true; + } + throw error; } } @@ -857,8 +869,8 @@ namespace vfs { */ private _resolve(path: string) { return this._cwd - ? vpath.resolve(this._cwd, vpath.validate(path, vpath.ValidationFlags.RelativeOrAbsolute)) - : vpath.validate(path, vpath.ValidationFlags.Absolute); + ? vpath.resolve(this._cwd, vpath.validate(path, vpath.ValidationFlags.RelativeOrAbsolute | vpath.ValidationFlags.AllowWildcard)) + : vpath.validate(path, vpath.ValidationFlags.Absolute | vpath.ValidationFlags.AllowWildcard); } private _applyFiles(files: FileSet, dirname: string) { @@ -1118,6 +1130,7 @@ namespace vfs { export function createIOError(code: keyof typeof IOErrorMessages) { const err: NodeJS.ErrnoException = new Error(`${code}: ${IOErrorMessages[code]}`); err.code = code; + if (Error.captureStackTrace) Error.captureStackTrace(err, createIOError); return err; } diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index ef3d4955e42..96873f1c083 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -811,6 +811,10 @@ interface Array {}` return Harness.mockHash(s); } + createSHA256Hash(s: string): string { + return sys.createSHA256Hash(s); + } + watchFile(fileName: string, cb: FileWatcherCallback, pollingInterval: number) { if (this.dynamicPriorityWatchFile) { return this.dynamicPriorityWatchFile(fileName, cb, pollingInterval); diff --git a/src/harness/vpath.ts b/src/harness/vpath.ts index 31430b50e2b..6211fc9278a 100644 --- a/src/harness/vpath.ts +++ b/src/harness/vpath.ts @@ -18,7 +18,7 @@ namespace vpath { export import dirname = ts.getDirectoryPath; export import basename = ts.getBaseFileName; export import extname = ts.getAnyExtensionFromPath; - export import relative = ts.getRelativePath; + export import relative = ts.getRelativePathFromDirectory; export import beneath = ts.containsPath; export import changeExtension = ts.changeAnyExtension; export import isTypeScript = ts.hasTypeScriptFileExtension; @@ -26,7 +26,9 @@ namespace vpath { const invalidRootComponentRegExp = /^(?!(\/|\/\/\w+\/|[a-zA-Z]:\/?|)$)/; const invalidNavigableComponentRegExp = /[:*?"<>|]/; + const invalidNavigableComponentWithWildcardsRegExp = /[:"<>|]/; const invalidNonNavigableComponentRegExp = /^\.{1,2}$|[:*?"<>|]/; + const invalidNonNavigableComponentWithWildcardsRegExp = /^\.{1,2}$|[:"<>|]/; const extRegExp = /\.\w+$/; export const enum ValidationFlags { @@ -44,6 +46,7 @@ namespace vpath { AllowExtname = 1 << 8, AllowTrailingSeparator = 1 << 9, AllowNavigation = 1 << 10, + AllowWildcard = 1 << 11, /** Path must be a valid directory root */ Root = RequireRoot | AllowRoot | AllowTrailingSeparator, @@ -63,7 +66,9 @@ namespace vpath { const hasDirname = components.length > 2; const hasBasename = components.length > 1; const hasExtname = hasBasename && extRegExp.test(components[components.length - 1]); - const invalidComponentRegExp = flags & ValidationFlags.AllowNavigation ? invalidNavigableComponentRegExp : invalidNonNavigableComponentRegExp; + const invalidComponentRegExp = flags & ValidationFlags.AllowNavigation + ? flags & ValidationFlags.AllowWildcard ? invalidNavigableComponentWithWildcardsRegExp : invalidNavigableComponentRegExp + : flags & ValidationFlags.AllowWildcard ? invalidNonNavigableComponentWithWildcardsRegExp : invalidNonNavigableComponentRegExp; // Validate required components if (flags & ValidationFlags.RequireRoot && !hasRoot) return false; diff --git a/src/lib/es2018.regexp.d.ts b/src/lib/es2018.regexp.d.ts index 85e1bc909b5..2067b4846d7 100644 --- a/src/lib/es2018.regexp.d.ts +++ b/src/lib/es2018.regexp.d.ts @@ -8,4 +8,12 @@ interface RegExpExecArray { groups?: { [key: string]: string } +} + +interface RegExp { + /** + * Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression. + * Default is false. Read-only. + */ + readonly dotAll: boolean; } \ No newline at end of file diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 0364ba3402a..3607e3e8488 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1107,6 +1107,15 @@ + + + + + + + + + @@ -2043,6 +2052,15 @@ + + + + + + + + + @@ -2421,6 +2439,15 @@ + + + + + + + + + @@ -3054,15 +3081,6 @@ - - - - - - - - - @@ -3072,6 +3090,15 @@ + + + + + + + + + @@ -3144,6 +3171,15 @@ + + + + + + + + + @@ -3699,6 +3735,15 @@ + + + + + + + + + @@ -4302,6 +4347,15 @@ + + + + + + + + + @@ -5226,6 +5280,15 @@ + + + + + + + + + @@ -5598,6 +5661,15 @@ + + + + + + + + + @@ -5616,6 +5688,24 @@ + + + + + + + + + + + + + + + + + + @@ -6012,6 +6102,24 @@ + + + + + + + + + + + + + + + + + + @@ -6438,6 +6546,24 @@ + + + + + + + + + + + + + + + + + + @@ -6450,6 +6576,15 @@ + + + + + + + + + @@ -6459,6 +6594,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 0772c6551d1..f08745d21c6 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1107,6 +1107,15 @@ + + + + + + + + + @@ -2043,6 +2052,15 @@ + + + + + + + + + @@ -2421,6 +2439,15 @@ + + + + + + + + + @@ -3054,15 +3081,6 @@ - - - - - - - - - @@ -3072,6 +3090,15 @@ + + + + + + + + + @@ -3144,6 +3171,15 @@ + + + + + + + + + @@ -3699,6 +3735,15 @@ + + + + + + + + + @@ -4305,6 +4350,9 @@ + + + @@ -5232,6 +5280,15 @@ + + + + + + + + + @@ -5607,6 +5664,9 @@ + + + @@ -5628,6 +5688,24 @@ + + + + + + + + + + + + + + + + + + @@ -6024,6 +6102,24 @@ + + + + + + + + + + + + + + + + + + @@ -6450,6 +6546,24 @@ + + + + + + + + + + + + + + + + + + @@ -6462,6 +6576,15 @@ + + + + + + + + + @@ -6471,6 +6594,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1a0f4433a62..d64721cd90e 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1116,6 +1116,15 @@ + + + + + + + + + @@ -2052,6 +2061,15 @@ + + + + + + + + + @@ -2430,6 +2448,15 @@ + + + + + + + + + @@ -3063,15 +3090,6 @@ - - - - - - - - - @@ -3081,6 +3099,15 @@ + + + + + + + + + @@ -3153,6 +3180,15 @@ + + + + + + + + + @@ -3708,6 +3744,15 @@ + + + + + + + + + @@ -4314,6 +4359,9 @@ + + + @@ -5241,6 +5289,15 @@ + + + + + + + + + @@ -5616,6 +5673,9 @@ + + + @@ -5637,6 +5697,24 @@ + + + + + + + + + + + + + + + + + + @@ -6033,6 +6111,24 @@ + + + + + + + + + + + + + + + + + + @@ -6459,6 +6555,24 @@ + + + + + + + + + + + + + + + + + + @@ -6471,6 +6585,15 @@ + + + + + + + + + @@ -6480,6 +6603,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 9d3620e29e4..ea95d1bda8c 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1104,6 +1104,15 @@ + + + + + + + + + @@ -2040,6 +2049,15 @@ + + + + + + + + + @@ -2418,6 +2436,15 @@ + + + + + + + + + @@ -3051,15 +3078,6 @@ - - - - - - - - - @@ -3069,6 +3087,15 @@ + + + + + + + + + @@ -3141,6 +3168,15 @@ + + + + + + + + + @@ -3696,6 +3732,15 @@ + + + + + + + + + @@ -4302,6 +4347,9 @@ + + + @@ -5229,6 +5277,15 @@ + + + + + + + + + @@ -5604,6 +5661,9 @@ + + + @@ -5625,6 +5685,24 @@ + + + + + + + + + + + + + + + + + + @@ -6018,6 +6096,24 @@ + + + + + + + + + + + + + + + + + + @@ -6444,6 +6540,24 @@ + + + + + + + + + + + + + + + + + + @@ -6456,6 +6570,15 @@ + + + + + + + + + @@ -6465,6 +6588,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index b6d30cd95f8..7a76969651e 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1017,6 +1017,15 @@ + + + + + + + + + @@ -1116,6 +1125,15 @@ + + + + + + + + + @@ -2052,6 +2070,15 @@ + + + + + + + + + @@ -2430,6 +2457,15 @@ + + + + + + + + + @@ -3063,15 +3099,6 @@ - - - - - - - - - @@ -3081,6 +3108,15 @@ + + + + + + + + + @@ -3153,6 +3189,15 @@ + + + + + + + + + @@ -3708,6 +3753,15 @@ + + + + + + + + + @@ -4314,6 +4368,9 @@ + + + @@ -5241,6 +5298,15 @@ + + + + + + + + + @@ -5616,6 +5682,9 @@ + + + @@ -5637,6 +5706,24 @@ + + + + + + + + + + + + + + + + + + @@ -6033,6 +6120,24 @@ + + + + + + + + + + + + + + + + + + @@ -6459,6 +6564,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -6471,6 +6600,15 @@ + + + + + + + + + @@ -6480,6 +6618,21 @@ + + + + + + + + + + + + + + + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 83c9542ac40..e880c4493a9 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1017,6 +1017,15 @@ + + + + + + + + + @@ -1116,6 +1125,15 @@ + + + + + + + + + @@ -2052,6 +2070,15 @@ + + + + + + + + + @@ -2430,6 +2457,15 @@ + + + + + + + + + @@ -3063,15 +3099,6 @@ - - - - - - - - - @@ -3081,6 +3108,15 @@ + + + + + + + + + @@ -3153,6 +3189,15 @@ + + + + + + + + + @@ -3708,6 +3753,15 @@ + + + + + + + + + @@ -4314,6 +4368,9 @@ + + + @@ -5241,6 +5298,15 @@ + + + + + + + + + @@ -5616,6 +5682,9 @@ + + + @@ -5637,6 +5706,24 @@ + + + + + + + + + + + + + + + + + + @@ -6033,6 +6120,24 @@ + + + + + + + + + + + + + + + + + + @@ -6459,6 +6564,24 @@ + + + + + + + + + + + + + + + + + + @@ -6471,6 +6594,15 @@ + + + + + + + + + @@ -6480,6 +6612,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1a9638ca02d..4f11a5ceaf9 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1107,6 +1107,15 @@ + + + + + + + + + @@ -2043,6 +2052,15 @@ + + + + + + + + + @@ -2421,6 +2439,15 @@ + + + + + + + + + @@ -3054,15 +3081,6 @@ - - - - - - - - - @@ -3072,6 +3090,15 @@ + + + + + + + + + @@ -3144,6 +3171,15 @@ + + + + + + + + + @@ -3699,6 +3735,15 @@ + + + + + + + + + @@ -4305,6 +4350,9 @@ + + + @@ -5232,6 +5280,15 @@ + + + + + + + + + @@ -5607,6 +5664,9 @@ + + + @@ -5628,6 +5688,24 @@ + + + + + + + + + + + + + + + + + + @@ -6024,6 +6102,24 @@ + + + + + + + + + + + + + + + + + + @@ -6450,6 +6546,24 @@ + + + + + + + + + + + + + + + + + + @@ -6462,6 +6576,15 @@ + + + + + + + + + @@ -6471,6 +6594,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 4b662f5b9c3..d034fc6882f 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1107,6 +1107,15 @@ + + + + + + + + + @@ -2043,6 +2052,15 @@ + + + + + + + + + @@ -2421,6 +2439,15 @@ + + + + + + + + + @@ -3054,15 +3081,6 @@ - - - - - - - - - @@ -3072,6 +3090,15 @@ + + + + + + + + + @@ -3144,6 +3171,15 @@ + + + + + + + + + @@ -3699,6 +3735,15 @@ + + + + + + + + + @@ -4305,6 +4350,9 @@ + + + @@ -5232,6 +5280,15 @@ + + + + + + + + + @@ -5607,6 +5664,9 @@ + + + @@ -5628,6 +5688,24 @@ + + + + + + + + + + + + + + + + + + @@ -6024,6 +6102,24 @@ + + + + + + + + + + + + + + + + + + @@ -6450,6 +6546,24 @@ + + + + + + + + + + + + + + + + + + @@ -6462,6 +6576,15 @@ + + + + + + + + + @@ -6471,6 +6594,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 9d97508babb..7c6b790800a 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1107,6 +1107,15 @@ + + + + + + + + + @@ -2043,6 +2052,15 @@ + + + + + + + + + @@ -2421,6 +2439,15 @@ + + + + + + + + + @@ -2523,6 +2550,9 @@ + + + @@ -2556,6 +2586,9 @@ + + + @@ -3048,15 +3081,6 @@ - - - - - - - - - @@ -3066,6 +3090,15 @@ + + + + + + + + + @@ -3138,6 +3171,15 @@ + + + + + + + + + @@ -3693,6 +3735,15 @@ + + + + + + + + + @@ -4296,6 +4347,15 @@ + + + + + + + + + @@ -5220,6 +5280,15 @@ + + + + + + + + + @@ -5592,6 +5661,15 @@ + + + + + + + + + @@ -5610,6 +5688,24 @@ + + + + + + + + + + + + + + + + + + @@ -6006,6 +6102,24 @@ + + + + + + + + + + + + + + + + + + @@ -6432,6 +6546,24 @@ + + + + + + + + + + + + + + + + + + @@ -6444,6 +6576,15 @@ + + + + + + + + + @@ -6453,6 +6594,15 @@ + + + + + + + + + @@ -7443,6 +7593,9 @@ + + + @@ -9387,6 +9540,9 @@ + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 6f596916ae7..50dcbfc1f8e 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1097,6 +1097,15 @@ + + + + + + + + + @@ -2033,6 +2042,15 @@ + + + + + + + + + @@ -2411,6 +2429,15 @@ + + + + + + + + + @@ -3044,15 +3071,6 @@ - - - - - - - - - @@ -3062,6 +3080,15 @@ + + + + + + + + + @@ -3134,6 +3161,15 @@ + + + + + + + + + @@ -3689,6 +3725,15 @@ + + + + + + + + + @@ -4295,6 +4340,9 @@ + + + @@ -5222,6 +5270,15 @@ + + + + + + + + + @@ -5597,6 +5654,9 @@ + + + @@ -5618,6 +5678,24 @@ + + + + + + + + + + + + + + + + + + @@ -6011,6 +6089,24 @@ + + + + + + + + + + + + + + + + + + @@ -6437,6 +6533,24 @@ + + + + + + + + + + + + + + + + + + @@ -6449,6 +6563,15 @@ + + + + + + + + + @@ -6458,6 +6581,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 5d69f25ad5d..3bc6e8db18b 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -998,6 +998,15 @@ + + + + + + + + + @@ -1097,6 +1106,15 @@ + + + + + + + + + @@ -2033,6 +2051,15 @@ + + + + + + + + + @@ -2411,6 +2438,15 @@ + + + + + + + + + @@ -3044,15 +3080,6 @@ - - - - - - - - - @@ -3062,6 +3089,15 @@ + + + + + + + + + @@ -3134,6 +3170,15 @@ + + + + + + + + + @@ -3689,6 +3734,15 @@ + + + + + + + + + @@ -4295,6 +4349,9 @@ + + + @@ -5222,6 +5279,15 @@ + + + + + + + + + @@ -5597,6 +5663,9 @@ + + + @@ -5618,6 +5687,24 @@ + + + + + + + + + + + + + + + + + + @@ -6011,6 +6098,24 @@ + + + + + + + + + + + + + + + + + + @@ -6437,6 +6542,24 @@ + + + + + + + + + + + + + + + + + + @@ -6449,6 +6572,15 @@ + + + + + + + + + @@ -6458,6 +6590,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 055e897855c..bdc5b984f48 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1106,6 +1106,15 @@ + + + + + + + + + @@ -2042,6 +2051,15 @@ + + + + + + + + + @@ -2420,6 +2438,15 @@ + + + + + + + + + @@ -3053,15 +3080,6 @@ - - - - - - - - - @@ -3071,6 +3089,15 @@ + + + + + + + + + @@ -3143,6 +3170,15 @@ + + + + + + + + + @@ -3698,6 +3734,15 @@ + + + + + + + + + @@ -4304,6 +4349,9 @@ + + + @@ -5231,6 +5279,15 @@ + + + + + + + + + @@ -5606,6 +5663,9 @@ + + + @@ -5627,6 +5687,24 @@ + + + + + + + + + + + + + + + + + + @@ -6023,6 +6101,24 @@ + + + + + + + + + + + + + + + + + + @@ -6449,6 +6545,24 @@ + + + + + + + + + + + + + + + + + + @@ -6461,6 +6575,15 @@ + + + + + + + + + @@ -6470,6 +6593,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 19679bd8c21..e279a6d066c 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1100,6 +1100,15 @@ + + + + + + + + + @@ -2036,6 +2045,15 @@ + + + + + + + + + @@ -2414,6 +2432,15 @@ + + + + + + + + + @@ -3047,15 +3074,6 @@ - - - - - - - - - @@ -3065,6 +3083,15 @@ + + + + + + + + + @@ -3137,6 +3164,15 @@ + + + + + + + + + @@ -3692,6 +3728,15 @@ + + + + + + + + + @@ -4298,6 +4343,9 @@ + + + @@ -5225,6 +5273,15 @@ + + + + + + + + + @@ -5600,6 +5657,9 @@ + + + @@ -5621,6 +5681,24 @@ + + + + + + + + + + + + + + + + + + @@ -6017,6 +6095,24 @@ + + + + + + + + + + + + + + + + + + @@ -6443,6 +6539,24 @@ + + + + + + + + + + + + + + + + + + @@ -6455,6 +6569,15 @@ + + + + + + + + + @@ -6464,6 +6587,15 @@ + + + + + + + + + diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 2bc61c67210..bb3560cbde5 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -6,6 +6,7 @@ namespace ts.server { export const ConfigFileDiagEvent = "configFileDiag"; export const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; export const ProjectInfoTelemetryEvent = "projectInfo"; + export const OpenFileInfoTelemetryEvent = "openFileInfo"; // tslint:enable variable-name export interface ProjectsUpdatedInBackgroundEvent { @@ -55,6 +56,20 @@ namespace ts.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. + */ + export interface OpenFileInfoTelemetryEvent { + readonly eventName: typeof OpenFileInfoTelemetryEvent; + readonly data: OpenFileInfoTelemetryEventData; + } + + export interface OpenFileInfoTelemetryEventData { + readonly info: OpenFileInfo; + } + export interface ProjectInfoTypeAcquisitionData { readonly enable: boolean; // Actual values of include/exclude entries are scrubbed. @@ -68,9 +83,14 @@ namespace ts.server { readonly ts: number; readonly tsx: number; readonly dts: number; + readonly deferred: number; } - export type ProjectServiceEvent = ProjectsUpdatedInBackgroundEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent; + export interface OpenFileInfo { + readonly checkJs: boolean; + } + + export type ProjectServiceEvent = ProjectsUpdatedInBackgroundEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; export type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void; @@ -325,6 +345,9 @@ namespace ts.server { * Container of all known scripts */ private readonly filenameToScriptInfo = createMap(); + // Set of all '.js' files ever opened. + private readonly allJsFilesForOpenFileTelemetry = createMap(); + /** * Map to the real path of the infos */ @@ -1406,12 +1429,12 @@ namespace ts.server { } this.seenProjects.set(projectKey, true); - if (!this.eventHandler) { + if (!this.eventHandler || !this.host.createSHA256Hash) { return; } const data: ProjectInfoTelemetryEventData = { - projectId: this.host.createHash(projectKey), + projectId: this.host.createSHA256Hash(projectKey), fileStats: countEachFileTypes(project.getScriptInfos()), compilerOptions: convertCompilerOptionsForTelemetry(project.getCompilationSettings()), typeAcquisition: convertTypeAcquisition(project.getTypeAcquisition()), @@ -2095,9 +2118,19 @@ namespace ts.server { this.printProjects(); + this.telemetryOnOpenFile(info); return { configFileName, configFileErrors }; } + private telemetryOnOpenFile(scriptInfo: ScriptInfo): void { + if (this.syntaxOnly || !this.eventHandler || !scriptInfo.isJavaScript() || !addToSeen(this.allJsFilesForOpenFileTelemetry, scriptInfo.path)) { + return; + } + + const info: OpenFileInfo = { checkJs: !!scriptInfo.getDefaultProject().getSourceFile(scriptInfo.path).checkJsDirective }; + this.eventHandler({ eventName: OpenFileInfoTelemetryEvent, data: { info } }); + } + /** * Close file whose contents is managed by the client * @param filename is absolute pathname diff --git a/src/server/project.ts b/src/server/project.ts index 328d41649ca..754d061235d 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -6,9 +6,12 @@ namespace ts.server { External } + /* @internal */ + export type Mutable = { -readonly [K in keyof T]: T[K]; }; + /* @internal */ export function countEachFileTypes(infos: ScriptInfo[]): FileStats { - const result = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0 }; + const result: Mutable = { js: 0, jsx: 0, ts: 0, tsx: 0, dts: 0, deferred: 0 }; for (const info of infos) { switch (info.scriptKind) { case ScriptKind.JS: @@ -25,6 +28,9 @@ namespace ts.server { case ScriptKind.TSX: result.tsx += 1; break; + case ScriptKind.Deferred: + result.deferred += 1; + break; } } return result; @@ -352,6 +358,10 @@ namespace ts.server { return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames); } + getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations { + return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile); + } + resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[] { return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); } @@ -958,7 +968,7 @@ namespace ts.server { return this.missingFilesMap && this.missingFilesMap.has(path); } - getScriptInfoForNormalizedPath(fileName: NormalizedPath) { + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo | undefined { const scriptInfo = this.projectService.getScriptInfoForPath(this.toPath(fileName)); if (scriptInfo && !scriptInfo.isAttached(this)) { return Errors.ThrowProjectDoesNotContainDocument(fileName, this); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 289478e7453..20854c7597b 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2682,6 +2682,7 @@ namespace ts.server.protocol { */ readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; + readonly allowTextChangesInNewFiles?: boolean; } export interface CompilerOptions { diff --git a/src/server/session.ts b/src/server/session.ts index 8d6defa1562..40f26785113 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -665,9 +665,8 @@ namespace ts.server { if (simplifiedResult) { return this.mapDefinitionInfo(definitions, project); } - else { - return definitions; - } + + return definitions.map(Session.mapToOriginalLocation); } private getDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan { @@ -691,13 +690,37 @@ namespace ts.server { }; } - return definitionAndBoundSpan; + return { + ...definitionAndBoundSpan, + definitions: definitionAndBoundSpan.definitions.map(Session.mapToOriginalLocation) + }; } private mapDefinitionInfo(definitions: ReadonlyArray, project: Project): ReadonlyArray { return definitions.map(def => this.toFileSpan(def.fileName, def.textSpan, project)); } + /* + * When we map a .d.ts location to .ts, Visual Studio gets confused because there's no associated Roslyn Document in + * the same project which corresponds to the file. VS Code has no problem with this, and luckily we have two protocols. + * This retains the existing behavior for the "simplified" (VS Code) protocol but stores the .d.ts location in a + * set of additional fields, and does the reverse for VS (store the .d.ts location where + * it used to be and stores the .ts location in the additional fields). + */ + private static mapToOriginalLocation(def: T): T { + if (def.originalFileName) { + Debug.assert(def.originalTextSpan !== undefined, "originalTextSpan should be present if originalFileName is"); + return { + ...def, + fileName: def.originalFileName, + textSpan: def.originalTextSpan, + targetFileName: def.fileName, + targetTextSpan: def.textSpan + }; + } + return def; + } + private toFileSpan(fileName: string, textSpan: TextSpan, project: Project): protocol.FileSpan { const ls = project.getLanguageService(); const start = ls.toLineColumnOffset(fileName, textSpan.start); @@ -732,9 +755,8 @@ namespace ts.server { if (simplifiedResult) { return implementations.map(({ fileName, textSpan }) => this.toFileSpan(fileName, textSpan, project)); } - else { - return implementations; - } + + return implementations.map(Session.mapToOriginalLocation); } private getOccurrences(args: protocol.FileLocationRequestArgs): ReadonlyArray { @@ -1744,11 +1766,17 @@ namespace ts.server { return textChanges.map(change => this.mapTextChangesToCodeEditsUsingScriptinfo(change, project.getScriptInfoForNormalizedPath(toNormalizedPath(change.fileName)))); } - private mapTextChangesToCodeEditsUsingScriptinfo(textChanges: FileTextChanges, scriptInfo: ScriptInfo): protocol.FileCodeEdits { - return { - fileName: textChanges.fileName, - textChanges: textChanges.textChanges.map(textChange => this.convertTextChangeToCodeEdit(textChange, scriptInfo)) - }; + private mapTextChangesToCodeEditsUsingScriptinfo(textChanges: FileTextChanges, scriptInfo: ScriptInfo | undefined): protocol.FileCodeEdits { + Debug.assert(!!textChanges.isNewFile === !scriptInfo); + if (scriptInfo) { + return { + fileName: textChanges.fileName, + textChanges: textChanges.textChanges.map(textChange => this.convertTextChangeToCodeEdit(textChange, scriptInfo)) + }; + } + else { + return this.convertNewFileTextChangeToCodeEdit(textChanges); + } } private convertTextChangeToCodeEdit(change: TextChange, scriptInfo: ScriptInfo): protocol.CodeEdit { @@ -1759,6 +1787,13 @@ namespace ts.server { }; } + private convertNewFileTextChangeToCodeEdit(textChanges: FileTextChanges): protocol.FileCodeEdits { + Debug.assert(textChanges.textChanges.length === 1); + const change = first(textChanges.textChanges); + Debug.assert(change.span.start === 0 && change.span.length === 0); + return { fileName: textChanges.fileName, textChanges: [{ start: { line: 0, offset: 0 }, end: { line: 0, offset: 0 }, newText: change.newText }] }; + } + private getBraceMatching(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.TextSpan[] | TextSpan[] { const { file, languageService } = this.getFileAndLanguageServiceForSyntacticOperation(args); const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file); diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index 71ff00e6ac1..8ae6974baf0 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -101,6 +101,8 @@ "../services/codefixes/fixExtendsInterfaceBecomesImplements.ts", "../services/codefixes/fixForgottenThisPropertyAccess.ts", "../services/codefixes/fixUnusedIdentifier.ts", + "../services/codefixes/fixUnreachableCode.ts", + "../services/codefixes/fixUnusedLabel.ts", "../services/codefixes/fixJSDocTypes.ts", "../services/codefixes/fixAwaitInSyncFunction.ts", "../services/codefixes/disableJsDiagnostics.ts", @@ -108,10 +110,13 @@ "../services/codefixes/inferFromUsage.ts", "../services/codefixes/fixInvalidImportSyntax.ts", "../services/codefixes/fixStrictClassInitialization.ts", + "../services/codefixes/moduleSpecifiers.ts", "../services/codefixes/requireInTs.ts", "../services/codefixes/useDefaultImport.ts", + "../services/codefixes/fixAddModuleReferTypeMissingTypeof.ts", "../services/refactors/extractSymbol.ts", "../services/refactors/generateGetAccessorAndSetAccessor.ts", + "../services/refactors/moveToNewFile.ts", "../services/sourcemaps.ts", "../services/services.ts", "../services/breakpoints.ts", diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 95489ff0ea3..922af11e879 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -107,6 +107,8 @@ "../services/codefixes/fixExtendsInterfaceBecomesImplements.ts", "../services/codefixes/fixForgottenThisPropertyAccess.ts", "../services/codefixes/fixUnusedIdentifier.ts", + "../services/codefixes/fixUnreachableCode.ts", + "../services/codefixes/fixUnusedLabel.ts", "../services/codefixes/fixJSDocTypes.ts", "../services/codefixes/fixAwaitInSyncFunction.ts", "../services/codefixes/disableJsDiagnostics.ts", @@ -114,10 +116,13 @@ "../services/codefixes/inferFromUsage.ts", "../services/codefixes/fixInvalidImportSyntax.ts", "../services/codefixes/fixStrictClassInitialization.ts", + "../services/codefixes/moduleSpecifiers.ts", "../services/codefixes/requireInTs.ts", "../services/codefixes/useDefaultImport.ts", + "../services/codefixes/fixAddModuleReferTypeMissingTypeof.ts", "../services/refactors/extractSymbol.ts", "../services/refactors/generateGetAccessorAndSetAccessor.ts", + "../services/refactors/moveToNewFile.ts", "../services/sourcemaps.ts", "../services/services.ts", "../services/breakpoints.ts", diff --git a/src/server/typingsCache.ts b/src/server/typingsCache.ts index c255757481f..7440735ecb2 100644 --- a/src/server/typingsCache.ts +++ b/src/server/typingsCache.ts @@ -11,7 +11,7 @@ namespace ts.server { enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray): void; attach(projectService: ProjectService): void; onProjectClosed(p: Project): void; - readonly globalTypingsCacheLocation: string; + readonly globalTypingsCacheLocation: string | undefined; } export const nullTypingsInstaller: ITypingsInstaller = { diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index faab2b08db6..6815be9863d 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -41,7 +41,7 @@ namespace ts.BreakpointResolver { } function textSpanEndingAtNextToken(startNode: Node, previousTokenToFindNextEndToken: Node): TextSpan { - return textSpan(startNode, findNextToken(previousTokenToFindNextEndToken, previousTokenToFindNextEndToken.parent)); + return textSpan(startNode, findNextToken(previousTokenToFindNextEndToken, previousTokenToFindNextEndToken.parent, sourceFile)); } function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan { @@ -60,7 +60,7 @@ namespace ts.BreakpointResolver { } function spanInNextNode(node: Node): TextSpan { - return spanInNode(findNextToken(node, node.parent)); + return spanInNode(findNextToken(node, node.parent, sourceFile)); } function spanInNode(node: Node): TextSpan { diff --git a/src/services/classifier.ts b/src/services/classifier.ts index 89c96a45021..9719a1ccdad 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -706,16 +706,17 @@ namespace ts { break; case SyntaxKind.JSDocTemplateTag: processJSDocTemplateTag(tag); + pos = tag.end; break; case SyntaxKind.JSDocTypeTag: processElement((tag).typeExpression); + pos = tag.end; break; case SyntaxKind.JSDocReturnTag: processElement((tag).typeExpression); + pos = tag.end; break; } - - pos = tag.end; } } diff --git a/src/services/codefixes/annotateWithTypeFromJSDoc.ts b/src/services/codefixes/annotateWithTypeFromJSDoc.ts index 5b809452677..7b664678436 100644 --- a/src/services/codefixes/annotateWithTypeFromJSDoc.ts +++ b/src/services/codefixes/annotateWithTypeFromJSDoc.ts @@ -43,7 +43,7 @@ namespace ts.codefix { if (isFunctionLikeDeclaration(decl) && (getJSDocReturnType(decl) || decl.parameters.some(p => !!getJSDocType(p)))) { if (!decl.typeParameters) { const typeParameters = getJSDocTypeParameterDeclarations(decl); - if (typeParameters) changes.insertTypeParameters(sourceFile, decl, typeParameters); + if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } const needParens = isArrowFunction(decl) && !findChildOfKind(decl, SyntaxKind.OpenParenToken, sourceFile); if (needParens) changes.insertNodeBefore(sourceFile, first(decl.parameters), createToken(SyntaxKind.OpenParenToken)); diff --git a/src/services/codefixes/convertToEs6Module.ts b/src/services/codefixes/convertToEs6Module.ts index b496697d541..92a14b1d20d 100644 --- a/src/services/codefixes/convertToEs6Module.ts +++ b/src/services/codefixes/convertToEs6Module.ts @@ -233,7 +233,7 @@ namespace ts.codefix { Debug.assertNever(prop); } }); - return statements && [statements, true]; + return statements && [statements, false]; } function convertNamedExport( @@ -487,15 +487,6 @@ namespace ts.codefix { : makeImport(/*name*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier); } - function makeImport(name: Identifier | undefined, namedImports: ReadonlyArray | undefined, moduleSpecifier: StringLiteralLike): ImportDeclaration { - return makeImportDeclaration(name, namedImports, moduleSpecifier); - } - - export function makeImportDeclaration(name: Identifier, namedImports: ReadonlyArray | undefined, moduleSpecifier: Expression) { - const importClause = (name || namedImports) && createImportClause(name, namedImports && createNamedImports(namedImports)); - return createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, moduleSpecifier); - } - function makeImportSpecifier(propertyName: string | undefined, name: string): ImportSpecifier { return createImportSpecifier(propertyName !== undefined && propertyName !== name ? createIdentifier(propertyName) : undefined, createIdentifier(name)); } diff --git a/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts new file mode 100644 index 00000000000..15d282342ea --- /dev/null +++ b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts @@ -0,0 +1,30 @@ +/* @internal */ +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]; + registerCodeFix({ + errorCodes, + getCodeActions: context => { + const { sourceFile, span } = context; + const importType = getImportTypeNode(sourceFile, span.start); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, importType)); + return [createCodeFixAction(fixId, changes, Diagnostics.Add_missing_typeof, fixId, Diagnostics.Add_missing_typeof)]; + }, + fixIds: [fixId], + getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => + doChange(changes, context.sourceFile, getImportTypeNode(diag.file, diag.start!))), + }); + + function getImportTypeNode(sourceFile: SourceFile, pos: number): ImportTypeNode { + const token = getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + Debug.assert(token.kind === SyntaxKind.ImportKeyword); + Debug.assert(token.parent.kind === SyntaxKind.ImportType); + return token.parent; + } + + function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importType: ImportTypeNode) { + const newTypeNode = updateImportTypeNode(importType, importType.argument, importType.qualifier, importType.typeArguments, /* isTypeOf */ true); + changes.replaceNode(sourceFile, importType, newTypeNode); + } +} diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts index 50bf41360bc..89a9aca461c 100644 --- a/src/services/codefixes/fixInvalidImportSyntax.ts +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -28,7 +28,7 @@ namespace ts.codefix { const variations: CodeFixAction[] = []; // import Bluebird from "bluebird"; - variations.push(createAction(context, sourceFile, node, makeImportDeclaration(namespace.name, /*namedImports*/ undefined, node.moduleSpecifier))); + variations.push(createAction(context, sourceFile, node, makeImport(namespace.name, /*namedImports*/ undefined, node.moduleSpecifier))); if (getEmitModuleKind(opts) === ModuleKind.CommonJS) { // import Bluebird = require("bluebird"); diff --git a/src/services/codefixes/fixUnreachableCode.ts b/src/services/codefixes/fixUnreachableCode.ts new file mode 100644 index 00000000000..96241c2263c --- /dev/null +++ b/src/services/codefixes/fixUnreachableCode.ts @@ -0,0 +1,76 @@ +/* @internal */ +namespace ts.codefix { + const fixId = "fixUnreachableCode"; + const errorCodes = [Diagnostics.Unreachable_code_detected.code]; + registerCodeFix({ + errorCodes, + getCodeActions(context) { + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, context.span.start)); + 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)), + }); + + function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, start: number): void { + const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + 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)); + } + 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); + } + } + } + + 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); + } + } + + 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])); + } +} diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 5b411bedde4..f22a87f102e 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -19,7 +19,7 @@ namespace ts.codefix { const changes = textChanges.ChangeTracker.with(context, t => t.deleteNode(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 => tryDeleteFullDestructure(t, sourceFile, context.span.start)); + const delDestructure = textChanges.ChangeTracker.with(context, t => tryDeleteFullDestructure(t, sourceFile, context.span.start, /*deleted*/ undefined)); if (delDestructure.length) { return [createCodeFixAction(fixName, delDestructure, Diagnostics.Remove_destructuring, fixIdDelete, Diagnostics.Delete_all_unused_declarations)]; } @@ -27,7 +27,7 @@ namespace ts.codefix { const token = getToken(sourceFile, textSpanEnd(context.span)); const result: CodeFixAction[] = []; - const deletion = textChanges.ChangeTracker.with(context, t => tryDeleteDeclaration(t, sourceFile, token)); + const deletion = textChanges.ChangeTracker.with(context, t => tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined)); if (deletion.length) { result.push(createCodeFixAction(fixName, deletion, [Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, Diagnostics.Delete_all_unused_declarations)); } @@ -40,30 +40,37 @@ namespace ts.codefix { return result; }, fixIds: [fixIdPrefix, fixIdDelete], - getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => { - const { sourceFile } = context; - const token = findPrecedingToken(textSpanEnd(diag), diag.file!); - switch (context.fixId) { - case fixIdPrefix: - if (isIdentifier(token) && canPrefix(token)) { - tryPrefixDeclaration(changes, diag.code, sourceFile, token); - } - break; - case fixIdDelete: - const importDecl = tryGetFullImport(diag.file!, diag.start!); - if (importDecl) { - changes.deleteNode(sourceFile, importDecl); - } - else { - if (!tryDeleteFullDestructure(changes, sourceFile, diag.start!)) { - tryDeleteDeclaration(changes, sourceFile, token); + getAllCodeActions: context => { + // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors. + const deleted = new NodeSet(); + return codeFixAll(context, errorCodes, (changes, diag) => { + const { sourceFile } = context; + const token = findPrecedingToken(textSpanEnd(diag), diag.file!); + switch (context.fixId) { + case fixIdPrefix: + if (isIdentifier(token) && canPrefix(token)) { + tryPrefixDeclaration(changes, diag.code, sourceFile, token); } - } - break; - default: - Debug.fail(JSON.stringify(context.fixId)); - } - }), + break; + case fixIdDelete: + // Ignore if this range was already deleted. + if (deleted.some(d => rangeContainsPosition(d, diag.start!))) break; + + const importDecl = tryGetFullImport(diag.file!, diag.start!); + if (importDecl) { + changes.deleteNode(sourceFile, importDecl); + } + else { + if (!tryDeleteFullDestructure(changes, sourceFile, diag.start!, deleted)) { + tryDeleteDeclaration(changes, sourceFile, token, deleted); + } + } + break; + default: + Debug.fail(JSON.stringify(context.fixId)); + } + }); + }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. @@ -72,18 +79,20 @@ namespace ts.codefix { return startToken.kind === SyntaxKind.ImportKeyword ? tryCast(startToken.parent, isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number): boolean { + function tryDeleteFullDestructure(changes: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, deletedAncestors: NodeSet | undefined): boolean { const startToken = getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); if (startToken.kind !== SyntaxKind.OpenBraceToken || !isObjectBindingPattern(startToken.parent)) return false; const decl = startToken.parent.parent; switch (decl.kind) { case SyntaxKind.VariableDeclaration: - tryDeleteVariableDeclaration(changes, sourceFile, decl); + tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); break; case SyntaxKind.Parameter: + if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNodeInList(sourceFile, decl); break; case SyntaxKind.BindingElement: + if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNode(sourceFile, decl); break; default: @@ -93,7 +102,7 @@ namespace ts.codefix { } function getToken(sourceFile: SourceFile, pos: number): Node { - const token = findPrecedingToken(pos, sourceFile); + const token = findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true); // this handles var ["computed"] = 12; return token.kind === SyntaxKind.CloseBracketToken ? findPrecedingToken(pos - 1, sourceFile) : token; } @@ -121,41 +130,45 @@ namespace ts.codefix { return false; } - function tryDeleteDeclaration(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Node): void { + function tryDeleteDeclaration(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Node, deletedAncestors: NodeSet | undefined): void { switch (token.kind) { case SyntaxKind.Identifier: - tryDeleteIdentifier(changes, sourceFile, token); + tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors); break; case SyntaxKind.PropertyDeclaration: case SyntaxKind.NamespaceImport: + if (deletedAncestors) deletedAncestors.add(token.parent); changes.deleteNode(sourceFile, token.parent); break; default: - tryDeleteDefault(changes, sourceFile, token); + tryDeleteDefault(changes, sourceFile, token, deletedAncestors); } } - function tryDeleteDefault(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Node): void { + function tryDeleteDefault(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Node, deletedAncestors: NodeSet | undefined): void { if (isDeclarationName(token)) { + if (deletedAncestors) deletedAncestors.add(token.parent); changes.deleteNode(sourceFile, token.parent); } else if (isLiteralComputedPropertyDeclarationName(token)) { + if (deletedAncestors) deletedAncestors.add(token.parent.parent); changes.deleteNode(sourceFile, token.parent.parent); } } - function tryDeleteIdentifier(changes: textChanges.ChangeTracker, sourceFile: SourceFile, identifier: Identifier): void { + function tryDeleteIdentifier(changes: textChanges.ChangeTracker, sourceFile: SourceFile, identifier: Identifier, deletedAncestors: NodeSet | undefined): void { const parent = identifier.parent; switch (parent.kind) { case SyntaxKind.VariableDeclaration: - tryDeleteVariableDeclaration(changes, sourceFile, parent); + tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); break; case SyntaxKind.TypeParameter: - const typeParameters = (parent.parent).typeParameters; + const typeParameters = getEffectiveTypeParameterDeclarations(parent.parent); if (typeParameters.length === 1) { - const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1, /*includeJsDocComment*/ false); - const nextToken = getTokenAtPosition(sourceFile, typeParameters.end, /*includeJsDocComment*/ false); + const { pos, end } = cast(typeParameters, isNodeArray); + const previousToken = getTokenAtPosition(sourceFile, pos - 1, /*includeJsDocComment*/ false); + const nextToken = getTokenAtPosition(sourceFile, end, /*includeJsDocComment*/ false); Debug.assert(previousToken.kind === SyntaxKind.LessThanToken); Debug.assert(nextToken.kind === SyntaxKind.GreaterThanToken); @@ -255,7 +268,7 @@ namespace ts.codefix { break; default: - tryDeleteDefault(changes, sourceFile, identifier); + tryDeleteDefault(changes, sourceFile, identifier, deletedAncestors); break; } } @@ -280,15 +293,17 @@ namespace ts.codefix { } // token.parent is a variableDeclaration - function tryDeleteVariableDeclaration(changes: textChanges.ChangeTracker, sourceFile: SourceFile, varDecl: VariableDeclaration): void { + function tryDeleteVariableDeclaration(changes: textChanges.ChangeTracker, sourceFile: SourceFile, varDecl: VariableDeclaration, deletedAncestors: NodeSet | undefined): void { switch (varDecl.parent.parent.kind) { case SyntaxKind.ForStatement: { const forStatement = varDecl.parent.parent; const 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; @@ -298,6 +313,7 @@ namespace ts.codefix { const forOfStatement = varDecl.parent.parent; Debug.assert(forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList); const forOfInitializer = forOfStatement.initializer; + if (deletedAncestors) deletedAncestors.add(forOfInitializer.declarations[0]); changes.replaceNode(sourceFile, forOfInitializer.declarations[0], createObjectLiteral()); break; @@ -308,11 +324,25 @@ namespace ts.codefix { default: const 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); } } } -} \ No newline at end of file + + class NodeSet { + private map = createMap(); + + add(node: Node): void { + this.map.set(String(getNodeId(node)), node); + } + + some(pred: (node: Node) => boolean): boolean { + return forEachEntry(this.map, pred) || false; + } + } +} diff --git a/src/services/codefixes/fixUnusedLabel.ts b/src/services/codefixes/fixUnusedLabel.ts new file mode 100644 index 00000000000..b99f72d6839 --- /dev/null +++ b/src/services/codefixes/fixUnusedLabel.ts @@ -0,0 +1,25 @@ +/* @internal */ +namespace ts.codefix { + const fixId = "fixUnusedLabel"; + const errorCodes = [Diagnostics.Unused_label.code]; + registerCodeFix({ + errorCodes, + getCodeActions(context) { + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, context.span.start)); + return [createCodeFixAction(fixId, changes, Diagnostics.Remove_unused_label, fixId, Diagnostics.Remove_all_unused_labels)]; + }, + fixIds: [fixId], + getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => doChange(changes, diag.file, diag.start)), + }); + + function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, start: number): void { + const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); + const labeledStatement = cast(token.parent, isLabeledStatement); + const pos = token.getStart(sourceFile); + const statementPos = labeledStatement.statement.getStart(sourceFile); + // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. + const end = positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos + : skipTrivia(sourceFile.text, findChildOfKind(labeledStatement, SyntaxKind.ColonToken, sourceFile)!.end, /*stopAfterLineBreak*/ true); + changes.deleteRange(sourceFile, { pos, end }); + } +} diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 68b6e9a856f..d30e2a2cf60 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -101,7 +101,7 @@ namespace ts.codefix { const exportInfos = getAllReExportingModules(exportedSymbol, moduleSymbol, symbolName, sourceFile, checker, allSourceFiles); 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, compilerOptions, getCanonicalFileName, host, preferences)).moduleSpecifier; + 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)) }; } @@ -225,10 +225,6 @@ namespace ts.codefix { } } - function usesJsExtensionOnImports(sourceFile: SourceFile): boolean { - return firstDefined(sourceFile.imports, ({ text }) => pathIsRelative(text) ? fileExtensionIs(text, Extension.Js) : undefined) || false; - } - function createImportClauseOfKind(kind: ImportKind.Default | ImportKind.Named | ImportKind.Namespace, symbolName: string) { const id = createIdentifier(symbolName); switch (kind) { @@ -247,320 +243,17 @@ namespace ts.codefix { program: Program, sourceFile: SourceFile, moduleSymbols: ReadonlyArray, - compilerOptions: CompilerOptions, - getCanonicalFileName: (file: string) => string, host: LanguageServiceHost, preferences: UserPreferences, ): ReadonlyArray { - const { baseUrl, paths, rootDirs } = compilerOptions; - const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); - const addJsExtension = usesJsExtensionOnImports(sourceFile); const choicesForEachExportingModule = flatMap(moduleSymbols, ({ moduleSymbol, importKind }) => { - const modulePathsGroups = getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()).map(moduleFileName => { - const sourceDirectory = getDirectoryPath(sourceFile.fileName); - const global = tryGetModuleNameFromAmbientModule(moduleSymbol) - || tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); - if (global) { - return [global]; - } - - const relativePath = removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePath(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); - if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { - return [relativePath]; - } - - const relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); - if (!relativeToBaseUrl) { - return [relativePath]; - } - - const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); - if (paths) { - const fromPaths = tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - if (fromPaths) { - return [fromPaths]; - } - } - - if (preferences.importModuleSpecifierPreference === "non-relative") { - return [importRelativeToBaseUrl]; - } - - if (preferences.importModuleSpecifierPreference !== undefined) Debug.assertNever(preferences.importModuleSpecifierPreference); - - if (isPathRelativeToParent(relativeToBaseUrl)) { - return [relativePath]; - } - - /* - Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/a/b - moduleFileName = /base/foo/bar - Then: - relativePath = ../../foo/bar - getRelativePathNParents(relativePath) = 2 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 2 < 2 = false - In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/foo/a - moduleFileName = /base/foo/bar - Then: - relativePath = ../a - getRelativePathNParents(relativePath) = 1 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 1 < 2 = true - In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". - */ - const pathFromSourceToBaseUrl = ensurePathIsNonModuleName(getRelativePath(sourceDirectory, baseUrl, getCanonicalFileName)); - const relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); - return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; - }); + const modulePathsGroups = moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program, sourceFile, host, preferences); return modulePathsGroups.map(group => group.map(moduleSpecifier => ({ 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)); } - /** - * Looks for a existing imports that use symlinks to this module. - * Only if no symlink is available, the real path will be used. - */ - function getAllModulePaths(program: Program, { fileName }: SourceFile): ReadonlyArray { - const symlinks = mapDefined(program.getSourceFiles(), sf => - sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res => - res && res.resolvedFileName === fileName ? res.originalPath : undefined)); - return symlinks.length === 0 ? [fileName] : symlinks; - } - - function getRelativePathNParents(relativePath: string): number { - const components = getPathComponents(relativePath); - if (components[0] || components.length === 1) return 0; - for (let i = 1; i < components.length; i++) { - if (components[i] !== "..") return i - 1; - } - return components.length - 1; - } - - function tryGetModuleNameFromAmbientModule(moduleSymbol: Symbol): string | undefined { - const decl = moduleSymbol.valueDeclaration; - if (isModuleDeclaration(decl) && isStringLiteral(decl.name)) { - return decl.name.text; - } - } - - function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex: string, relativeToBaseUrl: string, paths: MapLike>): string | undefined { - for (const key in paths) { - 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) { - const prefix = pattern.substr(0, indexOfStar); - const suffix = pattern.substr(indexOfStar + 1); - if (relativeToBaseUrl.length >= prefix.length + suffix.length && - startsWith(relativeToBaseUrl, prefix) && - endsWith(relativeToBaseUrl, suffix)) { - const matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length); - return key.replace("*", matchedStar); - } - } - else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) { - return key; - } - } - } - } - - function tryGetModuleNameFromRootDirs(rootDirs: ReadonlyArray, moduleFileName: string, sourceDirectory: string, getCanonicalFileName: (file: string) => string): string | undefined { - const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); - if (normalizedTargetPath === undefined) { - return undefined; - } - - const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); - const relativePath = normalizedSourcePath !== undefined ? ensurePathIsNonModuleName(getRelativePath(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return removeFileExtension(relativePath); - } - - function tryGetModuleNameFromTypeRoots( - options: CompilerOptions, - host: GetEffectiveTypeRootsHost, - getCanonicalFileName: (file: string) => string, - moduleFileName: string, - addJsExtension: boolean, - ): string | undefined { - const roots = getEffectiveTypeRoots(options, host); - return firstDefined(roots, unNormalizedTypeRoot => { - const typeRoot = toPath(unNormalizedTypeRoot, /*basePath*/ undefined, getCanonicalFileName); - if (startsWith(moduleFileName, typeRoot)) { - // For a type definition, we can strip `/index` even with classic resolution. - return removeExtensionAndIndexPostFix(moduleFileName.substring(typeRoot.length + 1), ModuleResolutionKind.NodeJs, addJsExtension); - } - }); - } - - function tryGetModuleNameAsNodeModule( - options: CompilerOptions, - moduleFileName: string, - host: LanguageServiceHost, - getCanonicalFileName: (file: string) => string, - sourceDirectory: string, - ): string | undefined { - if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) { - // nothing to do here - return undefined; - } - - const parts = getNodeModulePathParts(moduleFileName); - - if (!parts) { - return undefined; - } - - // Simplify the full file path to something that can be resolved by Node. - - // If the module could be imported by a directory name, use that directory's name - let moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); - // Get a path that's relative to node_modules or the importing file's path - moduleSpecifier = getNodeResolvablePath(moduleSpecifier); - // If the module was found in @types, get the actual Node package name - return getPackageNameFromAtTypesDirectory(moduleSpecifier); - - function getDirectoryOrExtensionlessFileName(path: string): string { - // If the file is the main module, it can be imported by the package name - const packageRootPath = path.substring(0, parts.packageRootIndex); - const packageJsonPath = combinePaths(packageRootPath, "package.json"); - if (host.fileExists(packageJsonPath)) { - const packageJsonContent = JSON.parse(host.readFile(packageJsonPath)); - if (packageJsonContent) { - const mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; - if (mainFileRelative) { - const mainExportFile = toPath(mainFileRelative, packageRootPath, getCanonicalFileName); - if (mainExportFile === getCanonicalFileName(path)) { - return packageRootPath; - } - } - } - } - - // We still have a file name - remove the extension - const fullModulePathWithoutExtension = removeFileExtension(path); - - // If the file is /index, it can be imported by its directory name - if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index") { - return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex); - } - - return fullModulePathWithoutExtension; - } - - function getNodeResolvablePath(path: string): string { - const basePath = path.substring(0, parts.topLevelNodeModulesIndex); - if (sourceDirectory.indexOf(basePath) === 0) { - // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - return path.substring(parts.topLevelPackageNameIndex + 1); - } - else { - return ensurePathIsNonModuleName(getRelativePath(sourceDirectory, path, getCanonicalFileName)); - } - } - } - - function getNodeModulePathParts(fullPath: string) { - // If fullPath can't be valid module file within node_modules, returns undefined. - // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js - // Returns indices: ^ ^ ^ ^ - - let topLevelNodeModulesIndex = 0; - let topLevelPackageNameIndex = 0; - let packageRootIndex = 0; - let fileNameIndex = 0; - - const enum States { - BeforeNodeModules, - NodeModules, - Scope, - PackageContent - } - - let partStart = 0; - let partEnd = 0; - let state = States.BeforeNodeModules; - - while (partEnd >= 0) { - partStart = partEnd; - partEnd = fullPath.indexOf("/", partStart + 1); - switch (state) { - case States.BeforeNodeModules: - if (fullPath.indexOf("/node_modules/", partStart) === partStart) { - topLevelNodeModulesIndex = partStart; - topLevelPackageNameIndex = partEnd; - state = States.NodeModules; - } - break; - case States.NodeModules: - case States.Scope: - if (state === States.NodeModules && fullPath.charAt(partStart + 1) === "@") { - state = States.Scope; - } - else { - packageRootIndex = partEnd; - state = States.PackageContent; - } - break; - case States.PackageContent: - if (fullPath.indexOf("/node_modules/", partStart) === partStart) { - state = States.NodeModules; - } - else { - state = States.PackageContent; - } - break; - } - } - - fileNameIndex = partStart; - - return state > States.NodeModules ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : undefined; - } - - function getPathRelativeToRootDirs(path: string, rootDirs: ReadonlyArray, getCanonicalFileName: GetCanonicalFileName): string | undefined { - return firstDefined(rootDirs, rootDir => { - const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); - return isPathRelativeToParent(relativePath) ? undefined : relativePath; - }); - } - - function removeExtensionAndIndexPostFix(fileName: string, moduleResolutionKind: ModuleResolutionKind, addJsExtension: boolean): string { - const noExtension = removeFileExtension(fileName); - return addJsExtension - ? noExtension + ".js" - : moduleResolutionKind === ModuleResolutionKind.NodeJs - ? removeSuffix(noExtension, "/index") - : noExtension; - } - - function getRelativePathIfInDirectory(path: string, directoryPath: string, getCanonicalFileName: GetCanonicalFileName): string | undefined { - const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - return isRootedDiskPath(relativePath) ? undefined : relativePath; - } - - function isPathRelativeToParent(path: string): boolean { - return startsWith(path, ".."); - } - function getCodeActionsForAddImport( exportInfos: ReadonlyArray, ctx: ImportCodeFixContext, @@ -585,7 +278,7 @@ namespace ts.codefix { const existingDeclaration = firstDefined(existingImports, newImportInfoFromExistingSpecifier); const newImportInfos = existingDeclaration ? [existingDeclaration] - : getNewImportInfos(ctx.program, ctx.sourceFile, exportInfos, ctx.compilerOptions, ctx.getCanonicalFileName, ctx.host, ctx.preferences); + : getNewImportInfos(ctx.program, ctx.sourceFile, exportInfos, ctx.host, ctx.preferences); for (const info of newImportInfos) { addNew.push(getCodeActionForNewImport(ctx, info)); } diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index 8b36d3e5d51..92f4ab05e3c 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -32,16 +32,16 @@ namespace ts.codefix { const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); let declaration!: Declaration; - const changes = textChanges.ChangeTracker.with(context, changes => { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken); }); + const changes = textChanges.ChangeTracker.with(context, changes => { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeenseen*/ returnTrue); }); return changes.length === 0 ? undefined : [createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), getNameOfDeclaration(declaration).getText(sourceFile)], fixId, Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions(context) { const { sourceFile, program, cancellationToken } = context; - const seenFunctions = createMap(); + const markSeen = nodeSeenTracker(); return codeFixAll(context, errorCodes, (changes, err) => { - doChange(changes, sourceFile, getTokenAtPosition(err.file!, err.start!, /*includeJsDocComment*/ false), err.code, program, cancellationToken, seenFunctions); + doChange(changes, sourceFile, getTokenAtPosition(err.file!, err.start!, /*includeJsDocComment*/ false), err.code, program, cancellationToken, markSeen); }); }, }); @@ -57,7 +57,7 @@ namespace ts.codefix { } } - function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Node, errorCode: number, program: Program, cancellationToken: CancellationToken, seenFunctions?: Map): Declaration | undefined { + function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Node, errorCode: number, program: Program, cancellationToken: CancellationToken, markSeen: NodeSeenTracker): Declaration | undefined { if (!isParameterPropertyModifier(token.kind) && token.kind !== SyntaxKind.Identifier && token.kind !== SyntaxKind.DotDotDotToken) { return undefined; } @@ -67,7 +67,7 @@ namespace ts.codefix { // Variable and Property declarations case Diagnostics.Member_0_implicitly_has_an_1_type.code: case Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: - if (isVariableDeclaration(parent) || isPropertyDeclaration(parent) || isPropertySignature(parent)) { // handle bad location + if ((isVariableDeclaration(parent) && markSeen(parent)) || isPropertyDeclaration(parent) || isPropertySignature(parent)) { // handle bad location annotateVariableDeclaration(changes, sourceFile, parent, program, cancellationToken); return parent; } @@ -75,10 +75,11 @@ namespace ts.codefix { case Diagnostics.Variable_0_implicitly_has_an_1_type.code: { const symbol = program.getTypeChecker().getSymbolAtLocation(token); - if (symbol && symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration)) { + if (symbol && symbol.valueDeclaration && isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, cancellationToken); return symbol.valueDeclaration; } + return undefined; } } @@ -96,7 +97,7 @@ namespace ts.codefix { } // falls through case Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - if (!seenFunctions || addToSeen(seenFunctions, getNodeId(containingFunction))) { + if (markSeen(containingFunction)) { const param = cast(parent, isParameter); annotateParameters(changes, param, containingFunction, sourceFile, program, cancellationToken); return param; @@ -318,6 +319,16 @@ namespace ts.codefix { case SyntaxKind.ElementAccessExpression: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; + case SyntaxKind.VariableDeclaration: { + const { name, initializer } = node.parent as VariableDeclaration; + if (node === name) { + if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. + addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + } + break; + } + } + // falls through default: return inferTypeFromContextualType(node, checker, usageContext); } @@ -511,7 +522,7 @@ namespace ts.codefix { return checker.getStringType(); } else if (usageContext.candidateTypes) { - return checker.getWidenedType(checker.getUnionType(map(usageContext.candidateTypes, t => checker.getBaseTypeOfLiteralType(t)), UnionReduction.Subtype)); + return checker.getWidenedType(checker.getUnionType(usageContext.candidateTypes.map(t => checker.getBaseTypeOfLiteralType(t)), UnionReduction.Subtype)); } else if (usageContext.properties && hasCallContext(usageContext.properties.get("then" as __String))) { const paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then" as __String).callContexts, /*isRestParameter*/ false, checker); diff --git a/src/services/codefixes/moduleSpecifiers.ts b/src/services/codefixes/moduleSpecifiers.ts new file mode 100644 index 00000000000..94b7846d8e6 --- /dev/null +++ b/src/services/codefixes/moduleSpecifiers.ts @@ -0,0 +1,322 @@ +// Used by importFixes to synthesize import module specifiers. +/* @internal */ +namespace ts.moduleSpecifiers { + // For each symlink/original for a module, returns a list of ways to import that file. + export function getModuleSpecifiers( + moduleSymbol: Symbol, + program: Program, + importingSourceFile: SourceFile, + host: LanguageServiceHost, + preferences: UserPreferences, + ): ReadonlyArray> { + const compilerOptions = program.getCompilerOptions(); + const { baseUrl, paths, rootDirs } = compilerOptions; + const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); + const addJsExtension = usesJsExtensionOnImports(importingSourceFile); + const getCanonicalFileName = hostGetCanonicalFileName(host); + const sourceDirectory = getDirectoryPath(importingSourceFile.fileName); + + return getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()).map(moduleFileName => { + const global = tryGetModuleNameFromAmbientModule(moduleSymbol) + || tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) + || rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + if (global) { + return [global]; + } + + const relativePath = removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { + return [relativePath]; + } + + const relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); + if (!relativeToBaseUrl) { + return [relativePath]; + } + + const importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); + if (paths) { + const fromPaths = tryGetModuleNameFromPaths(removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); + if (fromPaths) { + return [fromPaths]; + } + } + + if (preferences.importModuleSpecifierPreference === "non-relative") { + return [importRelativeToBaseUrl]; + } + + if (preferences.importModuleSpecifierPreference !== undefined) Debug.assertNever(preferences.importModuleSpecifierPreference); + + if (isPathRelativeToParent(relativeToBaseUrl)) { + return [relativePath]; + } + + /* + Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. + + Suppose we have: + baseUrl = /base + sourceDirectory = /base/a/b + moduleFileName = /base/foo/bar + Then: + relativePath = ../../foo/bar + getRelativePathNParents(relativePath) = 2 + pathFromSourceToBaseUrl = ../../ + getRelativePathNParents(pathFromSourceToBaseUrl) = 2 + 2 < 2 = false + In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". + + Suppose we have: + baseUrl = /base + sourceDirectory = /base/foo/a + moduleFileName = /base/foo/bar + Then: + relativePath = ../a + getRelativePathNParents(relativePath) = 1 + pathFromSourceToBaseUrl = ../../ + getRelativePathNParents(pathFromSourceToBaseUrl) = 2 + 1 < 2 = true + In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". + */ + const pathFromSourceToBaseUrl = ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); + const relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); + return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + }); + } + + function usesJsExtensionOnImports({ imports }: SourceFile): boolean { + return firstDefined(imports, ({ text }) => pathIsRelative(text) ? fileExtensionIs(text, Extension.Js) : undefined) || false; + } + + /** + * Looks for a existing imports that use symlinks to this module. + * Only if no symlink is available, the real path will be used. + */ + function getAllModulePaths(program: Program, { fileName }: SourceFile): ReadonlyArray { + const symlinks = mapDefined(program.getSourceFiles(), sf => + sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res => + res && res.resolvedFileName === fileName ? res.originalPath : undefined)); + return symlinks.length === 0 ? [fileName] : symlinks; + } + + function getRelativePathNParents(relativePath: string): number { + const components = getPathComponents(relativePath); + if (components[0] || components.length === 1) return 0; + for (let i = 1; i < components.length; i++) { + if (components[i] !== "..") return i - 1; + } + return components.length - 1; + } + + function tryGetModuleNameFromAmbientModule(moduleSymbol: Symbol): string | undefined { + const decl = moduleSymbol.valueDeclaration; + if (isModuleDeclaration(decl) && isStringLiteral(decl.name)) { + return decl.name.text; + } + } + + function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex: string, relativeToBaseUrl: string, paths: MapLike>): string | undefined { + for (const key in paths) { + 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) { + const prefix = pattern.substr(0, indexOfStar); + const suffix = pattern.substr(indexOfStar + 1); + if (relativeToBaseUrl.length >= prefix.length + suffix.length && + startsWith(relativeToBaseUrl, prefix) && + endsWith(relativeToBaseUrl, suffix)) { + const matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length); + return key.replace("*", matchedStar); + } + } + else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) { + return key; + } + } + } + } + + function tryGetModuleNameFromRootDirs(rootDirs: ReadonlyArray, moduleFileName: string, sourceDirectory: string, getCanonicalFileName: (file: string) => string): string | undefined { + const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); + if (normalizedTargetPath === undefined) { + return undefined; + } + + const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); + const relativePath = normalizedSourcePath !== undefined ? ensurePathIsNonModuleName(getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; + return removeFileExtension(relativePath); + } + + function tryGetModuleNameFromTypeRoots( + options: CompilerOptions, + host: GetEffectiveTypeRootsHost, + getCanonicalFileName: (file: string) => string, + moduleFileName: string, + addJsExtension: boolean, + ): string | undefined { + const roots = getEffectiveTypeRoots(options, host); + return firstDefined(roots, unNormalizedTypeRoot => { + const typeRoot = toPath(unNormalizedTypeRoot, /*basePath*/ undefined, getCanonicalFileName); + if (startsWith(moduleFileName, typeRoot)) { + // For a type definition, we can strip `/index` even with classic resolution. + return removeExtensionAndIndexPostFix(moduleFileName.substring(typeRoot.length + 1), ModuleResolutionKind.NodeJs, addJsExtension); + } + }); + } + + function tryGetModuleNameAsNodeModule( + options: CompilerOptions, + moduleFileName: string, + host: LanguageServiceHost, + getCanonicalFileName: (file: string) => string, + sourceDirectory: string, + ): string | undefined { + if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) { + // nothing to do here + return undefined; + } + + const parts = getNodeModulePathParts(moduleFileName); + + if (!parts) { + return undefined; + } + + // Simplify the full file path to something that can be resolved by Node. + + // If the module could be imported by a directory name, use that directory's name + let moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + // Get a path that's relative to node_modules or the importing file's path + moduleSpecifier = getNodeResolvablePath(moduleSpecifier); + // If the module was found in @types, get the actual Node package name + return getPackageNameFromAtTypesDirectory(moduleSpecifier); + + function getDirectoryOrExtensionlessFileName(path: string): string { + // If the file is the main module, it can be imported by the package name + const packageRootPath = path.substring(0, parts.packageRootIndex); + const packageJsonPath = combinePaths(packageRootPath, "package.json"); + if (host.fileExists(packageJsonPath)) { + const packageJsonContent = JSON.parse(host.readFile(packageJsonPath)); + if (packageJsonContent) { + const mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; + if (mainFileRelative) { + const mainExportFile = toPath(mainFileRelative, packageRootPath, getCanonicalFileName); + if (mainExportFile === getCanonicalFileName(path)) { + return packageRootPath; + } + } + } + } + + // We still have a file name - remove the extension + const fullModulePathWithoutExtension = removeFileExtension(path); + + // If the file is /index, it can be imported by its directory name + if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index") { + return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex); + } + + return fullModulePathWithoutExtension; + } + + function getNodeResolvablePath(path: string): string { + const basePath = path.substring(0, parts.topLevelNodeModulesIndex); + if (sourceDirectory.indexOf(basePath) === 0) { + // if node_modules folder is in this folder or any of its parent folders, no need to keep it. + return path.substring(parts.topLevelPackageNameIndex + 1); + } + else { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, path, getCanonicalFileName)); + } + } + } + + function getNodeModulePathParts(fullPath: string) { + // If fullPath can't be valid module file within node_modules, returns undefined. + // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js + // Returns indices: ^ ^ ^ ^ + + let topLevelNodeModulesIndex = 0; + let topLevelPackageNameIndex = 0; + let packageRootIndex = 0; + let fileNameIndex = 0; + + const enum States { + BeforeNodeModules, + NodeModules, + Scope, + PackageContent + } + + let partStart = 0; + let partEnd = 0; + let state = States.BeforeNodeModules; + + while (partEnd >= 0) { + partStart = partEnd; + partEnd = fullPath.indexOf("/", partStart + 1); + switch (state) { + case States.BeforeNodeModules: + if (fullPath.indexOf("/node_modules/", partStart) === partStart) { + topLevelNodeModulesIndex = partStart; + topLevelPackageNameIndex = partEnd; + state = States.NodeModules; + } + break; + case States.NodeModules: + case States.Scope: + if (state === States.NodeModules && fullPath.charAt(partStart + 1) === "@") { + state = States.Scope; + } + else { + packageRootIndex = partEnd; + state = States.PackageContent; + } + break; + case States.PackageContent: + if (fullPath.indexOf("/node_modules/", partStart) === partStart) { + state = States.NodeModules; + } + else { + state = States.PackageContent; + } + break; + } + } + + fileNameIndex = partStart; + + return state > States.NodeModules ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : undefined; + } + + function getPathRelativeToRootDirs(path: string, rootDirs: ReadonlyArray, getCanonicalFileName: GetCanonicalFileName): string | undefined { + return firstDefined(rootDirs, rootDir => { + const relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); + return isPathRelativeToParent(relativePath) ? undefined : relativePath; + }); + } + + function removeExtensionAndIndexPostFix(fileName: string, moduleResolutionKind: ModuleResolutionKind, addJsExtension: boolean): string { + const noExtension = removeFileExtension(fileName); + return addJsExtension + ? noExtension + ".js" + : moduleResolutionKind === ModuleResolutionKind.NodeJs + ? removeSuffix(noExtension, "/index") + : noExtension; + } + + function getRelativePathIfInDirectory(path: string, directoryPath: string, getCanonicalFileName: GetCanonicalFileName): string | undefined { + const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + return isRootedDiskPath(relativePath) ? undefined : relativePath; + } + + function isPathRelativeToParent(path: string): boolean { + return startsWith(path, ".."); + } +} diff --git a/src/services/codefixes/useDefaultImport.ts b/src/services/codefixes/useDefaultImport.ts index 632cfc97e00..99fc145b563 100644 --- a/src/services/codefixes/useDefaultImport.ts +++ b/src/services/codefixes/useDefaultImport.ts @@ -37,6 +37,6 @@ namespace ts.codefix { } function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, info: Info): void { - changes.replaceNode(sourceFile, info.importNode, makeImportDeclaration(info.name, /*namedImports*/ undefined, info.moduleSpecifier)); + changes.replaceNode(sourceFile, info.importNode, makeImport(info.name, /*namedImports*/ undefined, info.moduleSpecifier)); } } diff --git a/src/services/completions.ts b/src/services/completions.ts index 4950d1370e1..d8b0bbc138d 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -972,12 +972,8 @@ namespace ts.Completions { } else if (isRightOfOpenTag) { const tagSymbols = Debug.assertEachDefined(typeChecker.getJsxIntrinsicTagNamesAt(location), "getJsxIntrinsicTagNames() should all be defined"); - if (tryGetGlobalSymbols()) { - symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & (SymbolFlags.Value | SymbolFlags.Alias)))); - } - else { - symbols = tagSymbols; - } + tryGetGlobalSymbols(); + symbols = tagSymbols.concat(symbols); completionKind = CompletionKind.MemberLike; } else if (isStartingCloseTag) { @@ -1298,7 +1294,7 @@ namespace ts.Completions { const exportedSymbols = typeChecker.getExportsOfModule(symbol); // If the exported symbols contains type, // symbol can be referenced at locations where type is allowed - return forEach(exportedSymbols, symbolCanBeReferencedAtTypeLocation); + return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation); } } @@ -2211,7 +2207,6 @@ namespace ts.Completions { function isValidTrigger(sourceFile: SourceFile, triggerCharacter: CompletionsTriggerCharacter, contextToken: Node, position: number): boolean { switch (triggerCharacter) { case ".": - case "/": case "@": return true; case '"': @@ -2222,6 +2217,10 @@ namespace ts.Completions { case "<": // Opening JSX tag return contextToken.kind === SyntaxKind.LessThanToken && contextToken.parent.kind !== SyntaxKind.BinaryExpression; + case "/": + return isStringLiteralLike(contextToken) + ? !!tryGetImportFromModuleSpecifier(contextToken) + : contextToken.kind === SyntaxKind.SlashToken && isJsxClosingElement(contextToken.parent); default: return Debug.assertNever(triggerCharacter); } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 69c75548fe5..65653483d07 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -74,6 +74,10 @@ namespace ts.DocumentHighlights { case SyntaxKind.GetKeyword: case SyntaxKind.SetKeyword: return getFromAllDeclarations(isAccessor, [SyntaxKind.GetKeyword, SyntaxKind.SetKeyword]); + case SyntaxKind.AwaitKeyword: + return useParent(node.parent, isAwaitExpression, getAsyncAndAwaitOccurrences); + case SyntaxKind.AsyncKeyword: + return highlightSpans(getAsyncAndAwaitOccurrences(node)); default: return isModifierKind(node.kind) && (isDeclaration(node.parent) || isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) @@ -368,6 +372,35 @@ namespace ts.DocumentHighlights { return keywords; } + function getAsyncAndAwaitOccurrences(node: Node): Node[] | undefined { + const func = getContainingFunction(node); + if (!func) { + return undefined; + } + + const keywords: Node[] = []; + + if (func.modifiers) { + func.modifiers.forEach(modifier => { + pushKeywordIf(keywords, modifier, SyntaxKind.AsyncKeyword); + }); + } + + forEachChild(func, aggregate); + + return keywords; + + function aggregate(node: Node): void { + if (isAwaitExpression(node)) { + pushKeywordIf(keywords, node.getFirstToken(), SyntaxKind.AwaitKeyword); + } + // Do not cross function boundaries. + if (!isFunctionLike(node) && !isClassLike(node) && !isInterfaceDeclaration(node) && !isModuleDeclaration(node) && !isTypeAliasDeclaration(node) && !isTypeNode(node)) { + forEachChild(node, aggregate); + } + } + } + function getIfElseOccurrences(ifStatement: IfStatement, sourceFile: SourceFile): HighlightSpan[] { const keywords = getIfElseKeywords(ifStatement, sourceFile); const result: HighlightSpan[] = []; diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index bedb657a66d..5f4d653ca3d 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -236,7 +236,7 @@ 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), sourceFiles, sourceFilesSet); + return reference && getReferencedSymbolsForModule(program, program.getTypeChecker().getMergedSymbol(reference.file.symbol), /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } if (!options.implementations) { @@ -247,7 +247,7 @@ namespace ts.FindAllReferences.Core { } const checker = program.getTypeChecker(); - const symbol = checker.getSymbolAtLocation(node); + let symbol = checker.getSymbolAtLocation(node); // Could not find a symbol e.g. unknown identifier if (!symbol) { @@ -255,37 +255,37 @@ namespace ts.FindAllReferences.Core { return !options.implementations && isStringLiteral(node) ? getReferencesForStringLiteral(node, sourceFiles, cancellationToken) : undefined; } - if (symbol.flags & SymbolFlags.Module && isModuleReferenceLocation(node)) { - return getReferencedSymbolsForModule(program, symbol, sourceFiles, sourceFilesSet); + let moduleReferences: SymbolAndEntries[] = emptyArray; + const moduleSourceFile = isModuleSymbol(symbol); + if (moduleSourceFile) { + const exportEquals = symbol.exports.get(InternalSymbolName.ExportEquals); + // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. + moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); + if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) return moduleReferences; + // Continue to get references to 'export ='. + symbol = skipAlias(exportEquals, checker); + node = undefined; } - - return getReferencedSymbolsForSymbol(symbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options); + return concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); } - function isModuleReferenceLocation(node: Node): boolean { - if (!isStringLiteralLike(node)) { - return false; - } - switch (node.parent.kind) { - case SyntaxKind.ModuleDeclaration: - case SyntaxKind.ExternalModuleReference: - case SyntaxKind.ImportDeclaration: - case SyntaxKind.ExportDeclaration: - return true; - case SyntaxKind.LiteralType: - return isImportTypeNode(node.parent.parent); - case SyntaxKind.CallExpression: - return isRequireCall(node.parent as CallExpression, /*checkArgumentIsStringLiteralLike*/ false) || isImportCall(node.parent as CallExpression); - default: - return false; - } + function isModuleSymbol(symbol: Symbol): SourceFile | undefined { + return symbol.flags & SymbolFlags.Module && find(symbol.declarations, isSourceFile); } - function getReferencedSymbolsForModule(program: Program, symbol: Symbol, sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap): SymbolAndEntries[] { + function getReferencedSymbolsForModule(program: Program, symbol: Symbol, excludeImportTypeOfExportEquals: boolean, sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap): SymbolAndEntries[] { Debug.assert(!!symbol.valueDeclaration); - const references = findModuleReferences(program, sourceFiles, symbol).map(reference => { + const references = mapDefined(findModuleReferences(program, sourceFiles, symbol), reference => { if (reference.kind === "import") { + const parent = reference.literal.parent; + if (isLiteralTypeNode(parent)) { + const importType = cast(parent.parent, isImportTypeNode); + if (excludeImportTypeOfExportEquals && !importType.qualifier) { + return undefined; + } + } + // import("foo") with no qualifier will reference the `export =` of the module, which may be referenced anyway. return { type: "node", node: reference.literal }; } else { @@ -308,11 +308,12 @@ namespace ts.FindAllReferences.Core { } break; default: + // This may be merged with something. Debug.fail("Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } - return [{ definition: { type: "symbol", symbol }, references }]; + return references.length ? [{ definition: { type: "symbol", symbol }, references }] : emptyArray; } /** getReferencedSymbols for special node kinds. */ @@ -345,21 +346,21 @@ namespace ts.FindAllReferences.Core { } /** Core find-all-references algorithm for a normal symbol. */ - function getReferencedSymbolsForSymbol(symbol: Symbol, node: Node, sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap, checker: TypeChecker, cancellationToken: CancellationToken, options: Options): SymbolAndEntries[] { - symbol = skipPastExportOrImportSpecifierOrUnion(symbol, node, checker) || symbol; + function getReferencedSymbolsForSymbol(symbol: Symbol, node: Node | undefined, sourceFiles: ReadonlyArray, sourceFilesSet: ReadonlyMap, checker: TypeChecker, cancellationToken: CancellationToken, options: Options): SymbolAndEntries[] { + symbol = node && skipPastExportOrImportSpecifierOrUnion(symbol, node, checker) || symbol; // Compute the meaning from the location and the symbol it references - const searchMeaning = getIntersectingMeaningFromDeclarations(node, symbol); + const searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : SemanticMeaning.All; const result: SymbolAndEntries[] = []; - const state = new State(sourceFiles, sourceFilesSet, getSpecialSearchKind(node), checker, cancellationToken, searchMeaning, options, result); + const state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : SpecialSearchKind.None, checker, cancellationToken, searchMeaning, options, result); - if (node.kind === SyntaxKind.DefaultKeyword) { + if (node && node.kind === SyntaxKind.DefaultKeyword) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: ExportKind.Default }, state); } else { - const search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: populateSearchSymbolSet(symbol, node, checker, options.implementations) }); + const search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.implementations) : [symbol] }); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). @@ -499,7 +500,7 @@ namespace ts.FindAllReferences.Core { } /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ - createSearch(location: Node, symbol: Symbol, comingFrom: ImportExport | undefined, searchOptions: { text?: string, allSearchSymbols?: Symbol[] } = {}): Search { + 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 }`. // The other two forms seem to be handled downstream (e.g. in `skipPastExportOrImportSpecifier`), so special-casing the first form @@ -509,7 +510,7 @@ namespace ts.FindAllReferences.Core { allSearchSymbols = [symbol], } = searchOptions; const escapedText = escapeLeadingUnderscores(text); - const parents = this.options.implementations && getParentSymbolsOfPropertyAccess(location, symbol, this.checker); + const parents = this.options.implementations && location && getParentSymbolsOfPropertyAccess(location, symbol, this.checker); return { symbol, comingFrom, text, escapedText, parents, allSearchSymbols, includes: sym => contains(allSearchSymbols, sym) }; } @@ -559,11 +560,7 @@ namespace ts.FindAllReferences.Core { if (singleReferences.length) { const addRef = state.referenceAdder(exportSymbol); for (const singleRef of singleReferences) { - // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - if (hasMatchingMeaning(singleRef, state) && - !(state.options.isForRename && (isExportSpecifier(singleRef.parent) || isImportSpecifier(singleRef.parent)) && singleRef.escapedText === InternalSymbolName.Default)) { - addRef(singleRef); - } + if (shouldAddSingleReference(singleRef, state)) addRef(singleRef); } } @@ -593,6 +590,15 @@ namespace ts.FindAllReferences.Core { } } + function shouldAddSingleReference(singleRef: Identifier | StringLiteral, state: State): boolean { + if (!hasMatchingMeaning(singleRef, state)) return false; + if (!state.options.isForRename) return true; + // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` + if (!isIdentifier(singleRef)) return false; + // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. + return !((isExportSpecifier(singleRef.parent) || isImportSpecifier(singleRef.parent)) && singleRef.escapedText === InternalSymbolName.Default); + } + // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol: Symbol, state: State): void { for (const declaration of symbol.declarations) { @@ -614,27 +620,19 @@ namespace ts.FindAllReferences.Core { checker.getPropertySymbolOfDestructuringAssignment(location); } - function getObjectBindingElementWithoutPropertyName(symbol: Symbol): BindingElement | undefined { + function getObjectBindingElementWithoutPropertyName(symbol: Symbol): BindingElement & { name: Identifier } | undefined { const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); if (bindingElement && bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern && + isIdentifier(bindingElement.name) && !bindingElement.propertyName) { - return bindingElement; + return bindingElement as BindingElement & { name: Identifier }; } } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, checker: TypeChecker): Symbol | undefined { const bindingElement = getObjectBindingElementWithoutPropertyName(symbol); - if (!bindingElement) return undefined; - - const typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); - const propSymbol = typeOfPattern && checker.getPropertyOfType(typeOfPattern, (bindingElement.name).text); - if (propSymbol && propSymbol.flags & SymbolFlags.Accessor) { - // See GH#16922 - Debug.assert(!!(propSymbol.flags & SymbolFlags.Transient)); - return (propSymbol as TransientSymbol).target; - } - return propSymbol; + return bindingElement && getPropertySymbolFromBindingElement(checker, bindingElement); } /** diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 0e89be42532..a75781b8da0 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -269,7 +269,7 @@ namespace ts.formatting { } function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): NextTokenKind { - const nextToken = findNextToken(precedingToken, current); + const nextToken = findNextToken(precedingToken, current, sourceFile); if (!nextToken) { return NextTokenKind.Unknown; } diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index d5fc94c6d62..d05d22a98d9 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -4,7 +4,7 @@ namespace ts { const pathUpdater = getPathUpdater(oldFilePath, newFilePath, host); return textChanges.ChangeTracker.with({ host, formatContext }, changeTracker => { updateTsconfigFiles(program, changeTracker, oldFilePath, newFilePath); - for (const { sourceFile, toUpdate } of getImportsToUpdate(program, oldFilePath)) { + for (const { sourceFile, toUpdate } of getImportsToUpdate(program, oldFilePath, host)) { const newPath = pathUpdater(isRef(toUpdate) ? toUpdate.fileName : toUpdate.text); if (newPath !== undefined) { const range = isRef(toUpdate) ? toUpdate : createStringRange(toUpdate, sourceFile); @@ -30,7 +30,7 @@ namespace ts { return "fileName" in toUpdate; } - function getImportsToUpdate(program: Program, oldFilePath: string): ReadonlyArray { + function getImportsToUpdate(program: Program, oldFilePath: string, host: LanguageServiceHost): ReadonlyArray { const checker = program.getTypeChecker(); const result: ToUpdate[] = []; for (const sourceFile of program.getSourceFiles()) { @@ -44,7 +44,9 @@ namespace ts { // If it resolved to something already, ignore. if (checker.getSymbolAtLocation(importStringLiteral)) continue; - const resolved = program.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName); + const resolved = host.resolveModuleNames + ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName) + : program.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName); if (resolved && contains(resolved.failedLookupLocations, oldFilePath)) { result.push({ sourceFile, toUpdate: importStringLiteral }); } @@ -55,7 +57,7 @@ namespace ts { function getPathUpdater(oldFilePath: string, newFilePath: string, host: LanguageServiceHost): (oldPath: string) => string | undefined { // Get the relative path from old to new location, and append it on to the end of imports and normalize. - const rel = ensurePathIsNonModuleName(getRelativePath(getDirectoryPath(oldFilePath), newFilePath, createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host)))); + const rel = getRelativePathFromFile(oldFilePath, newFilePath, createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host))); return oldPath => { if (!pathIsRelative(oldPath)) return; return ensurePathIsNonModuleName(normalizePath(combinePaths(getDirectoryPath(oldPath), rel))); diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 4858fdc4b34..4f9836dfdf6 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -3,9 +3,9 @@ namespace ts.FindAllReferences { export interface ImportsResult { /** For every import of the symbol, the location and local symbol for the import. */ - importSearches: [Identifier, Symbol][]; + 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: Identifier[]; + 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; } @@ -33,7 +33,7 @@ namespace ts.FindAllReferences { interface AmbientModuleDeclaration extends ModuleDeclaration { body?: ModuleBlock; } type SourceFileLike = SourceFile | AmbientModuleDeclaration; // Identifier for the case of `const x = require("y")`. - type Importer = AnyImportOrReExport | ImportTypeNode | Identifier; + type Importer = AnyImportOrReExport | ValidImportTypeNode | Identifier; type ImporterOrCallExpression = Importer | CallExpression; /** Returns import statements that directly reference the exporting module, and a list of files that may access the module through a namespace. */ @@ -135,13 +135,7 @@ namespace ts.FindAllReferences { break; case SyntaxKind.ImportType: - if (direct.qualifier) { - // `import("foo").x` named import - directImports.push(direct); - } - else { - // TODO: GH#23879 - } + directImports.push(direct); break; default: @@ -205,7 +199,7 @@ namespace ts.FindAllReferences { */ function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker, isForRename: boolean): Pick { const importSearches: [Identifier, Symbol][] = []; - const singleReferences: Identifier[] = []; + const singleReferences: (Identifier | StringLiteral)[] = []; function addSearch(location: Identifier, symbol: Symbol): void { importSearches.push([location, symbol]); } @@ -232,8 +226,13 @@ namespace ts.FindAllReferences { } if (decl.kind === SyntaxKind.ImportType) { - if (decl.qualifier) { // TODO: GH#23879 - singleReferences.push(decl.qualifier.kind === SyntaxKind.Identifier ? decl.qualifier : decl.qualifier.right); + if (decl.qualifier) { + if (isIdentifier(decl.qualifier) && decl.qualifier.escapedText === symbolName(exportSymbol)) { + singleReferences.push(decl.qualifier); + } + } + else if (exportKind === ExportKind.ExportEquals) { + singleReferences.push(decl.argument.literal); } return; } @@ -267,7 +266,7 @@ namespace ts.FindAllReferences { const { name } = importClause; // If a default import has the same name as the default export, allow to rename it. // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. - if (name && (!isForRename || name.escapedText === symbolName(exportSymbol))) { + if (name && (!isForRename || name.escapedText === symbolEscapedNameNoDefault(exportSymbol))) { const defaultImportAlias = checker.getSymbolAtLocation(name); addSearch(name, defaultImportAlias); } @@ -550,7 +549,7 @@ namespace ts.FindAllReferences { // If the import has a different name than the export, do not continue searching. // If `importedName` is undefined, do continue searching as the export is anonymous. // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) - const importedName = symbolName(importedSymbol); + const importedName = symbolEscapedNameNoDefault(importedSymbol); if (importedName === undefined || importedName === InternalSymbolName.Default || importedName === symbol.escapedName) { return { kind: ImportExport.Import, symbol: importedSymbol, ...isImport }; } @@ -622,17 +621,6 @@ namespace ts.FindAllReferences { return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined; } - function symbolName(symbol: Symbol): __String | undefined { - if (symbol.escapedName !== InternalSymbolName.Default) { - return symbol.escapedName; - } - - return forEach(symbol.declarations, decl => { - const name = getNameOfDeclaration(decl); - return name && name.kind === SyntaxKind.Identifier && name.escapedText; - }); - } - /** If at an export specifier, go to the symbol it refers to. */ function skipExportSpecifierSymbol(symbol: Symbol, checker: TypeChecker): Symbol { // For `export { foo } from './bar", there's nothing to skip, because it does not create a new alias. But `export { foo } does. diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index ca0dafbc74c..c8958ad3d2f 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -5,6 +5,7 @@ namespace ts.JsDoc { "author", "argument", "borrows", + "callback", "class", "constant", "constructor", @@ -68,10 +69,12 @@ namespace ts.JsDoc { function getCommentHavingNodes(declaration: Declaration): ReadonlyArray { switch (declaration.kind) { + case SyntaxKind.JSDocParameterTag: case SyntaxKind.JSDocPropertyTag: return [declaration as JSDocPropertyTag]; + case SyntaxKind.JSDocCallbackTag: case SyntaxKind.JSDocTypedefTag: - return [(declaration as JSDocTypedefTag).parent]; + return [(declaration as JSDocTypedefTag), (declaration as JSDocTypedefTag).parent]; default: return getJSDocCommentsAndTags(declaration); } @@ -98,6 +101,7 @@ namespace ts.JsDoc { case SyntaxKind.JSDocTypeTag: return withNode((tag as JSDocTypeTag).typeExpression); case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JSDocCallbackTag: case SyntaxKind.JSDocPropertyTag: case SyntaxKind.JSDocParameterTag: const { name } = tag as JSDocTypedefTag | JSDocPropertyTag | JSDocParameterTag; diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 907003b7db7..c6f97ec2a1a 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -32,12 +32,43 @@ namespace ts.JsTyping { /* @internal */ export const nodeCoreModuleList: ReadonlyArray = [ - "buffer", "querystring", "events", "http", "cluster", - "zlib", "os", "https", "punycode", "repl", "readline", - "vm", "child_process", "url", "dns", "net", - "dgram", "fs", "path", "string_decoder", "tls", - "crypto", "stream", "util", "assert", "tty", "domain", - "constants", "process", "v8", "timers", "console"]; + "assert", + "async_hooks", + "buffer", + "child_process", + "cluster", + "console", + "constants", + "crypto", + "dgram", + "dns", + "domain", + "events", + "fs", + "http", + "https", + "http2", + "inspector", + "net", + "os", + "path", + "perf_hooks", + "process", + "punycode", + "querystring", + "readline", + "repl", + "stream", + "string_decoder", + "timers", + "tls", + "tty", + "url", + "util", + "v8", + "vm", + "zlib" + ]; /* @internal */ export const nodeCoreModules = arrayToSet(nodeCoreModuleList); diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index b029796e718..3ce18b91002 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -290,7 +290,7 @@ namespace ts.NavigationBar { if (hasJSDocNodes(node)) { forEach(node.jsDoc, jsDoc => { forEach(jsDoc.tags, tag => { - if (tag.kind === SyntaxKind.JSDocTypedefTag) { + if (isJSDocTypeAlias(tag)) { addLeafNode(tag); } }); @@ -414,8 +414,6 @@ namespace ts.NavigationBar { case SyntaxKind.ArrowFunction: case SyntaxKind.ClassExpression: return getFunctionOrClassName(node); - case SyntaxKind.JSDocTypedefTag: - return getJSDocTypedefTagName(node); default: return undefined; } @@ -460,31 +458,11 @@ namespace ts.NavigationBar { return "()"; case SyntaxKind.IndexSignature: return "[]"; - case SyntaxKind.JSDocTypedefTag: - return getJSDocTypedefTagName(node); default: return ""; } } - function getJSDocTypedefTagName(node: JSDocTypedefTag): string { - if (node.name) { - return node.name.text; - } - else { - const parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === SyntaxKind.VariableStatement) { - if (parentNode.declarationList.declarations.length > 0) { - const nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === SyntaxKind.Identifier) { - return nameIdentifier.text; - } - } - } - return ""; - } - } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ function topLevelItems(root: NavigationBarNode): NavigationBarNode[] { const topLevel: NavigationBarNode[] = []; @@ -511,6 +489,7 @@ namespace ts.NavigationBar { case SyntaxKind.SourceFile: case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.JSDocTypedefTag: + case SyntaxKind.JSDocCallbackTag: return true; case SyntaxKind.Constructor: diff --git a/src/services/organizeImports.ts b/src/services/organizeImports.ts index 5109b050b6b..99bac64973f 100644 --- a/src/services/organizeImports.ts +++ b/src/services/organizeImports.ts @@ -17,19 +17,32 @@ namespace ts.OrganizeImports { const changeTracker = textChanges.ChangeTracker.fromContext({ host, formatContext }); + const coalesceAndOrganizeImports = (importGroup: ReadonlyArray) => coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); + // All of the old ImportDeclarations in the file, in syntactic order. const topLevelImportDecls = sourceFile.statements.filter(isImportDeclaration); - organizeImportsWorker(topLevelImportDecls); + organizeImportsWorker(topLevelImportDecls, coalesceAndOrganizeImports); + + // All of the old ExportDeclarations in the file, in syntactic order. + const topLevelExportDecls = sourceFile.statements.filter(isExportDeclaration); + organizeImportsWorker(topLevelExportDecls, coalesceExports); for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) { const ambientModuleBody = getModuleBlock(ambientModule as ModuleDeclaration); + const ambientModuleImportDecls = ambientModuleBody.statements.filter(isImportDeclaration); - organizeImportsWorker(ambientModuleImportDecls); + organizeImportsWorker(ambientModuleImportDecls, coalesceAndOrganizeImports); + + const ambientModuleExportDecls = ambientModuleBody.statements.filter(isExportDeclaration); + organizeImportsWorker(ambientModuleExportDecls, coalesceExports); } return changeTracker.getChanges(); - function organizeImportsWorker(oldImportDecls: ReadonlyArray) { + function organizeImportsWorker( + oldImportDecls: ReadonlyArray, + coalesce: (group: ReadonlyArray) => ReadonlyArray) { + if (length(oldImportDecls) === 0) { return; } @@ -45,7 +58,7 @@ namespace ts.OrganizeImports { const sortedImportGroups = stableSort(oldImportGroups, (group1, group2) => compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier)); const newImportDecls = flatMap(sortedImportGroups, importGroup => getExternalModuleName(importGroup[0].moduleSpecifier) - ? coalesceImports(removeUnusedImports(importGroup, sourceFile, program)) + ? coalesce(importGroup) : importGroup); // Delete or replace the first import. @@ -131,7 +144,9 @@ namespace ts.OrganizeImports { } function getExternalModuleName(specifier: Expression) { - return isStringLiteralLike(specifier) ? specifier.text : undefined; + return specifier !== undefined && isStringLiteralLike(specifier) + ? specifier.text + : undefined; } /* @internal */ // Internal for testing @@ -189,16 +204,16 @@ namespace ts.OrganizeImports { newImportSpecifiers.push(...flatMap(namedImports, i => (i.importClause.namedBindings as NamedImports).elements)); - const sortedImportSpecifiers = stableSort(newImportSpecifiers, (s1, s2) => - compareIdentifiers(s1.propertyName || s1.name, s2.propertyName || s2.name) || - compareIdentifiers(s1.name, s2.name)); + const sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers); const importDecl = defaultImports.length > 0 ? defaultImports[0] : namedImports[0]; const newNamedImports = sortedImportSpecifiers.length === 0 - ? undefined + ? newDefaultImport + ? undefined + : createNamedImports(emptyArray) : namedImports.length === 0 ? createNamedImports(sortedImportSpecifiers) : updateNamedImports(namedImports[0].importClause.namedBindings as NamedImports, sortedImportSpecifiers); @@ -252,9 +267,69 @@ namespace ts.OrganizeImports { namedImports, }; } + } - function compareIdentifiers(s1: Identifier, s2: Identifier) { - return compareStringsCaseSensitive(s1.text, s2.text); + /* @internal */ // Internal for testing + /** + * @param exportGroup a list of ExportDeclarations, all with the same module name. + */ + export function coalesceExports(exportGroup: ReadonlyArray) { + if (exportGroup.length === 0) { + return exportGroup; + } + + const { exportWithoutClause, namedExports } = getCategorizedExports(exportGroup); + + const coalescedExports: ExportDeclaration[] = []; + + if (exportWithoutClause) { + coalescedExports.push(exportWithoutClause); + } + + if (namedExports.length === 0) { + return coalescedExports; + } + + const newExportSpecifiers: ExportSpecifier[] = []; + newExportSpecifiers.push(...flatMap(namedExports, i => (i.exportClause).elements)); + + const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers); + + const exportDecl = namedExports[0]; + coalescedExports.push( + updateExportDeclaration( + exportDecl, + exportDecl.decorators, + exportDecl.modifiers, + updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers), + exportDecl.moduleSpecifier)); + + return coalescedExports; + + /* + * Returns entire export declarations because they may already have been rewritten and + * may lack parent pointers. The desired parts can easily be recovered based on the + * categorization. + */ + function getCategorizedExports(exportGroup: ReadonlyArray) { + let exportWithoutClause: ExportDeclaration | undefined; + const namedExports: ExportDeclaration[] = []; + + for (const exportDeclaration of exportGroup) { + if (exportDeclaration.exportClause === undefined) { + // Only the first such export is interesting - the others are redundant. + // Note: Unfortunately, we will lose trivia that was on this node. + exportWithoutClause = exportWithoutClause || exportDeclaration; + } + else { + namedExports.push(exportDeclaration); + } + } + + return { + exportWithoutClause, + namedExports, + }; } } @@ -271,12 +346,22 @@ namespace ts.OrganizeImports { importDeclaration.moduleSpecifier); } + function sortSpecifiers(specifiers: ReadonlyArray) { + return stableSort(specifiers, (s1, s2) => + compareIdentifiers(s1.propertyName || s1.name, s2.propertyName || s2.name) || + compareIdentifiers(s1.name, s2.name)); + } + /* internal */ // Exported for testing export function compareModuleSpecifiers(m1: Expression, m2: Expression) { const name1 = getExternalModuleName(m1); const name2 = getExternalModuleName(m2); return compareBooleans(name1 === undefined, name2 === undefined) || compareBooleans(isExternalModuleNameRelative(name1), isExternalModuleNameRelative(name2)) || - compareStringsCaseSensitive(name1, name2); + compareStringsCaseInsensitive(name1, name2); } -} \ No newline at end of file + + function compareIdentifiers(s1: Identifier, s2: Identifier) { + return compareStringsCaseInsensitive(s1.text, s2.text); + } +} diff --git a/src/services/preProcess.ts b/src/services/preProcess.ts index 6c5f6c1b2ff..5f1378ddbb7 100644 --- a/src/services/preProcess.ts +++ b/src/services/preProcess.ts @@ -1,7 +1,7 @@ namespace ts { export function preProcessFile(sourceText: string, readImportFiles = true, detectJavaScriptImports = false): PreProcessedFileInfo { const pragmaContext: PragmaContext = { - languageVersion: ScriptTarget.ES5, // controls weather the token scanner considers unicode identifiers or not - shouldn't matter, since we're only using it for trivia + languageVersion: ScriptTarget.ES5, // controls whether the token scanner considers unicode identifiers or not - shouldn't matter, since we're only using it for trivia pragmas: undefined, checkJsDirective: undefined, referencedFiles: [], diff --git a/src/services/refactorProvider.ts b/src/services/refactorProvider.ts index f3504ed89b8..adb3af3ea7a 100644 --- a/src/services/refactorProvider.ts +++ b/src/services/refactorProvider.ts @@ -38,7 +38,7 @@ namespace ts { } } - export function getRefactorContextLength(context: RefactorContext): number { - return context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + export function getRefactorContextSpan({ startPosition, endPosition }: RefactorContext): TextSpan { + return createTextSpanFromBounds(startPosition, endPosition === undefined ? startPosition : endPosition); } } diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 5805a986180..32a39c8f9ad 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -8,7 +8,7 @@ namespace ts.refactor.extractSymbol { * Exported for tests. */ export function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined { - const rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: getRefactorContextLength(context) }); + const rangeToExtract = getRangeToExtract(context.file, getRefactorContextSpan(context)); const targetRange: TargetRange = rangeToExtract.targetRange; if (targetRange === undefined) { @@ -87,7 +87,7 @@ namespace ts.refactor.extractSymbol { /* Exported for tests */ export function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined { - const rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: getRefactorContextLength(context) }); + const rangeToExtract = getRangeToExtract(context.file, getRefactorContextSpan(context)); const targetRange: TargetRange = rangeToExtract.targetRange; const parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName); @@ -1464,8 +1464,8 @@ namespace ts.refactor.extractSymbol { } // Note that we add the current node's type parameters *after* updating the corresponding scope. - if (isDeclarationWithTypeParameters(curr) && curr.typeParameters) { - for (const typeParameterDecl of curr.typeParameters) { + if (isDeclarationWithTypeParameters(curr)) { + for (const typeParameterDecl of getEffectiveTypeParameterDeclarations(curr)) { const typeParameter = checker.getTypeAtLocation(typeParameterDecl) as TypeParameter; if (allTypeParameterUsages.has(typeParameter.id.toString())) { seenTypeParameterUsages.set(typeParameter.id.toString(), typeParameter); @@ -1534,20 +1534,8 @@ namespace ts.refactor.extractSymbol { return { target, usagesPerScope, functionErrorsPerScope, constantErrorsPerScope, exposedVariableDeclarations }; - function hasTypeParameters(node: Node) { - return isDeclarationWithTypeParameters(node) && - node.typeParameters !== undefined && - node.typeParameters.length > 0; - } - function isInGenericContext(node: Node) { - for (; node; node = node.parent) { - if (hasTypeParameters(node)) { - return true; - } - } - - return false; + return !!findAncestor(node, n => isDeclarationWithTypeParameters(n) && getEffectiveTypeParameterDeclarations(n).length !== 0); } function recordTypeParameterUsages(type: Type) { diff --git a/src/services/refactors/generateGetAccessorAndSetAccessor.ts b/src/services/refactors/generateGetAccessorAndSetAccessor.ts index 523ad97e5fa..92d87b1fcd0 100644 --- a/src/services/refactors/generateGetAccessorAndSetAccessor.ts +++ b/src/services/refactors/generateGetAccessorAndSetAccessor.ts @@ -11,15 +11,18 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor { interface Info { container: ContainerDeclaration; isStatic: boolean; + isReadonly: boolean; type: TypeNode | undefined; declaration: AcceptedDeclaration; fieldName: AcceptedNameType; accessorName: AcceptedNameType; + originalName: AcceptedNameType; + renameAccessor: boolean; } function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined { - const { file, startPosition } = context; - if (!getConvertibleFieldAtPosition(file, startPosition)) return undefined; + const { file } = context; + if (!getConvertibleFieldAtPosition(context, file)) return undefined; return [{ name: actionName, @@ -34,33 +37,54 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor { } function getEditsForAction(context: RefactorContext, _actionName: string): RefactorEditInfo | undefined { - const { file, startPosition } = context; + const { file } = context; - const fieldInfo = getConvertibleFieldAtPosition(file, startPosition); + const fieldInfo = getConvertibleFieldAtPosition(context, file); if (!fieldInfo) return undefined; const isJS = isSourceFileJavaScript(file); const changeTracker = textChanges.ChangeTracker.fromContext(context); - const { isStatic, fieldName, accessorName, type, container, declaration } = fieldInfo; + const { isStatic, isReadonly, fieldName, accessorName, originalName, type, container, declaration, renameAccessor } = fieldInfo; + + suppressLeadingAndTrailingTrivia(fieldName); + suppressLeadingAndTrailingTrivia(declaration); + suppressLeadingAndTrailingTrivia(container); const isInClassLike = isClassLike(container); + // avoid Readonly modifier because it will convert to get accessor + const modifierFlags = getModifierFlags(declaration) & ~ModifierFlags.Readonly; const accessorModifiers = isInClassLike - ? !declaration.modifiers || getModifierFlags(declaration) & ModifierFlags.Private ? getModifiers(isJS, isStatic, SyntaxKind.PublicKeyword) : declaration.modifiers + ? !modifierFlags || modifierFlags & ModifierFlags.Private + ? getModifiers(isJS, isStatic, SyntaxKind.PublicKeyword) + : createNodeArray(createModifiersFromModifierFlags(modifierFlags)) : undefined; const fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, SyntaxKind.PrivateKeyword) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); const getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); - const setAccessor = generateSetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); - + suppressLeadingAndTrailingTrivia(getAccessor); insertAccessor(changeTracker, file, getAccessor, declaration, container); - insertAccessor(changeTracker, file, setAccessor, declaration, container); + + if (isReadonly) { + // readonly modifier only existed in classLikeDeclaration + const constructor = getFirstConstructorWithBody(container); + if (constructor) { + updateReadonlyPropertyInitializerStatementConstructor(changeTracker, context, constructor, fieldName, originalName); + } + } + else { + const setAccessor = generateSetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); + suppressLeadingAndTrailingTrivia(setAccessor); + insertAccessor(changeTracker, file, setAccessor, declaration, container); + } const edits = changeTracker.getChanges(); const renameFilename = file.fileName; - const renameLocationOffset = isIdentifier(fieldName) ? 0 : -1; - const renameLocation = renameLocationOffset + getRenameLocation(edits, renameFilename, fieldName.text, /*preferLastLocation*/ isParameter(declaration)); + + const nameNeedRename = renameAccessor ? accessorName : fieldName; + const renameLocationOffset = isIdentifier(nameNeedRename) ? 0 : -1; + const renameLocation = renameLocationOffset + getRenameLocation(edits, renameFilename, nameNeedRename.text, /*preferLastLocation*/ isParameter(declaration)); return { renameFilename, renameLocation, edits }; } @@ -89,24 +113,34 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor { return modifiers && createNodeArray(modifiers); } - function getConvertibleFieldAtPosition(file: SourceFile, startPosition: number): Info | undefined { + function startsWithUnderscore(name: string): boolean { + return name.charCodeAt(0) === CharacterCodes._; + } + + function getConvertibleFieldAtPosition(context: RefactorContext, file: SourceFile): Info | undefined { + const { startPosition, endPosition } = context; + const node = getTokenAtPosition(file, startPosition, /*includeJsDocComment*/ false); const declaration = findAncestor(node.parent, isAcceptedDeclaration); - // make sure propertyDeclaration have AccessibilityModifier or Static Modifier - const meaning = ModifierFlags.AccessibilityModifier | ModifierFlags.Static; - if (!declaration || !isConvertableName(declaration.name) || (getModifierFlags(declaration) | meaning) !== meaning) return undefined; + // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier + const meaning = ModifierFlags.AccessibilityModifier | ModifierFlags.Static | ModifierFlags.Readonly; + if (!declaration || !rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) + || !isConvertableName(declaration.name) || (getModifierFlags(declaration) | meaning) !== meaning) return undefined; - const fieldName = createPropertyName(getUniqueName(`_${declaration.name.text}`, file.text), declaration.name); - const accessorName = createPropertyName(declaration.name.text, declaration.name); - suppressLeadingAndTrailingTrivia(fieldName); - suppressLeadingAndTrailingTrivia(declaration); + const name = declaration.name.text; + const startWithUnderscore = startsWithUnderscore(name); + const fieldName = createPropertyName(startWithUnderscore ? name : getUniqueName(`_${name}`, file.text), declaration.name); + const accessorName = createPropertyName(startWithUnderscore ? getUniqueName(name.substring(1), file.text) : name, declaration.name); return { isStatic: hasStaticModifier(declaration), + isReadonly: hasReadonlyModifier(declaration), type: getTypeAnnotationNode(declaration), container: declaration.kind === SyntaxKind.Parameter ? declaration.parent.parent : declaration.parent, + originalName: declaration.name, declaration, fieldName, accessorName, + renameAccessor: startWithUnderscore }; } @@ -159,7 +193,6 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor { declaration.type, declaration.initializer ); - changeTracker.replaceNode(file, declaration, property); } @@ -184,6 +217,28 @@ namespace ts.refactor.generateGetAccessorAndSetAccessor { function insertAccessor(changeTracker: textChanges.ChangeTracker, file: SourceFile, accessor: AccessorDeclaration, declaration: AcceptedDeclaration, container: ContainerDeclaration) { isParameterPropertyDeclaration(declaration) ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + : isPropertyAssignment(declaration) + ? changeTracker.insertNodeAfterComma(file, declaration, accessor) + : changeTracker.insertNodeAfter(file, declaration, accessor); + } + + function updateReadonlyPropertyInitializerStatementConstructor(changeTracker: textChanges.ChangeTracker, context: RefactorContext, constructor: ConstructorDeclaration, fieldName: AcceptedNameType, originalName: AcceptedNameType) { + if (!constructor.body) return; + const { file, program, cancellationToken } = context; + + const referenceEntries = mapDefined(FindAllReferences.getReferenceEntriesForNode(originalName.parent.pos, originalName, program, [file], cancellationToken), entry => ( + (entry.type === "node" && rangeContainsRange(constructor, entry.node) && isIdentifier(entry.node) && isWriteAccess(entry.node)) ? entry.node : undefined + )); + + forEach(referenceEntries, entry => { + const parent = entry.parent; + const accessorName = createIdentifier(fieldName.text); + const node = isBinaryExpression(parent) + ? updateBinary(parent, accessorName, parent.right, parent.operatorToken) + : isPropertyAccessExpression(parent) + ? updatePropertyAccess(parent, parent.expression, accessorName) + : Debug.fail("Unexpected write access token"); + changeTracker.replaceNode(file, parent, node); + }); } } diff --git a/src/services/refactors/moveToNewFile.ts b/src/services/refactors/moveToNewFile.ts new file mode 100644 index 00000000000..d0d0df4250e --- /dev/null +++ b/src/services/refactors/moveToNewFile.ts @@ -0,0 +1,671 @@ +/* @internal */ +namespace ts.refactor { + const refactorName = "Move to a new file"; + registerRefactor(refactorName, { + getAvailableActions(context): ApplicableRefactorInfo[] { + if (!context.preferences.allowTextChangesInNewFiles || getFirstAndLastStatementToMove(context) === undefined) return undefined; + const description = getLocaleSpecificMessage(Diagnostics.Move_to_a_new_file); + return [{ name: refactorName, description, actions: [{ name: refactorName, description }] }]; + }, + getEditsForAction(context, actionName): RefactorEditInfo { + Debug.assert(actionName === refactorName); + const statements = Debug.assertDefined(getStatementsToMove(context)); + const edits = textChanges.ChangeTracker.with(context, t => doChange(context.file, context.program, statements, t, context.host)); + return { edits, renameFilename: undefined, renameLocation: undefined }; + } + }); + + function getFirstAndLastStatementToMove(context: RefactorContext): { readonly first: number, readonly afterLast: number } | undefined { + const { file } = context; + const range = createTextRangeFromSpan(getRefactorContextSpan(context)); + const { statements } = file; + + const startNodeIndex = findIndex(statements, s => s.end > range.pos); + if (startNodeIndex === -1) return undefined; + // Can't only partially include the start node or be partially into the next node + if (range.pos > statements[startNodeIndex].getStart(file)) return undefined; + const afterEndNodeIndex = findIndex(statements, s => s.end > range.end, startNodeIndex); + // Can't be partially into the next node + if (afterEndNodeIndex !== -1 && (afterEndNodeIndex === 0 || statements[afterEndNodeIndex].getStart(file) < range.end)) return undefined; + + return { first: startNodeIndex, afterLast: afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex }; + } + + function doChange(oldFile: SourceFile, program: Program, toMove: ToMove, changes: textChanges.ChangeTracker, host: LanguageServiceHost): void { + const checker = program.getTypeChecker(); + const usage = getUsageInfo(oldFile, toMove.all, checker); + + const currentDirectory = getDirectoryPath(oldFile.fileName); + const extension = extensionFromPath(oldFile.fileName); + const newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host); + const newFileNameWithExtension = newModuleName + extension; + + // If previous file was global, this is easy. + changes.createNewFile(oldFile, combinePaths(currentDirectory, newFileNameWithExtension), getNewStatements(oldFile, usage, changes, toMove, program, newModuleName)); + + addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, hostGetCanonicalFileName(host)); + } + + interface StatementRange { + readonly first: Statement; + readonly last: Statement; + } + interface ToMove { + readonly all: ReadonlyArray; + readonly ranges: ReadonlyArray; + } + + // Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file. + function getStatementsToMove(context: RefactorContext): ToMove | undefined { + const { statements } = context.file; + const { first, afterLast } = getFirstAndLastStatementToMove(context)!; + const all: Statement[] = []; + const ranges: StatementRange[] = []; + const rangeToMove = statements.slice(first, afterLast); + getRangesWhere(rangeToMove, s => !isPureImport(s), (start, afterEnd) => { + for (let i = start; i < afterEnd; i++) all.push(rangeToMove[i]); + ranges.push({ first: rangeToMove[start], last: rangeToMove[afterEnd - 1] }); + }); + return { all, ranges }; + } + + function isPureImport(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + return true; + case SyntaxKind.ImportEqualsDeclaration: + return !hasModifier(node, ModifierFlags.Export); + case SyntaxKind.VariableStatement: + return (node as VariableStatement).declarationList.declarations.every(d => isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true)); + default: + return false; + } + } + + function addNewFileToTsconfig(program: Program, changes: textChanges.ChangeTracker, oldFileName: string, newFileNameWithExtension: string, getCanonicalFileName: GetCanonicalFileName): void { + const cfg = program.getCompilerOptions().configFile; + if (!cfg) return; + + const newFileAbsolutePath = normalizePath(combinePaths(oldFileName, "..", newFileNameWithExtension)); + const newFilePath = getRelativePathFromFile(cfg.fileName, newFileAbsolutePath, getCanonicalFileName); + + const cfgObject = cfg.statements[0] && tryCast(cfg.statements[0].expression, isObjectLiteralExpression); + const filesProp = cfgObject && find(cfgObject.properties, (prop): prop is PropertyAssignment => + isPropertyAssignment(prop) && isStringLiteral(prop.name) && prop.name.text === "files"); + if (filesProp && isArrayLiteralExpression(filesProp.initializer)) { + changes.insertNodeInListAfter(cfg, last(filesProp.initializer.elements), createLiteral(newFilePath), filesProp.initializer.elements); + } + } + + function getNewStatements( + oldFile: SourceFile, usage: UsageInfo, changes: textChanges.ChangeTracker, toMove: ToMove, program: Program, newModuleName: string, + ): ReadonlyArray { + const checker = program.getTypeChecker(); + + if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) { + deleteMovedStatements(oldFile, toMove.ranges, changes); + return toMove.all; + } + + const useEs6ModuleSyntax = !!oldFile.externalModuleIndicator; + const importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax); + if (importsFromNewFile) { + changes.insertNodeBefore(oldFile, oldFile.statements[0], importsFromNewFile, /*blankLineBetween*/ true); + } + + deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); + deleteMovedStatements(oldFile, toMove.ranges, changes); + + updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); + + return [ + ...getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax), + ...addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax), + ]; + } + + function deleteMovedStatements(sourceFile: SourceFile, moved: ReadonlyArray, changes: textChanges.ChangeTracker) { + for (const { first, last } of moved) { + changes.deleteNodeRange(sourceFile, first, last); + } + } + + function deleteUnusedOldImports(oldFile: SourceFile, toMove: ReadonlyArray, changes: textChanges.ChangeTracker, toDelete: ReadonlySymbolSet, checker: TypeChecker) { + for (const statement of oldFile.statements) { + if (contains(toMove, statement)) continue; + forEachImportInStatement(statement, i => deleteUnusedImports(oldFile, i, changes, name => toDelete.has(checker.getSymbolAtLocation(name)))); + } + } + + function updateImportsInOtherFiles(changes: textChanges.ChangeTracker, program: Program, oldFile: SourceFile, movedSymbols: ReadonlySymbolSet, newModuleName: string): void { + const checker = program.getTypeChecker(); + for (const sourceFile of program.getSourceFiles()) { + if (sourceFile === oldFile) continue; + for (const statement of sourceFile.statements) { + forEachImportInStatement(statement, importNode => { + const shouldMove = (name: Identifier): boolean => { + const symbol = isBindingElement(name.parent) + ? getPropertySymbolFromBindingElement(checker, name.parent as BindingElement & { name: Identifier }) + : skipAlias(checker.getSymbolAtLocation(name), checker); + return !!symbol && movedSymbols.has(symbol); + }; + deleteUnusedImports(sourceFile, importNode, changes, shouldMove); // These will be changed to imports from the new file + const newModuleSpecifier = combinePaths(getDirectoryPath(moduleSpecifierFromImport(importNode).text), newModuleName); + const newImportDeclaration = filterImport(importNode, createLiteral(newModuleSpecifier), shouldMove); + if (newImportDeclaration) changes.insertNodeAfter(sourceFile, statement, newImportDeclaration); + }); + } + } + } + + function moduleSpecifierFromImport(i: SupportedImport): StringLiteralLike { + return (i.kind === SyntaxKind.ImportDeclaration ? i.moduleSpecifier + : i.kind === SyntaxKind.ImportEqualsDeclaration ? i.moduleReference.expression + : i.initializer.arguments[0]); + } + + function forEachImportInStatement(statement: Statement, cb: (importNode: SupportedImport) => void): void { + if (isImportDeclaration(statement)) { + if (isStringLiteral(statement.moduleSpecifier)) cb(statement as SupportedImport); + } + else if (isImportEqualsDeclaration(statement)) { + if (isExternalModuleReference(statement.moduleReference) && isStringLiteralLike(statement.moduleReference.expression)) { + cb(statement as SupportedImport); + } + } + else if (isVariableStatement(statement)) { + for (const decl of statement.declarationList.declarations) { + if (decl.initializer && isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true)) { + cb(decl as SupportedImport); + } + } + } + } + + type SupportedImport = + | ImportDeclaration & { moduleSpecifier: StringLiteralLike } + | ImportEqualsDeclaration & { moduleReference: ExternalModuleReference & { expression: StringLiteralLike } } + | VariableDeclaration & { initializer: RequireOrImportCall }; + type SupportedImportStatement = + | ImportDeclaration + | ImportEqualsDeclaration + | VariableStatement; + + function createOldFileImportsFromNewFile(newFileNeedExport: ReadonlySymbolSet, newFileNameWithExtension: string, useEs6Imports: boolean): Statement | undefined { + let defaultImport: Identifier | undefined; + const imports: string[] = []; + newFileNeedExport.forEach(symbol => { + if (symbol.escapedName === InternalSymbolName.Default) { + defaultImport = createIdentifier(symbolNameNoDefault(symbol)); + } + else { + imports.push(symbol.name); + } + }); + return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports); + } + + function makeImportOrRequire(defaultImport: Identifier | undefined, imports: ReadonlyArray, path: string, useEs6Imports: boolean): Statement | undefined { + path = ensurePathIsNonModuleName(path); + if (useEs6Imports) { + const specifiers = imports.map(i => createImportSpecifier(/*propertyName*/ undefined, createIdentifier(i))); + return makeImportIfNecessary(defaultImport, specifiers, path); + } + else { + Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + const bindingElements = imports.map(i => createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i)); + return bindingElements.length + ? makeVariableStatement(createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(createLiteral(path))) + : undefined; + } + } + + function makeVariableStatement(name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined, flags: NodeFlags = NodeFlags.Const) { + return createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([createVariableDeclaration(name, type, initializer)], flags)); + } + + function createRequireCall(moduleSpecifier: StringLiteralLike): CallExpression { + return createCall(createIdentifier("require"), /*typeArguments*/ undefined, [moduleSpecifier]); + } + + function addExports(sourceFile: SourceFile, toMove: ReadonlyArray, needExport: ReadonlySymbolSet, useEs6Exports: boolean): ReadonlyArray { + return flatMap(toMove, statement => { + if (isTopLevelDeclarationStatement(statement) && + !isExported(sourceFile, statement, useEs6Exports) && + forEachTopLevelDeclaration(statement, d => needExport.has(Debug.assertDefined(d.symbol)))) { + const exports = addExport(statement, useEs6Exports); + if (exports) return exports; + } + return statement; + }); + } + + function deleteUnusedImports(sourceFile: SourceFile, importDecl: SupportedImport, changes: textChanges.ChangeTracker, isUnused: (name: Identifier) => boolean): void { + switch (importDecl.kind) { + case SyntaxKind.ImportDeclaration: + deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); + break; + case SyntaxKind.ImportEqualsDeclaration: + if (isUnused(importDecl.name)) { + changes.deleteNode(sourceFile, importDecl); + } + break; + case SyntaxKind.VariableDeclaration: + deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); + break; + default: + Debug.assertNever(importDecl); + } + } + function deleteUnusedImportsInDeclaration(sourceFile: SourceFile, importDecl: ImportDeclaration, changes: textChanges.ChangeTracker, isUnused: (name: Identifier) => boolean): void { + if (!importDecl.importClause) return; + const { name, namedBindings } = importDecl.importClause; + const defaultUnused = !name || isUnused(name); + const namedBindingsUnused = !namedBindings || + (namedBindings.kind === SyntaxKind.NamespaceImport ? isUnused(namedBindings.name) : namedBindings.elements.every(e => isUnused(e.name))); + if (defaultUnused && namedBindingsUnused) { + changes.deleteNode(sourceFile, importDecl); + } + else { + if (name && defaultUnused) { + changes.deleteNode(sourceFile, name); + } + if (namedBindings) { + if (namedBindingsUnused) { + changes.deleteNode(sourceFile, namedBindings); + } + else if (namedBindings.kind === SyntaxKind.NamedImports) { + for (const element of namedBindings.elements) { + if (isUnused(element.name)) changes.deleteNodeInList(sourceFile, element); + } + } + } + } + } + function deleteUnusedImportsInVariableDeclaration(sourceFile: SourceFile, varDecl: VariableDeclaration, changes: textChanges.ChangeTracker, isUnused: (name: Identifier) => boolean) { + const { name } = varDecl; + switch (name.kind) { + case SyntaxKind.Identifier: + if (isUnused(name)) { + changes.deleteNode(sourceFile, name); + } + break; + case SyntaxKind.ArrayBindingPattern: + break; + case SyntaxKind.ObjectBindingPattern: + if (name.elements.every(e => isIdentifier(e.name) && isUnused(e.name))) { + changes.deleteNode(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); + } + } + } + break; + } + } + + function getNewFileImportsAndAddExportInOldFile( + oldFile: SourceFile, + importsToCopy: ReadonlySymbolSet, + newFileImportsFromOldFile: ReadonlySymbolSet, + changes: textChanges.ChangeTracker, + checker: TypeChecker, + useEs6ModuleSyntax: boolean, + ): ReadonlyArray { + const copiedOldImports: SupportedImportStatement[] = []; + for (const oldStatement of oldFile.statements) { + forEachImportInStatement(oldStatement, i => { + append(copiedOldImports, filterImport(i, moduleSpecifierFromImport(i), name => importsToCopy.has(checker.getSymbolAtLocation(name)))); + }); + } + + // Also, import things used from the old file, and insert 'export' modifiers as necessary in the old file. + let oldFileDefault: Identifier | undefined; + const oldFileNamedImports: string[] = []; + const markSeenTop = nodeSeenTracker(); // Needed because multiple declarations may appear in `const x = 0, y = 1;`. + newFileImportsFromOldFile.forEach(symbol => { + for (const decl of symbol.declarations) { + if (!isTopLevelDeclaration(decl)) continue; + const name = nameOfTopLevelDeclaration(decl); + if (!name) continue; + + const top = getTopLevelDeclarationStatement(decl); + if (markSeenTop(top)) { + addExportToChanges(oldFile, top, changes, useEs6ModuleSyntax); + } + if (hasModifier(decl, ModifierFlags.Default)) { + oldFileDefault = name; + } + else { + oldFileNamedImports.push(name.text); + } + } + }); + + append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, removeFileExtension(getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax)); + return copiedOldImports; + } + + function makeUniqueModuleName(moduleName: string, extension: string, inDirectory: string, host: LanguageServiceHost): string { + let newModuleName = moduleName; + for (let i = 1; ; i++) { + const name = combinePaths(inDirectory, newModuleName + extension); + if (!host.fileExists(name)) return newModuleName; + newModuleName = `${moduleName}.${i}`; + } + } + + function getNewModuleName(movedSymbols: ReadonlySymbolSet): string { + return movedSymbols.forEachEntry(symbolNameNoDefault) || "newFile"; + } + + interface UsageInfo { + // Symbols whose declarations are moved from the old file to the new file. + readonly movedSymbols: ReadonlySymbolSet; + + // Symbols declared in the old file that must be imported by the new file. (May not already be exported.) + readonly newFileImportsFromOldFile: ReadonlySymbolSet; + // Subset of movedSymbols that are still used elsewhere in the old file and must be imported back. + readonly oldFileImportsFromNewFile: ReadonlySymbolSet; + + readonly oldImportsNeededByNewFile: ReadonlySymbolSet; + // Subset of oldImportsNeededByNewFile that are will no longer be used in the old file. + readonly unusedImportsFromOldFile: ReadonlySymbolSet; + } + function getUsageInfo(oldFile: SourceFile, toMove: ReadonlyArray, checker: TypeChecker): UsageInfo { + const movedSymbols = new SymbolSet(); + const oldImportsNeededByNewFile = new SymbolSet(); + const newFileImportsFromOldFile = new SymbolSet(); + + for (const statement of toMove) { + forEachTopLevelDeclaration(statement, decl => { + movedSymbols.add(Debug.assertDefined(isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + }); + } + for (const statement of toMove) { + forEachReference(statement, checker, symbol => { + if (!symbol.declarations) return; + for (const decl of symbol.declarations) { + if (isInImport(decl)) { + oldImportsNeededByNewFile.add(symbol); + } + else if (isTopLevelDeclaration(decl) && !movedSymbols.has(symbol)) { + newFileImportsFromOldFile.add(symbol); + } + } + }); + } + + const unusedImportsFromOldFile = oldImportsNeededByNewFile.clone(); + + const oldFileImportsFromNewFile = new SymbolSet(); + for (const statement of oldFile.statements) { + if (contains(toMove, statement)) continue; + + forEachReference(statement, checker, symbol => { + if (movedSymbols.has(symbol)) oldFileImportsFromNewFile.add(symbol); + unusedImportsFromOldFile.delete(symbol); + }); + } + + return { movedSymbols, newFileImportsFromOldFile, oldFileImportsFromNewFile, oldImportsNeededByNewFile, unusedImportsFromOldFile }; + } + + // Below should all be utilities + + function isInImport(decl: Declaration) { + switch (decl.kind) { + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ImportSpecifier: + case SyntaxKind.ImportClause: + return true; + case SyntaxKind.VariableDeclaration: + return isVariableDeclarationInImport(decl as VariableDeclaration); + case SyntaxKind.BindingElement: + return isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); + default: + return false; + } + } + function isVariableDeclarationInImport(decl: VariableDeclaration) { + return isSourceFile(decl.parent.parent.parent) && + decl.initializer && isRequireCall(decl.initializer, /*checkArgumentIsStringLiteralLike*/ true); + } + + function filterImport(i: SupportedImport, moduleSpecifier: StringLiteralLike, keep: (name: Identifier) => boolean): SupportedImportStatement | undefined { + switch (i.kind) { + case SyntaxKind.ImportDeclaration: { + const clause = i.importClause; + if (!clause) return undefined; + const defaultImport = clause.name && keep(clause.name) ? clause.name : undefined; + const namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep); + return defaultImport || namedBindings + ? createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createImportClause(defaultImport, namedBindings), moduleSpecifier) + : undefined; + } + case SyntaxKind.ImportEqualsDeclaration: + return keep(i.name) ? i : undefined; + case SyntaxKind.VariableDeclaration: { + const name = filterBindingName(i.name, keep); + return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; + } + default: + return Debug.assertNever(i); + } + } + function filterNamedBindings(namedBindings: NamedImportBindings, keep: (name: Identifier) => boolean): NamedImportBindings | undefined { + if (namedBindings.kind === SyntaxKind.NamespaceImport) { + return keep(namedBindings.name) ? namedBindings : undefined; + } + else { + const newElements = namedBindings.elements.filter(e => keep(e.name)); + return newElements.length ? createNamedImports(newElements) : undefined; + } + } + function filterBindingName(name: BindingName, keep: (name: Identifier) => boolean): BindingName | undefined { + switch (name.kind) { + case SyntaxKind.Identifier: + return keep(name) ? name : undefined; + case SyntaxKind.ArrayBindingPattern: + return name; + case SyntaxKind.ObjectBindingPattern: { + // We can't handle nested destructurings or property names well here, so just copy them all. + const newElements = name.elements.filter(prop => prop.propertyName || !isIdentifier(prop.name) || keep(prop.name)); + return newElements.length ? createObjectBindingPattern(newElements) : undefined; + } + } + } + + function forEachReference(node: Node, checker: TypeChecker, onReference: (s: Symbol) => void) { + node.forEachChild(function cb(node) { + if (isIdentifier(node) && !isDeclarationName(node)) { + const sym = checker.getSymbolAtLocation(node); + if (sym) onReference(sym); + } + else { + node.forEachChild(cb); + } + }); + } + + interface ReadonlySymbolSet { + has(symbol: Symbol): boolean; + forEach(cb: (symbol: Symbol) => void): void; + forEachEntry(cb: (symbol: Symbol) => T | undefined): T | undefined; + } + class SymbolSet implements ReadonlySymbolSet { + private map = createMap(); + add(symbol: Symbol): void { + this.map.set(String(getSymbolId(symbol)), symbol); + } + has(symbol: Symbol): boolean { + return this.map.has(String(getSymbolId(symbol))); + } + delete(symbol: Symbol): void { + this.map.delete(String(getSymbolId(symbol))); + } + forEach(cb: (symbol: Symbol) => void): void { + this.map.forEach(cb); + } + forEachEntry(cb: (symbol: Symbol) => T | undefined): T | undefined { + return forEachEntry(this.map, cb); + } + clone(): SymbolSet { + const clone = new SymbolSet(); + copyEntries(this.map, clone.map); + return clone; + } + } + + type TopLevelExpressionStatement = ExpressionStatement & { expression: BinaryExpression & { left: PropertyAccessExpression } }; // 'exports.x = ...' + type NonVariableTopLevelDeclaration = + | FunctionDeclaration + | ClassDeclaration + | EnumDeclaration + | TypeAliasDeclaration + | InterfaceDeclaration + | ModuleDeclaration + | TopLevelExpressionStatement + | ImportEqualsDeclaration; + type TopLevelDeclarationStatement = NonVariableTopLevelDeclaration | VariableStatement; + interface TopLevelVariableDeclaration extends VariableDeclaration { parent: VariableDeclarationList & { parent: VariableStatement; }; } + type TopLevelDeclaration = NonVariableTopLevelDeclaration | TopLevelVariableDeclaration; + function isTopLevelDeclaration(node: Node): node is TopLevelDeclaration { + return isNonVariableTopLevelDeclaration(node) || isVariableDeclaration(node) && isSourceFile(node.parent.parent.parent); + } + + function isTopLevelDeclarationStatement(node: Node): node is TopLevelDeclarationStatement { + Debug.assert(isSourceFile(node.parent)); + return isNonVariableTopLevelDeclaration(node) || isVariableStatement(node); + } + + function isNonVariableTopLevelDeclaration(node: Node): node is NonVariableTopLevelDeclaration { + switch (node.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + return true; + default: + return false; + } + } + + function forEachTopLevelDeclaration(statement: Statement, cb: (node: TopLevelDeclaration) => T): T { + switch (statement.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + return cb(statement as FunctionDeclaration | ClassDeclaration | EnumDeclaration | ModuleDeclaration | TypeAliasDeclaration | InterfaceDeclaration | ImportEqualsDeclaration); + + case SyntaxKind.VariableStatement: + return forEach((statement as VariableStatement).declarationList.declarations as ReadonlyArray, cb); + + case SyntaxKind.ExpressionStatement: { + const { expression } = statement as ExpressionStatement; + return isBinaryExpression(expression) && getSpecialPropertyAssignmentKind(expression) === SpecialPropertyAssignmentKind.ExportsProperty + ? cb(statement as TopLevelExpressionStatement) + : undefined; + } + } + } + + function nameOfTopLevelDeclaration(d: TopLevelDeclaration): Identifier | undefined { + return d.kind === SyntaxKind.ExpressionStatement ? d.expression.left.name : tryCast(d.name, isIdentifier); + } + + function getTopLevelDeclarationStatement(d: TopLevelDeclaration): TopLevelDeclarationStatement { + return isVariableDeclaration(d) ? d.parent.parent : d; + } + + function addExportToChanges(sourceFile: SourceFile, decl: TopLevelDeclarationStatement, changes: textChanges.ChangeTracker, useEs6Exports: boolean): void { + if (isExported(sourceFile, decl, useEs6Exports)) return; + if (useEs6Exports) { + if (!isExpressionStatement(decl)) changes.insertExportModifier(sourceFile, decl); + } + else { + const names = getNamesToExportInCommonJS(decl); + if (names.length !== 0) changes.insertNodesAfter(sourceFile, decl, names.map(createExportAssignment)); + } + } + + function isExported(sourceFile: SourceFile, decl: TopLevelDeclarationStatement, useEs6Exports: boolean): boolean { + if (useEs6Exports) { + return !isExpressionStatement(decl) && hasModifier(decl, ModifierFlags.Export); + } + else { + return getNamesToExportInCommonJS(decl).some(name => sourceFile.symbol.exports.has(escapeLeadingUnderscores(name))); + } + } + + function addExport(decl: TopLevelDeclarationStatement, useEs6Exports: boolean): ReadonlyArray | undefined { + return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); + } + function addEs6Export(d: TopLevelDeclarationStatement): TopLevelDeclarationStatement { + const modifiers = concatenate([createModifier(SyntaxKind.ExportKeyword)], d.modifiers); + switch (d.kind) { + case SyntaxKind.FunctionDeclaration: + return updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); + case SyntaxKind.ClassDeclaration: + return updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); + case SyntaxKind.VariableStatement: + return updateVariableStatement(d, modifiers, d.declarationList); + case SyntaxKind.ModuleDeclaration: + return updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); + case SyntaxKind.EnumDeclaration: + return updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); + case SyntaxKind.TypeAliasDeclaration: + return updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); + case SyntaxKind.InterfaceDeclaration: + return updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); + case SyntaxKind.ImportEqualsDeclaration: + return updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); + case SyntaxKind.ExpressionStatement: + return Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + default: + return Debug.assertNever(d); + } + } + function addCommonjsExport(decl: TopLevelDeclarationStatement): ReadonlyArray | undefined { + return [decl, ...getNamesToExportInCommonJS(decl).map(createExportAssignment)]; + } + function getNamesToExportInCommonJS(decl: TopLevelDeclarationStatement): ReadonlyArray { + switch (decl.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ClassDeclaration: + return [decl.name.text]; + case SyntaxKind.VariableStatement: + return mapDefined(decl.declarationList.declarations, d => isIdentifier(d.name) ? d.name.text : undefined); + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.EnumDeclaration: + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.InterfaceDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + return undefined; + case SyntaxKind.ExpressionStatement: + return Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + default: + Debug.assertNever(decl); + } + } + + /** Creates `exports.x = x;` */ + function createExportAssignment(name: string): Statement { + return createExpressionStatement( + createBinary( + createPropertyAccess(createIdentifier("exports"), createIdentifier(name)), + SyntaxKind.EqualsToken, + createIdentifier(name))); + } +} diff --git a/src/services/rename.ts b/src/services/rename.ts index 2f9de0c0cad..0fd7ce5e7b5 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -36,6 +36,9 @@ namespace ts.Rename { return undefined; } + // Can't rename a module name. + if (isStringLiteralLike(node) && tryGetImportFromModuleSpecifier(node)) return undefined; + const kind = SymbolDisplay.getSymbolKind(typeChecker, symbol, node); const specifierName = (isImportOrExportSpecifierName(node) || isStringOrNumericLiteral(node) && node.parent.kind === SyntaxKind.ComputedPropertyName) ? stripQuotes(getTextOfIdentifierOrLiteral(node)) diff --git a/src/services/services.ts b/src/services/services.ts index 700b07085a0..3fcd4e8e151 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1600,10 +1600,10 @@ namespace ts { function makeGetTargetOfMappedPosition( extract: (original: TIn) => sourcemaps.SourceMappableLocation, - create: (result: sourcemaps.SourceMappableLocation, original: TIn) => TIn + create: (result: sourcemaps.SourceMappableLocation, unmapped: TIn, original: TIn) => TIn ) { return getTargetOfMappedPosition; - function getTargetOfMappedPosition(input: TIn): TIn { + function getTargetOfMappedPosition(input: TIn, original = input): TIn { const info = extract(input); if (endsWith(info.fileName, Extension.Dts)) { let file: SourceFileLike = program.getSourceFile(info.fileName); @@ -1617,7 +1617,7 @@ namespace ts { const mapper = getSourceMapper(info.fileName, file); const newLoc = mapper.getOriginalPosition(info); if (newLoc === info) return input; - return getTargetOfMappedPosition(create(newLoc, input)); + return getTargetOfMappedPosition(create(newLoc, input, original), original); } return input; } @@ -1625,7 +1625,7 @@ namespace ts { const getTargetOfMappedDeclarationInfo = makeGetTargetOfMappedPosition( (info: DefinitionInfo) => ({ fileName: info.fileName, position: info.textSpan.start }), - (newLoc, info) => ({ + (newLoc, info, original) => ({ containerKind: info.containerKind, containerName: info.containerName, fileName: newLoc.fileName, @@ -1634,12 +1634,14 @@ namespace ts { textSpan: { start: newLoc.position, length: info.textSpan.length - } + }, + originalFileName: original.fileName, + originalTextSpan: original.textSpan }) ); function getTargetOfMappedDeclarationFiles(infos: ReadonlyArray): DefinitionInfo[] { - return map(infos, getTargetOfMappedDeclarationInfo); + return map(infos, d => getTargetOfMappedDeclarationInfo(d)); } /// Goto definition @@ -1678,12 +1680,14 @@ namespace ts { textSpan: { start: newLoc.position, length: info.textSpan.length - } + }, + originalFileName: info.fileName, + originalTextSpan: info.textSpan }) ); function getTargetOfMappedImplementationLocations(infos: ReadonlyArray): ImplementationLocation[] { - return map(infos, getTargetOfMappedImplementationLocation); + return map(infos, d => getTargetOfMappedImplementationLocation(d)); } function getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] { diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index 0c8ec58798c..3135fdc368b 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -5,7 +5,9 @@ namespace ts { const checker = program.getDiagnosticsProducingTypeChecker(); const diags: Diagnostic[] = []; - if (sourceFile.commonJsModuleIndicator && (programContainsEs6Modules(program) || compilerOptionsIndicateEs6Modules(program.getCompilerOptions()))) { + if (sourceFile.commonJsModuleIndicator && + (programContainsEs6Modules(program) || compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) && + containsTopLevelCommonjs(sourceFile)) { diags.push(createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module)); } @@ -58,7 +60,30 @@ namespace ts { } } - return diags.concat(checker.getSuggestionDiagnostics(sourceFile)); + return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort((d1, d2) => d1.start - d2.start); + } + + // convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes. + function containsTopLevelCommonjs(sourceFile: SourceFile): boolean { + return sourceFile.statements.some(statement => { + switch (statement.kind) { + case SyntaxKind.VariableStatement: + return (statement as VariableStatement).declarationList.declarations.some(decl => + isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true)); + case SyntaxKind.ExpressionStatement: { + const { expression } = statement as ExpressionStatement; + if (!isBinaryExpression(expression)) return isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); + const kind = getSpecialPropertyAssignmentKind(expression); + return kind === SpecialPropertyAssignmentKind.ExportsProperty || kind === SpecialPropertyAssignmentKind.ModuleExports; + } + default: + return false; + } + }); + } + + function propertyAccessLeftHandSide(node: Expression): Expression { + return isPropertyAccessExpression(node) ? propertyAccessLeftHandSide(node.expression) : node; } function importNameForConvertToDefaultImport(node: AnyValidImportOrReExport): Identifier | undefined { diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index eca1c639196..6002b79d2c4 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -211,7 +211,8 @@ namespace ts.textChanges { export class ChangeTracker { private readonly changes: Change[] = []; - private readonly deletedNodesInLists: true[] = []; // Stores ids of nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. + 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 public static fromContext(context: TextChangesContext): ChangeTracker { @@ -261,35 +262,15 @@ namespace ts.textChanges { this.deleteNode(sourceFile, node); return this; } - const id = getNodeId(node); - Debug.assert(!this.deletedNodesInLists[id], "Deleting a node twice"); - this.deletedNodesInLists[id] = true; - if (index !== containingList.length - 1) { - const nextToken = getTokenAtPosition(sourceFile, node.end, /*includeJsDocComment*/ false); - if (nextToken && isSeparator(node, nextToken)) { - // find first non-whitespace position in the leading trivia of the node - const startPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); - const nextElement = containingList[index + 1]; - /// find first non-whitespace position in the leading trivia of the next node - const endPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); - // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node - this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); - } - } - else { - const prev = containingList[index - 1]; - if (this.deletedNodesInLists[getNodeId(prev)]) { - const pos = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); - const end = getAdjustedEndPosition(sourceFile, node, {}); - this.deleteRange(sourceFile, { pos, end }); - } - else { - const previousToken = getTokenAtPosition(sourceFile, containingList[index - 1].end, /*includeJsDocComment*/ false); - if (previousToken && isSeparator(node, previousToken)) { - this.deleteNodeRange(sourceFile, previousToken, node); - } - } - } + + // 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; } @@ -319,10 +300,14 @@ namespace ts.textChanges { return this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); } + private nextCommaToken (sourceFile: SourceFile, node: Node): Node | undefined { + const next = findNextToken(node, node.parent, sourceFile); + return next && next.kind === SyntaxKind.CommaToken ? next : undefined; + } + public replacePropertyAssignment(sourceFile: SourceFile, oldNode: PropertyAssignment, newNode: PropertyAssignment) { - return this.replaceNode(sourceFile, oldNode, newNode, { - suffix: "," + this.newLineCharacter - }); + const suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); + return this.replaceNode(sourceFile, oldNode, newNode, { suffix }); } private insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) { @@ -359,7 +344,8 @@ namespace ts.textChanges { // Otherwise, add an extra new line immediately before the error span. const insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); const token = getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position, /*includeJsDocComment*/ false); - const text = `${insertAtLineStart ? "" : this.newLineCharacter}${sourceFile.text.slice(lineStartPosition, startPosition)}//${commentText}${this.newLineCharacter}`; + const indent = sourceFile.text.slice(lineStartPosition, startPosition); + const text = `${insertAtLineStart ? "" : this.newLineCharacter}//${commentText}${this.newLineCharacter}${indent}`; this.insertText(sourceFile, token.getStart(sourceFile), text); } @@ -463,7 +449,22 @@ namespace ts.textChanges { } } - public insertNodeAfter(sourceFile: SourceFile, after: Node, newNode: Node): this { + public insertNodeAfterComma(sourceFile: SourceFile, after: Node, newNode: Node): void { + const endPosition = this.insertNodeAfterWorker(sourceFile, this.nextCommaToken(sourceFile, after) || after, newNode); + this.insertNodeAt(sourceFile, endPosition, newNode, this.getInsertNodeAfterOptions(sourceFile, after)); + } + + public insertNodeAfter(sourceFile: SourceFile, after: Node, newNode: Node): void { + const endPosition = this.insertNodeAfterWorker(sourceFile, after, newNode); + this.insertNodeAt(sourceFile, endPosition, newNode, this.getInsertNodeAfterOptions(sourceFile, after)); + } + + public insertNodesAfter(sourceFile: SourceFile, after: Node, newNodes: ReadonlyArray): void { + const endPosition = this.insertNodeAfterWorker(sourceFile, after, first(newNodes)); + this.insertNodesAt(sourceFile, endPosition, newNodes, this.getInsertNodeAfterOptions(sourceFile, after)); + } + + private insertNodeAfterWorker(sourceFile: SourceFile, after: Node, newNode: Node): number { if (needSemicolonBetween(after, newNode)) { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI @@ -472,14 +473,17 @@ namespace ts.textChanges { } } const endPosition = getAdjustedEndPosition(sourceFile, after, {}); - const options = this.getInsertNodeAfterOptions(after); - return this.replaceRange(sourceFile, createTextRange(endPosition), newNode, { - ...options, - prefix: after.end === sourceFile.end && isStatement(after) ? (options.prefix ? `\n${options.prefix}` : "\n") : options.prefix, - }); + return endPosition; } - private getInsertNodeAfterOptions(node: Node): InsertNodeOptions { + private getInsertNodeAfterOptions(sourceFile: SourceFile, after: Node) { + const options = this.getInsertNodeAfterOptionsWorker(after); + return { + ...options, + prefix: after.end === sourceFile.end && isStatement(after) ? (options.prefix ? `\n${options.prefix}` : "\n") : options.prefix, + }; + } + private getInsertNodeAfterOptionsWorker(node: Node): InsertNodeOptions { if (isClassDeclaration(node) || isModuleDeclaration(node)) { return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; } @@ -527,13 +531,16 @@ namespace ts.textChanges { } } + public insertExportModifier(sourceFile: SourceFile, node: DeclarationStatement | VariableStatement): void { + this.insertText(sourceFile, node.getStart(sourceFile), "export "); + } + /** * 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. */ - public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { - const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile); + public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node, containingList = formatting.SmartIndenter.getContainingList(after, sourceFile)) { if (!containingList) { Debug.fail("node is not a list element"); return this; @@ -656,6 +663,19 @@ namespace ts.textChanges { }); } + private finishTrailingCommaAfterDeletingNodesInList() { + this.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); + if (lastNonDeletedIndex !== -1) { + this.deleteRange(sourceFile, { pos: list[lastNonDeletedIndex].end, end: startPositionToDeleteNodeInList(sourceFile, list[lastNonDeletedIndex + 1]) }); + } + }); + } + /** * Note: after calling this, the TextChanges object must be discarded! * @param validate only for tests @@ -664,8 +684,22 @@ namespace ts.textChanges { */ public getChanges(validate?: ValidateNonFormattedText): FileTextChanges[] { this.finishClassesWithNodesInsertedAtStart(); - return changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate); + 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)); + } + return changes; } + + public createNewFile(oldFile: SourceFile, fileName: string, statements: ReadonlyArray) { + this.newFiles.push({ oldFile, fileName, statements }); + } + } + + // find first non-whitespace position in the leading trivia of the node + function startPositionToDeleteNodeInList(sourceFile: SourceFile, node: Node): number { + return skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassBraceEnds(cls: ClassLikeDeclaration, sourceFile: SourceFile): [number, number] { @@ -679,7 +713,8 @@ namespace ts.textChanges { return group(changes, c => c.sourceFile.path).map(changesInFile => { const sourceFile = changesInFile[0].sourceFile; // order changes by start position - const normalized = stableSort(changesInFile, (a, b) => a.range.pos - b.range.pos); + // 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. + const normalized = stableSort(changesInFile, (a, b) => (a.range.pos - b.range.pos) || (a.range.end - b.range.end)); // verify that change intervals do not overlap, except possibly at end points. for (let i = 0; i < normalized.length - 1; i++) { Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", () => @@ -691,6 +726,11 @@ namespace ts.textChanges { }); } + export function newFileChanges(oldFile: SourceFile, fileName: string, statements: ReadonlyArray, newLineCharacter: string): FileTextChanges { + const text = statements.map(s => getNonformattedText(s, oldFile, newLineCharacter).text).join(newLineCharacter); + return { fileName, textChanges: [createTextChange(createTextSpan(0, 0), text)], isNewFile: true }; + } + function computeNewText(change: Change, sourceFile: SourceFile, newLineCharacter: string, formatContext: formatting.FormatContext, validate: ValidateNonFormattedText): string { if (change.kind === ChangeKind.Remove) { return ""; diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index be46c21e06b..7e1ccc9c3af 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -98,6 +98,8 @@ "codefixes/fixExtendsInterfaceBecomesImplements.ts", "codefixes/fixForgottenThisPropertyAccess.ts", "codefixes/fixUnusedIdentifier.ts", + "codefixes/fixUnreachableCode.ts", + "codefixes/fixUnusedLabel.ts", "codefixes/fixJSDocTypes.ts", "codefixes/fixAwaitInSyncFunction.ts", "codefixes/disableJsDiagnostics.ts", @@ -105,10 +107,13 @@ "codefixes/inferFromUsage.ts", "codefixes/fixInvalidImportSyntax.ts", "codefixes/fixStrictClassInitialization.ts", + "codefixes/moduleSpecifiers.ts", "codefixes/requireInTs.ts", "codefixes/useDefaultImport.ts", + "codefixes/fixAddModuleReferTypeMissingTypeof.ts", "refactors/extractSymbol.ts", "refactors/generateGetAccessorAndSetAccessor.ts", + "refactors/moveToNewFile.ts", "sourcemaps.ts", "services.ts", "breakpoints.ts", diff --git a/src/services/types.ts b/src/services/types.ts index c103d2f4ba0..b8e2c488b17 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -13,7 +13,7 @@ namespace ts { getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; - getWidth(sourceFile?: SourceFile): number; + getWidth(sourceFile?: SourceFileLike): number; getFullWidth(): number; getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; @@ -207,8 +207,11 @@ namespace ts { * LS host can optionally implement this method if it wants to be completely in charge of module name resolution. * if implementation is omitted then language service will use built-in module resolution logic and get answers to * host specific questions using 'getScriptSnapshot'. + * + * If this is implemented, `getResolvedModuleWithFailedLookupLocationsFromCache` should be too. */ resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; + getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; /* @internal */ hasInvalidatedResolution?: HasInvalidatedResolution; /* @internal */ hasChangedAutomaticTypeDirectiveNames?: boolean; @@ -234,6 +237,7 @@ namespace ts { readonly includeCompletionsForModuleExports?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; + readonly allowTextChangesInNewFiles?: boolean; } /* @internal */ export const defaultPreferences: UserPreferences = {}; @@ -438,6 +442,7 @@ namespace ts { export interface FileTextChanges { fileName: string; textChanges: TextChange[]; + isNewFile?: boolean; } export interface CodeAction { @@ -541,6 +546,13 @@ namespace ts { export interface DocumentSpan { textSpan: TextSpan; fileName: string; + + /** + * If the span represents a location that was remapped (e.g. via a .d.ts.map file), + * then the original filename and span will be specified here + */ + originalTextSpan?: TextSpan; + originalFileName?: string; } export interface RenameLocation extends DocumentSpan { @@ -653,9 +665,7 @@ namespace ts { indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; } - export interface DefinitionInfo { - fileName: string; - textSpan: TextSpan; + export interface DefinitionInfo extends DocumentSpan { kind: ScriptElementKind; name: string; containerKind: ScriptElementKind; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 3d50ded1886..b389b956eac 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -107,6 +107,10 @@ namespace ts { Debug.assert(isJSDocTemplateTag(node.parent.parent)); // Else would be handled by isDeclarationName return SemanticMeaning.Type; } + else if (isLiteralTypeNode(node.parent)) { + // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. + return SemanticMeaning.Type | SemanticMeaning.Value; + } else { return SemanticMeaning.Value; } @@ -272,7 +276,7 @@ namespace ts { } export function getContainerNode(node: Node): Declaration { - if (node.kind === SyntaxKind.JSDocTypedefTag) { + if (isJSDocTypeAlias(node)) { // This doesn't just apply to the node immediately under the comment, but to everything in its parent's scope. // node.parent = the JSDoc comment, node.parent.parent = the node having the comment. // Then we get parent again in the loop. @@ -311,7 +315,10 @@ namespace ts { case SyntaxKind.ClassExpression: return ScriptElementKind.classElement; case SyntaxKind.InterfaceDeclaration: return ScriptElementKind.interfaceElement; - case SyntaxKind.TypeAliasDeclaration: return ScriptElementKind.typeElement; + case SyntaxKind.TypeAliasDeclaration: + case SyntaxKind.JSDocCallbackTag: + case SyntaxKind.JSDocTypedefTag: + return ScriptElementKind.typeElement; case SyntaxKind.EnumDeclaration: return ScriptElementKind.enumElement; case SyntaxKind.VariableDeclaration: return getKindOfVariableDeclaration(node); @@ -342,8 +349,6 @@ namespace ts { case SyntaxKind.ExportSpecifier: case SyntaxKind.NamespaceImport: return ScriptElementKind.alias; - case SyntaxKind.JSDocTypedefTag: - return ScriptElementKind.typeElement; case SyntaxKind.BinaryExpression: const kind = getSpecialPropertyAssignmentKind(node as BinaryExpression); const { right } = node as BinaryExpression; @@ -412,6 +417,10 @@ namespace ts { return startEndContainsRange(r1.pos, r1.end, r2); } + export function rangeContainsPosition(r: TextRange, pos: number): boolean { + return r.pos <= pos && pos <= r.end; + } + export function startEndContainsRange(start: number, end: number, range: TextRange): boolean { return start <= range.pos && end >= range.end; } @@ -707,7 +716,7 @@ namespace ts { return findPrecedingToken(position, file); } - export function findNextToken(previousToken: Node, parent: Node): Node { + export function findNextToken(previousToken: Node, parent: Node, sourceFile: SourceFile): Node { return find(parent); function find(n: Node): Node { @@ -724,7 +733,7 @@ namespace ts { // previous token ends exactly at the beginning of child (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child)) { + if (shouldDiveInChildNode && nodeHasTokens(child, sourceFile)) { return find(child); } } @@ -759,12 +768,12 @@ namespace ts { const start = child.getStart(sourceFile, includeJsDoc); const lookInPreviousChild = (start >= position) || // cursor in the leading trivia - !nodeHasTokens(child) || + !nodeHasTokens(child, sourceFile) || isWhiteSpaceOnlyJsxText(child); if (lookInPreviousChild) { // actual start of the node is past the position - previous token should be at the end of previous child - const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i); + const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile); return candidate && findRightmostToken(candidate, sourceFile); } else { @@ -781,7 +790,7 @@ namespace ts { // Try to find the rightmost token in the file without filtering. // Namely we are skipping the check: 'position < node.end' if (children.length) { - const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); + const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); return candidate && findRightmostToken(candidate, sourceFile); } } @@ -797,21 +806,21 @@ namespace ts { } const children = n.getChildren(sourceFile); - const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length); + const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile); return candidate && findRightmostToken(candidate, sourceFile); } /** * Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens. */ - function findRightmostChildNodeWithTokens(children: Node[], exclusiveStartPosition: number): Node | undefined { + function findRightmostChildNodeWithTokens(children: Node[], exclusiveStartPosition: number, sourceFile: SourceFile): Node | undefined { for (let i = exclusiveStartPosition - 1; i >= 0; i--) { const child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { Debug.assert(i > 0, "`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); } - else if (nodeHasTokens(children[i])) { + else if (nodeHasTokens(children[i], sourceFile)) { return children[i]; } } @@ -1022,10 +1031,10 @@ namespace ts { } } - function nodeHasTokens(n: Node): boolean { + function nodeHasTokens(n: Node, sourceFile: SourceFileLike): boolean { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.getWidth() !== 0; + return n.getWidth(sourceFile) !== 0; } export function getNodeModifiers(node: Node): string { @@ -1146,6 +1155,10 @@ namespace ts { return createTextSpanFromBounds(range.pos, range.end); } + export function createTextRangeFromSpan(span: TextSpan): TextRange { + return createTextRange(span.start, span.start + span.length); + } + export function createTextChangeFromStartLength(start: number, length: number, newText: string): TextChange { return createTextChange(createTextSpan(start, length), newText); } @@ -1180,7 +1193,8 @@ namespace ts { } /** Returns `true` the first time it encounters a node and `false` afterwards. */ - export function nodeSeenTracker(): (node: T) => boolean { + export type NodeSeenTracker = (node: T) => boolean; + export function nodeSeenTracker(): NodeSeenTracker { const seen: true[] = []; return node => { const id = getNodeId(node); @@ -1225,6 +1239,64 @@ namespace ts { export function hostGetCanonicalFileName(host: LanguageServiceHost): GetCanonicalFileName { return createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host)); } + + export function makeImportIfNecessary(defaultImport: Identifier | undefined, namedImports: ReadonlyArray | undefined, moduleSpecifier: string): ImportDeclaration | undefined { + return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier) : undefined; + } + + export function makeImport(defaultImport: Identifier | undefined, namedImports: ReadonlyArray | undefined, moduleSpecifier: string | Expression): ImportDeclaration { + return createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + defaultImport || namedImports + ? createImportClause(defaultImport, namedImports && namedImports.length ? createNamedImports(namedImports) : undefined) + : undefined, + typeof moduleSpecifier === "string" ? createLiteral(moduleSpecifier) : moduleSpecifier); + } + + export function symbolNameNoDefault(symbol: Symbol): string | undefined { + const escaped = symbolEscapedNameNoDefault(symbol); + return escaped === undefined ? undefined : unescapeLeadingUnderscores(escaped); + } + + export function symbolEscapedNameNoDefault(symbol: Symbol): __String | undefined { + if (symbol.escapedName !== InternalSymbolName.Default) { + return symbol.escapedName; + } + + return firstDefined(symbol.declarations, decl => { + const name = getNameOfDeclaration(decl); + return name && name.kind === SyntaxKind.Identifier ? name.escapedText : undefined; + }); + } + + export function getPropertySymbolFromBindingElement(checker: TypeChecker, bindingElement: BindingElement & { name: Identifier }) { + const typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); + const propSymbol = typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + if (propSymbol && propSymbol.flags & SymbolFlags.Accessor) { + // See GH#16922 + Debug.assert(!!(propSymbol.flags & SymbolFlags.Transient)); + return (propSymbol as TransientSymbol).target; + } + return propSymbol; + } + + export class NodeSet { + private map = createMap(); + + add(node: Node): void { + this.map.set(String(getNodeId(node)), node); + } + has(node: Node): boolean { + return this.map.has(String(getNodeId(node))); + } + forEach(cb: (node: Node) => void): void { + this.map.forEach(cb); + } + some(pred: (node: Node) => boolean): boolean { + return forEachEntry(this.map, pred) || false; + } + } } // Display-part writer helpers diff --git a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.errors.txt b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.errors.txt deleted file mode 100644 index 0a8f03a504a..00000000000 --- a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts(3,8): error TS4033: Property 'f' of exported interface has or is using private name 'T'. - - -==== tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts (1 errors) ==== - type T = { x : number } - export interface I { - f: T; - ~ -!!! error TS4033: Property 'f' of exported interface has or is using private name 'T'. - } \ No newline at end of file diff --git a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.js b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.js new file mode 100644 index 00000000000..73c312a018b --- /dev/null +++ b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.js @@ -0,0 +1,19 @@ +//// [DeclarationErrorsNoEmitOnError.ts] +type T = { x : number } +export interface I { + f: T; +} + +//// [DeclarationErrorsNoEmitOnError.js] +"use strict"; +exports.__esModule = true; + + +//// [DeclarationErrorsNoEmitOnError.d.ts] +declare type T = { + x: number; +}; +export interface I { + f: T; +} +export {}; diff --git a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types index 08a65d9c146..d2598dfe748 100644 --- a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types +++ b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types @@ -1,12 +1,12 @@ === tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts === type T = { x : number } ->T : { x: number; } +>T : T >x : number export interface I { >I : I f: T; ->f : { x: number; } ->T : { x: number; } +>f : T +>T : T } diff --git a/tests/baselines/reference/ES5For-of30.js b/tests/baselines/reference/ES5For-of30.js index fead25e7cf0..2ee498efab4 100644 --- a/tests/baselines/reference/ES5For-of30.js +++ b/tests/baselines/reference/ES5For-of30.js @@ -7,6 +7,7 @@ for ([a = 1, b = ""] of tuple) { } //// [ES5For-of30.js] +var _a, _b, _c; var a, b; var tuple = [2, "3"]; for (var _i = 0, tuple_1 = tuple; _i < tuple_1.length; _i++) { @@ -14,4 +15,3 @@ for (var _i = 0, tuple_1 = tuple; _i < tuple_1.length; _i++) { a; b; } -var _a, _b, _c; diff --git a/tests/baselines/reference/ES5For-of31.js b/tests/baselines/reference/ES5For-of31.js index 6b038e377cb..23cee8bff42 100644 --- a/tests/baselines/reference/ES5For-of31.js +++ b/tests/baselines/reference/ES5For-of31.js @@ -7,10 +7,10 @@ for ({ a: b = 1, b: a = ""} of []) { } //// [ES5For-of31.js] +var _a, _b, _c; var a, b; -for (var _i = 0, _a = []; _i < _a.length; _i++) { - _b = _a[_i], _c = _b.a, b = _c === void 0 ? 1 : _c, _d = _b.b, a = _d === void 0 ? "" : _d; +for (var _i = 0, _d = []; _i < _d.length; _i++) { + _a = _d[_i], _b = _a.a, b = _b === void 0 ? 1 : _b, _c = _a.b, a = _c === void 0 ? "" : _c; a; b; } -var _b, _c, _d; diff --git a/tests/baselines/reference/ES5For-of33.js b/tests/baselines/reference/ES5For-of33.js index 729c37b8120..8a7bacbf52d 100644 --- a/tests/baselines/reference/ES5For-of33.js +++ b/tests/baselines/reference/ES5For-of33.js @@ -14,18 +14,18 @@ var __values = (this && this.__values) || function (o) { } }; }; +var e_1, _a; try { - for (var _a = __values(['a', 'b', 'c']), _b = _a.next(); !_b.done; _b = _a.next()) { - var v = _b.value; + for (var _b = __values(['a', 'b', 'c']), _c = _b.next(); !_c.done; _c = _b.next()) { + var v = _c.value; console.log(v); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_b && !_b.done && (_c = _a["return"])) _c.call(_a); + if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); } finally { if (e_1) throw e_1.error; } } -var e_1, _c; //# sourceMappingURL=ES5For-of33.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of33.js.map b/tests/baselines/reference/ES5For-of33.js.map index 7174a7ab6a9..c2a28ecec79 100644 --- a/tests/baselines/reference/ES5For-of33.js.map +++ b/tests/baselines/reference/ES5For-of33.js.map @@ -1,2 +1,2 @@ //// [ES5For-of33.js.map] -{"version":3,"file":"ES5For-of33.js","sourceRoot":"","sources":["ES5For-of33.ts"],"names":[],"mappings":";;;;;;;;;;;IAAA,KAAc,IAAA,KAAA,SAAA,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA,gBAAA,4BAAE;QAA1B,IAAI,CAAC,WAAA;QACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAClB"} \ No newline at end of file +{"version":3,"file":"ES5For-of33.js","sourceRoot":"","sources":["ES5For-of33.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,KAAc,IAAA,KAAA,SAAA,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA,gBAAA,4BAAE;QAA1B,IAAI,CAAC,WAAA;QACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAClB"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of33.sourcemap.txt b/tests/baselines/reference/ES5For-of33.sourcemap.txt index 981750750c0..8438d558c74 100644 --- a/tests/baselines/reference/ES5For-of33.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of33.sourcemap.txt @@ -18,8 +18,9 @@ sourceFile:ES5For-of33.ts >>> } >>> }; >>>}; +>>>var e_1, _a; >>>try { ->>> for (var _a = __values(['a', 'b', 'c']), _b = _a.next(); !_b.done; _b = _a.next()) { +>>> for (var _b = __values(['a', 'b', 'c']), _c = _b.next(); !_c.done; _c = _b.next()) { 1 >^^^^ 2 > ^^^^^ 3 > ^^^^ @@ -50,23 +51,23 @@ sourceFile:ES5For-of33.ts 13> 14> 15> ) -1 >Emitted(12, 5) Source(1, 1) + SourceIndex(0) -2 >Emitted(12, 10) Source(1, 15) + SourceIndex(0) -3 >Emitted(12, 14) Source(1, 15) + SourceIndex(0) -4 >Emitted(12, 19) Source(1, 15) + SourceIndex(0) -5 >Emitted(12, 28) Source(1, 15) + SourceIndex(0) -6 >Emitted(12, 29) Source(1, 16) + SourceIndex(0) -7 >Emitted(12, 32) Source(1, 19) + SourceIndex(0) -8 >Emitted(12, 34) Source(1, 21) + SourceIndex(0) -9 >Emitted(12, 37) Source(1, 24) + SourceIndex(0) -10>Emitted(12, 39) Source(1, 26) + SourceIndex(0) -11>Emitted(12, 42) Source(1, 29) + SourceIndex(0) -12>Emitted(12, 43) Source(1, 30) + SourceIndex(0) -13>Emitted(12, 44) Source(1, 30) + SourceIndex(0) -14>Emitted(12, 60) Source(1, 30) + SourceIndex(0) -15>Emitted(12, 88) Source(1, 32) + SourceIndex(0) +1 >Emitted(13, 5) Source(1, 1) + SourceIndex(0) +2 >Emitted(13, 10) Source(1, 15) + SourceIndex(0) +3 >Emitted(13, 14) Source(1, 15) + SourceIndex(0) +4 >Emitted(13, 19) Source(1, 15) + SourceIndex(0) +5 >Emitted(13, 28) Source(1, 15) + SourceIndex(0) +6 >Emitted(13, 29) Source(1, 16) + SourceIndex(0) +7 >Emitted(13, 32) Source(1, 19) + SourceIndex(0) +8 >Emitted(13, 34) Source(1, 21) + SourceIndex(0) +9 >Emitted(13, 37) Source(1, 24) + SourceIndex(0) +10>Emitted(13, 39) Source(1, 26) + SourceIndex(0) +11>Emitted(13, 42) Source(1, 29) + SourceIndex(0) +12>Emitted(13, 43) Source(1, 30) + SourceIndex(0) +13>Emitted(13, 44) Source(1, 30) + SourceIndex(0) +14>Emitted(13, 60) Source(1, 30) + SourceIndex(0) +15>Emitted(13, 88) Source(1, 32) + SourceIndex(0) --- ->>> var v = _b.value; +>>> var v = _c.value; 1 >^^^^^^^^ 2 > ^^^^ 3 > ^ @@ -75,10 +76,10 @@ sourceFile:ES5For-of33.ts 2 > var 3 > v 4 > -1 >Emitted(13, 9) Source(1, 6) + SourceIndex(0) -2 >Emitted(13, 13) Source(1, 10) + SourceIndex(0) -3 >Emitted(13, 14) Source(1, 11) + SourceIndex(0) -4 >Emitted(13, 25) Source(1, 11) + SourceIndex(0) +1 >Emitted(14, 9) Source(1, 6) + SourceIndex(0) +2 >Emitted(14, 13) Source(1, 10) + SourceIndex(0) +3 >Emitted(14, 14) Source(1, 11) + SourceIndex(0) +4 >Emitted(14, 25) Source(1, 11) + SourceIndex(0) --- >>> console.log(v); 1 >^^^^^^^^ @@ -98,28 +99,27 @@ sourceFile:ES5For-of33.ts 6 > v 7 > ) 8 > ; -1 >Emitted(14, 9) Source(2, 5) + SourceIndex(0) -2 >Emitted(14, 16) Source(2, 12) + SourceIndex(0) -3 >Emitted(14, 17) Source(2, 13) + SourceIndex(0) -4 >Emitted(14, 20) Source(2, 16) + SourceIndex(0) -5 >Emitted(14, 21) Source(2, 17) + SourceIndex(0) -6 >Emitted(14, 22) Source(2, 18) + SourceIndex(0) -7 >Emitted(14, 23) Source(2, 19) + SourceIndex(0) -8 >Emitted(14, 24) Source(2, 20) + SourceIndex(0) +1 >Emitted(15, 9) Source(2, 5) + SourceIndex(0) +2 >Emitted(15, 16) Source(2, 12) + SourceIndex(0) +3 >Emitted(15, 17) Source(2, 13) + SourceIndex(0) +4 >Emitted(15, 20) Source(2, 16) + SourceIndex(0) +5 >Emitted(15, 21) Source(2, 17) + SourceIndex(0) +6 >Emitted(15, 22) Source(2, 18) + SourceIndex(0) +7 >Emitted(15, 23) Source(2, 19) + SourceIndex(0) +8 >Emitted(15, 24) Source(2, 20) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > >} -1 >Emitted(15, 6) Source(3, 2) + SourceIndex(0) +1 >Emitted(16, 6) Source(3, 2) + SourceIndex(0) --- >>>} >>>catch (e_1_1) { e_1 = { error: e_1_1 }; } >>>finally { >>> try { ->>> if (_b && !_b.done && (_c = _a["return"])) _c.call(_a); +>>> if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); >>> } >>> finally { if (e_1) throw e_1.error; } >>>} ->>>var e_1, _c; >>>//# sourceMappingURL=ES5For-of33.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of34.js b/tests/baselines/reference/ES5For-of34.js index 307a7505d09..821cec60ee1 100644 --- a/tests/baselines/reference/ES5For-of34.js +++ b/tests/baselines/reference/ES5For-of34.js @@ -17,21 +17,21 @@ var __values = (this && this.__values) || function (o) { } }; }; +var e_1, _a; function foo() { return { x: 0 }; } try { - for (var _a = __values(['a', 'b', 'c']), _b = _a.next(); !_b.done; _b = _a.next()) { - foo().x = _b.value; + for (var _b = __values(['a', 'b', 'c']), _c = _b.next(); !_c.done; _c = _b.next()) { + foo().x = _c.value; var p = foo().x; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_b && !_b.done && (_c = _a["return"])) _c.call(_a); + if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); } finally { if (e_1) throw e_1.error; } } -var e_1, _c; //# sourceMappingURL=ES5For-of34.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of34.js.map b/tests/baselines/reference/ES5For-of34.js.map index 15cbe915a81..ac81f9749c9 100644 --- a/tests/baselines/reference/ES5For-of34.js.map +++ b/tests/baselines/reference/ES5For-of34.js.map @@ -1,2 +1,2 @@ //// [ES5For-of34.js.map] -{"version":3,"file":"ES5For-of34.js","sourceRoot":"","sources":["ES5For-of34.ts"],"names":[],"mappings":";;;;;;;;;;AAAA;IACI,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACpB,CAAC;;IACD,KAAgB,IAAA,KAAA,SAAA,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA,gBAAA,4BAAE;QAA5B,GAAG,EAAE,CAAC,CAAC,WAAA;QACR,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;KACnB"} \ No newline at end of file +{"version":3,"file":"ES5For-of34.js","sourceRoot":"","sources":["ES5For-of34.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;IACI,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACpB,CAAC;;IACD,KAAgB,IAAA,KAAA,SAAA,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA,gBAAA,4BAAE;QAA5B,GAAG,EAAE,CAAC,CAAC,WAAA;QACR,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;KACnB"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of34.sourcemap.txt b/tests/baselines/reference/ES5For-of34.sourcemap.txt index 86bd08aa1f6..ea1b982e766 100644 --- a/tests/baselines/reference/ES5For-of34.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of34.sourcemap.txt @@ -18,11 +18,12 @@ sourceFile:ES5For-of34.ts >>> } >>> }; >>>}; +>>>var e_1, _a; >>>function foo() { 1 > 2 >^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(11, 1) Source(1, 1) + SourceIndex(0) +1 >Emitted(12, 1) Source(1, 1) + SourceIndex(0) --- >>> return { x: 0 }; 1->^^^^ @@ -42,14 +43,14 @@ sourceFile:ES5For-of34.ts 6 > 0 7 > } 8 > ; -1->Emitted(12, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(12, 12) Source(2, 12) + SourceIndex(0) -3 >Emitted(12, 14) Source(2, 14) + SourceIndex(0) -4 >Emitted(12, 15) Source(2, 15) + SourceIndex(0) -5 >Emitted(12, 17) Source(2, 17) + SourceIndex(0) -6 >Emitted(12, 18) Source(2, 18) + SourceIndex(0) -7 >Emitted(12, 20) Source(2, 20) + SourceIndex(0) -8 >Emitted(12, 21) Source(2, 21) + SourceIndex(0) +1->Emitted(13, 5) Source(2, 5) + SourceIndex(0) +2 >Emitted(13, 12) Source(2, 12) + SourceIndex(0) +3 >Emitted(13, 14) Source(2, 14) + SourceIndex(0) +4 >Emitted(13, 15) Source(2, 15) + SourceIndex(0) +5 >Emitted(13, 17) Source(2, 17) + SourceIndex(0) +6 >Emitted(13, 18) Source(2, 18) + SourceIndex(0) +7 >Emitted(13, 20) Source(2, 20) + SourceIndex(0) +8 >Emitted(13, 21) Source(2, 21) + SourceIndex(0) --- >>>} 1 > @@ -58,11 +59,11 @@ sourceFile:ES5For-of34.ts 1 > > 2 >} -1 >Emitted(13, 1) Source(3, 1) + SourceIndex(0) -2 >Emitted(13, 2) Source(3, 2) + SourceIndex(0) +1 >Emitted(14, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(14, 2) Source(3, 2) + SourceIndex(0) --- >>>try { ->>> for (var _a = __values(['a', 'b', 'c']), _b = _a.next(); !_b.done; _b = _a.next()) { +>>> for (var _b = __values(['a', 'b', 'c']), _c = _b.next(); !_c.done; _c = _b.next()) { 1->^^^^ 2 > ^^^^^ 3 > ^^^^ @@ -94,23 +95,23 @@ sourceFile:ES5For-of34.ts 13> 14> 15> ) -1->Emitted(15, 5) Source(4, 1) + SourceIndex(0) -2 >Emitted(15, 10) Source(4, 17) + SourceIndex(0) -3 >Emitted(15, 14) Source(4, 17) + SourceIndex(0) -4 >Emitted(15, 19) Source(4, 17) + SourceIndex(0) -5 >Emitted(15, 28) Source(4, 17) + SourceIndex(0) -6 >Emitted(15, 29) Source(4, 18) + SourceIndex(0) -7 >Emitted(15, 32) Source(4, 21) + SourceIndex(0) -8 >Emitted(15, 34) Source(4, 23) + SourceIndex(0) -9 >Emitted(15, 37) Source(4, 26) + SourceIndex(0) -10>Emitted(15, 39) Source(4, 28) + SourceIndex(0) -11>Emitted(15, 42) Source(4, 31) + SourceIndex(0) -12>Emitted(15, 43) Source(4, 32) + SourceIndex(0) -13>Emitted(15, 44) Source(4, 32) + SourceIndex(0) -14>Emitted(15, 60) Source(4, 32) + SourceIndex(0) -15>Emitted(15, 88) Source(4, 34) + SourceIndex(0) +1->Emitted(16, 5) Source(4, 1) + SourceIndex(0) +2 >Emitted(16, 10) Source(4, 17) + SourceIndex(0) +3 >Emitted(16, 14) Source(4, 17) + SourceIndex(0) +4 >Emitted(16, 19) Source(4, 17) + SourceIndex(0) +5 >Emitted(16, 28) Source(4, 17) + SourceIndex(0) +6 >Emitted(16, 29) Source(4, 18) + SourceIndex(0) +7 >Emitted(16, 32) Source(4, 21) + SourceIndex(0) +8 >Emitted(16, 34) Source(4, 23) + SourceIndex(0) +9 >Emitted(16, 37) Source(4, 26) + SourceIndex(0) +10>Emitted(16, 39) Source(4, 28) + SourceIndex(0) +11>Emitted(16, 42) Source(4, 31) + SourceIndex(0) +12>Emitted(16, 43) Source(4, 32) + SourceIndex(0) +13>Emitted(16, 44) Source(4, 32) + SourceIndex(0) +14>Emitted(16, 60) Source(4, 32) + SourceIndex(0) +15>Emitted(16, 88) Source(4, 34) + SourceIndex(0) --- ->>> foo().x = _b.value; +>>> foo().x = _c.value; 1 >^^^^^^^^ 2 > ^^^ 3 > ^^ @@ -123,12 +124,12 @@ sourceFile:ES5For-of34.ts 4 > . 5 > x 6 > -1 >Emitted(16, 9) Source(4, 6) + SourceIndex(0) -2 >Emitted(16, 12) Source(4, 9) + SourceIndex(0) -3 >Emitted(16, 14) Source(4, 11) + SourceIndex(0) -4 >Emitted(16, 15) Source(4, 12) + SourceIndex(0) -5 >Emitted(16, 16) Source(4, 13) + SourceIndex(0) -6 >Emitted(16, 27) Source(4, 13) + SourceIndex(0) +1 >Emitted(17, 9) Source(4, 6) + SourceIndex(0) +2 >Emitted(17, 12) Source(4, 9) + SourceIndex(0) +3 >Emitted(17, 14) Source(4, 11) + SourceIndex(0) +4 >Emitted(17, 15) Source(4, 12) + SourceIndex(0) +5 >Emitted(17, 16) Source(4, 13) + SourceIndex(0) +6 >Emitted(17, 27) Source(4, 13) + SourceIndex(0) --- >>> var p = foo().x; 1 >^^^^^^^^ @@ -150,29 +151,28 @@ sourceFile:ES5For-of34.ts 7 > . 8 > x 9 > ; -1 >Emitted(17, 9) Source(5, 5) + SourceIndex(0) -2 >Emitted(17, 13) Source(5, 9) + SourceIndex(0) -3 >Emitted(17, 14) Source(5, 10) + SourceIndex(0) -4 >Emitted(17, 17) Source(5, 13) + SourceIndex(0) -5 >Emitted(17, 20) Source(5, 16) + SourceIndex(0) -6 >Emitted(17, 22) Source(5, 18) + SourceIndex(0) -7 >Emitted(17, 23) Source(5, 19) + SourceIndex(0) -8 >Emitted(17, 24) Source(5, 20) + SourceIndex(0) -9 >Emitted(17, 25) Source(5, 21) + SourceIndex(0) +1 >Emitted(18, 9) Source(5, 5) + SourceIndex(0) +2 >Emitted(18, 13) Source(5, 9) + SourceIndex(0) +3 >Emitted(18, 14) Source(5, 10) + SourceIndex(0) +4 >Emitted(18, 17) Source(5, 13) + SourceIndex(0) +5 >Emitted(18, 20) Source(5, 16) + SourceIndex(0) +6 >Emitted(18, 22) Source(5, 18) + SourceIndex(0) +7 >Emitted(18, 23) Source(5, 19) + SourceIndex(0) +8 >Emitted(18, 24) Source(5, 20) + SourceIndex(0) +9 >Emitted(18, 25) Source(5, 21) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > >} -1 >Emitted(18, 6) Source(6, 2) + SourceIndex(0) +1 >Emitted(19, 6) Source(6, 2) + SourceIndex(0) --- >>>} >>>catch (e_1_1) { e_1 = { error: e_1_1 }; } >>>finally { >>> try { ->>> if (_b && !_b.done && (_c = _a["return"])) _c.call(_a); +>>> if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); >>> } >>> finally { if (e_1) throw e_1.error; } >>>} ->>>var e_1, _c; >>>//# sourceMappingURL=ES5For-of34.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of35.js b/tests/baselines/reference/ES5For-of35.js index 597296cacae..608ce967479 100644 --- a/tests/baselines/reference/ES5For-of35.js +++ b/tests/baselines/reference/ES5For-of35.js @@ -15,9 +15,10 @@ var __values = (this && this.__values) || function (o) { } }; }; +var e_1, _a; try { - for (var _a = __values([2, 3]), _b = _a.next(); !_b.done; _b = _a.next()) { - var _c = _b.value, _d = _c.x, a = _d === void 0 ? 0 : _d, _e = _c.y, b = _e === void 0 ? 1 : _e; + for (var _b = __values([2, 3]), _c = _b.next(); !_c.done; _c = _b.next()) { + var _d = _c.value, _e = _d.x, a = _e === void 0 ? 0 : _e, _f = _d.y, b = _f === void 0 ? 1 : _f; a; b; } @@ -25,9 +26,8 @@ try { catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_b && !_b.done && (_f = _a["return"])) _f.call(_a); + if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); } finally { if (e_1) throw e_1.error; } } -var e_1, _f; //# sourceMappingURL=ES5For-of35.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of35.js.map b/tests/baselines/reference/ES5For-of35.js.map index 73ecad3ea1f..ca243e5bde5 100644 --- a/tests/baselines/reference/ES5For-of35.js.map +++ b/tests/baselines/reference/ES5For-of35.js.map @@ -1,2 +1,2 @@ //// [ES5For-of35.js.map] -{"version":3,"file":"ES5For-of35.js","sourceRoot":"","sources":["ES5For-of35.ts"],"names":[],"mappings":";;;;;;;;;;;IAAA,KAAmC,IAAA,KAAA,SAAA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,gBAAA,4BAAE;QAAhC,IAAA,aAAoB,EAAnB,SAAQ,EAAR,0BAAQ,EAAE,SAAQ,EAAR,0BAAQ;QAC1B,CAAC,CAAC;QACF,CAAC,CAAC;KACL"} \ No newline at end of file +{"version":3,"file":"ES5For-of35.js","sourceRoot":"","sources":["ES5For-of35.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,KAAmC,IAAA,KAAA,SAAA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,gBAAA,4BAAE;QAAhC,IAAA,aAAoB,EAAnB,SAAQ,EAAR,0BAAQ,EAAE,SAAQ,EAAR,0BAAQ;QAC1B,CAAC,CAAC;QACF,CAAC,CAAC;KACL"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of35.sourcemap.txt b/tests/baselines/reference/ES5For-of35.sourcemap.txt index 1caba0a51e0..907fc3ce690 100644 --- a/tests/baselines/reference/ES5For-of35.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of35.sourcemap.txt @@ -18,8 +18,9 @@ sourceFile:ES5For-of35.ts >>> } >>> }; >>>}; +>>>var e_1, _a; >>>try { ->>> for (var _a = __values([2, 3]), _b = _a.next(); !_b.done; _b = _a.next()) { +>>> for (var _b = __values([2, 3]), _c = _b.next(); !_c.done; _c = _b.next()) { 1 >^^^^ 2 > ^^^^^ 3 > ^^^^ @@ -47,21 +48,21 @@ sourceFile:ES5For-of35.ts 11> 12> 13> ) -1 >Emitted(12, 5) Source(1, 1) + SourceIndex(0) -2 >Emitted(12, 10) Source(1, 36) + SourceIndex(0) -3 >Emitted(12, 14) Source(1, 36) + SourceIndex(0) -4 >Emitted(12, 19) Source(1, 36) + SourceIndex(0) -5 >Emitted(12, 28) Source(1, 36) + SourceIndex(0) -6 >Emitted(12, 29) Source(1, 37) + SourceIndex(0) -7 >Emitted(12, 30) Source(1, 38) + SourceIndex(0) -8 >Emitted(12, 32) Source(1, 40) + SourceIndex(0) -9 >Emitted(12, 33) Source(1, 41) + SourceIndex(0) -10>Emitted(12, 34) Source(1, 42) + SourceIndex(0) -11>Emitted(12, 35) Source(1, 42) + SourceIndex(0) -12>Emitted(12, 51) Source(1, 42) + SourceIndex(0) -13>Emitted(12, 79) Source(1, 44) + SourceIndex(0) +1 >Emitted(13, 5) Source(1, 1) + SourceIndex(0) +2 >Emitted(13, 10) Source(1, 36) + SourceIndex(0) +3 >Emitted(13, 14) Source(1, 36) + SourceIndex(0) +4 >Emitted(13, 19) Source(1, 36) + SourceIndex(0) +5 >Emitted(13, 28) Source(1, 36) + SourceIndex(0) +6 >Emitted(13, 29) Source(1, 37) + SourceIndex(0) +7 >Emitted(13, 30) Source(1, 38) + SourceIndex(0) +8 >Emitted(13, 32) Source(1, 40) + SourceIndex(0) +9 >Emitted(13, 33) Source(1, 41) + SourceIndex(0) +10>Emitted(13, 34) Source(1, 42) + SourceIndex(0) +11>Emitted(13, 35) Source(1, 42) + SourceIndex(0) +12>Emitted(13, 51) Source(1, 42) + SourceIndex(0) +13>Emitted(13, 79) Source(1, 44) + SourceIndex(0) --- ->>> var _c = _b.value, _d = _c.x, a = _d === void 0 ? 0 : _d, _e = _c.y, b = _e === void 0 ? 1 : _e; +>>> var _d = _c.value, _e = _d.x, a = _e === void 0 ? 0 : _e, _f = _d.y, b = _f === void 0 ? 1 : _f; 1->^^^^^^^^ 2 > ^^^^ 3 > ^^^^^^^^^^^^^ @@ -84,17 +85,17 @@ sourceFile:ES5For-of35.ts 9 > y: b = 1 10> 11> y: b = 1 -1->Emitted(13, 9) Source(1, 12) + SourceIndex(0) -2 >Emitted(13, 13) Source(1, 12) + SourceIndex(0) -3 >Emitted(13, 26) Source(1, 32) + SourceIndex(0) -4 >Emitted(13, 28) Source(1, 13) + SourceIndex(0) -5 >Emitted(13, 37) Source(1, 21) + SourceIndex(0) -6 >Emitted(13, 39) Source(1, 13) + SourceIndex(0) -7 >Emitted(13, 65) Source(1, 21) + SourceIndex(0) -8 >Emitted(13, 67) Source(1, 23) + SourceIndex(0) -9 >Emitted(13, 76) Source(1, 31) + SourceIndex(0) -10>Emitted(13, 78) Source(1, 23) + SourceIndex(0) -11>Emitted(13, 104) Source(1, 31) + SourceIndex(0) +1->Emitted(14, 9) Source(1, 12) + SourceIndex(0) +2 >Emitted(14, 13) Source(1, 12) + SourceIndex(0) +3 >Emitted(14, 26) Source(1, 32) + SourceIndex(0) +4 >Emitted(14, 28) Source(1, 13) + SourceIndex(0) +5 >Emitted(14, 37) Source(1, 21) + SourceIndex(0) +6 >Emitted(14, 39) Source(1, 13) + SourceIndex(0) +7 >Emitted(14, 65) Source(1, 21) + SourceIndex(0) +8 >Emitted(14, 67) Source(1, 23) + SourceIndex(0) +9 >Emitted(14, 76) Source(1, 31) + SourceIndex(0) +10>Emitted(14, 78) Source(1, 23) + SourceIndex(0) +11>Emitted(14, 104) Source(1, 31) + SourceIndex(0) --- >>> a; 1 >^^^^^^^^ @@ -105,9 +106,9 @@ sourceFile:ES5For-of35.ts > 2 > a 3 > ; -1 >Emitted(14, 9) Source(2, 5) + SourceIndex(0) -2 >Emitted(14, 10) Source(2, 6) + SourceIndex(0) -3 >Emitted(14, 11) Source(2, 7) + SourceIndex(0) +1 >Emitted(15, 9) Source(2, 5) + SourceIndex(0) +2 >Emitted(15, 10) Source(2, 6) + SourceIndex(0) +3 >Emitted(15, 11) Source(2, 7) + SourceIndex(0) --- >>> b; 1->^^^^^^^^ @@ -117,23 +118,22 @@ sourceFile:ES5For-of35.ts > 2 > b 3 > ; -1->Emitted(15, 9) Source(3, 5) + SourceIndex(0) -2 >Emitted(15, 10) Source(3, 6) + SourceIndex(0) -3 >Emitted(15, 11) Source(3, 7) + SourceIndex(0) +1->Emitted(16, 9) Source(3, 5) + SourceIndex(0) +2 >Emitted(16, 10) Source(3, 6) + SourceIndex(0) +3 >Emitted(16, 11) Source(3, 7) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > >} -1 >Emitted(16, 6) Source(4, 2) + SourceIndex(0) +1 >Emitted(17, 6) Source(4, 2) + SourceIndex(0) --- >>>} >>>catch (e_1_1) { e_1 = { error: e_1_1 }; } >>>finally { >>> try { ->>> if (_b && !_b.done && (_f = _a["return"])) _f.call(_a); +>>> if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); >>> } >>> finally { if (e_1) throw e_1.error; } >>>} ->>>var e_1, _f; >>>//# sourceMappingURL=ES5For-of35.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of36.js b/tests/baselines/reference/ES5For-of36.js index fca89ee922b..5d53b241466 100644 --- a/tests/baselines/reference/ES5For-of36.js +++ b/tests/baselines/reference/ES5For-of36.js @@ -31,9 +31,10 @@ var __read = (this && this.__read) || function (o, n) { } return ar; }; +var e_1, _a; try { - for (var _a = __values([2, 3]), _b = _a.next(); !_b.done; _b = _a.next()) { - var _c = __read(_b.value, 2), _d = _c[0], a = _d === void 0 ? 0 : _d, _e = _c[1], b = _e === void 0 ? 1 : _e; + for (var _b = __values([2, 3]), _c = _b.next(); !_c.done; _c = _b.next()) { + var _d = __read(_c.value, 2), _e = _d[0], a = _e === void 0 ? 0 : _e, _f = _d[1], b = _f === void 0 ? 1 : _f; a; b; } @@ -41,9 +42,8 @@ try { catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_b && !_b.done && (_f = _a["return"])) _f.call(_a); + if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); } finally { if (e_1) throw e_1.error; } } -var e_1, _f; //# sourceMappingURL=ES5For-of36.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of36.js.map b/tests/baselines/reference/ES5For-of36.js.map index cbf56b3686b..09fdb4fd820 100644 --- a/tests/baselines/reference/ES5For-of36.js.map +++ b/tests/baselines/reference/ES5For-of36.js.map @@ -1,2 +1,2 @@ //// [ES5For-of36.js.map] -{"version":3,"file":"ES5For-of36.js","sourceRoot":"","sources":["ES5For-of36.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,KAA2B,IAAA,KAAA,SAAA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,gBAAA,4BAAE;QAA1B,IAAA,wBAAc,EAAb,UAAK,EAAL,0BAAK,EAAE,UAAK,EAAL,0BAAK;QAClB,CAAC,CAAC;QACF,CAAC,CAAC;KACL"} \ No newline at end of file +{"version":3,"file":"ES5For-of36.js","sourceRoot":"","sources":["ES5For-of36.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,KAA2B,IAAA,KAAA,SAAA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA,gBAAA,4BAAE;QAA1B,IAAA,wBAAc,EAAb,UAAK,EAAL,0BAAK,EAAE,UAAK,EAAL,0BAAK;QAClB,CAAC,CAAC;QACF,CAAC,CAAC;KACL"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of36.sourcemap.txt b/tests/baselines/reference/ES5For-of36.sourcemap.txt index 17249e4bb2b..c3ac87f51ca 100644 --- a/tests/baselines/reference/ES5For-of36.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of36.sourcemap.txt @@ -34,8 +34,9 @@ sourceFile:ES5For-of36.ts >>> } >>> return ar; >>>}; +>>>var e_1, _a; >>>try { ->>> for (var _a = __values([2, 3]), _b = _a.next(); !_b.done; _b = _a.next()) { +>>> for (var _b = __values([2, 3]), _c = _b.next(); !_c.done; _c = _b.next()) { 1 >^^^^ 2 > ^^^^^ 3 > ^^^^ @@ -63,21 +64,21 @@ sourceFile:ES5For-of36.ts 11> 12> 13> ) -1 >Emitted(28, 5) Source(1, 1) + SourceIndex(0) -2 >Emitted(28, 10) Source(1, 28) + SourceIndex(0) -3 >Emitted(28, 14) Source(1, 28) + SourceIndex(0) -4 >Emitted(28, 19) Source(1, 28) + SourceIndex(0) -5 >Emitted(28, 28) Source(1, 28) + SourceIndex(0) -6 >Emitted(28, 29) Source(1, 29) + SourceIndex(0) -7 >Emitted(28, 30) Source(1, 30) + SourceIndex(0) -8 >Emitted(28, 32) Source(1, 32) + SourceIndex(0) -9 >Emitted(28, 33) Source(1, 33) + SourceIndex(0) -10>Emitted(28, 34) Source(1, 34) + SourceIndex(0) -11>Emitted(28, 35) Source(1, 34) + SourceIndex(0) -12>Emitted(28, 51) Source(1, 34) + SourceIndex(0) -13>Emitted(28, 79) Source(1, 36) + SourceIndex(0) +1 >Emitted(29, 5) Source(1, 1) + SourceIndex(0) +2 >Emitted(29, 10) Source(1, 28) + SourceIndex(0) +3 >Emitted(29, 14) Source(1, 28) + SourceIndex(0) +4 >Emitted(29, 19) Source(1, 28) + SourceIndex(0) +5 >Emitted(29, 28) Source(1, 28) + SourceIndex(0) +6 >Emitted(29, 29) Source(1, 29) + SourceIndex(0) +7 >Emitted(29, 30) Source(1, 30) + SourceIndex(0) +8 >Emitted(29, 32) Source(1, 32) + SourceIndex(0) +9 >Emitted(29, 33) Source(1, 33) + SourceIndex(0) +10>Emitted(29, 34) Source(1, 34) + SourceIndex(0) +11>Emitted(29, 35) Source(1, 34) + SourceIndex(0) +12>Emitted(29, 51) Source(1, 34) + SourceIndex(0) +13>Emitted(29, 79) Source(1, 36) + SourceIndex(0) --- ->>> var _c = __read(_b.value, 2), _d = _c[0], a = _d === void 0 ? 0 : _d, _e = _c[1], b = _e === void 0 ? 1 : _e; +>>> var _d = __read(_c.value, 2), _e = _d[0], a = _e === void 0 ? 0 : _e, _f = _d[1], b = _f === void 0 ? 1 : _f; 1->^^^^^^^^ 2 > ^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,17 +101,17 @@ sourceFile:ES5For-of36.ts 9 > b = 1 10> 11> b = 1 -1->Emitted(29, 9) Source(1, 10) + SourceIndex(0) -2 >Emitted(29, 13) Source(1, 10) + SourceIndex(0) -3 >Emitted(29, 37) Source(1, 24) + SourceIndex(0) -4 >Emitted(29, 39) Source(1, 11) + SourceIndex(0) -5 >Emitted(29, 49) Source(1, 16) + SourceIndex(0) -6 >Emitted(29, 51) Source(1, 11) + SourceIndex(0) -7 >Emitted(29, 77) Source(1, 16) + SourceIndex(0) -8 >Emitted(29, 79) Source(1, 18) + SourceIndex(0) -9 >Emitted(29, 89) Source(1, 23) + SourceIndex(0) -10>Emitted(29, 91) Source(1, 18) + SourceIndex(0) -11>Emitted(29, 117) Source(1, 23) + SourceIndex(0) +1->Emitted(30, 9) Source(1, 10) + SourceIndex(0) +2 >Emitted(30, 13) Source(1, 10) + SourceIndex(0) +3 >Emitted(30, 37) Source(1, 24) + SourceIndex(0) +4 >Emitted(30, 39) Source(1, 11) + SourceIndex(0) +5 >Emitted(30, 49) Source(1, 16) + SourceIndex(0) +6 >Emitted(30, 51) Source(1, 11) + SourceIndex(0) +7 >Emitted(30, 77) Source(1, 16) + SourceIndex(0) +8 >Emitted(30, 79) Source(1, 18) + SourceIndex(0) +9 >Emitted(30, 89) Source(1, 23) + SourceIndex(0) +10>Emitted(30, 91) Source(1, 18) + SourceIndex(0) +11>Emitted(30, 117) Source(1, 23) + SourceIndex(0) --- >>> a; 1 >^^^^^^^^ @@ -121,9 +122,9 @@ sourceFile:ES5For-of36.ts > 2 > a 3 > ; -1 >Emitted(30, 9) Source(2, 5) + SourceIndex(0) -2 >Emitted(30, 10) Source(2, 6) + SourceIndex(0) -3 >Emitted(30, 11) Source(2, 7) + SourceIndex(0) +1 >Emitted(31, 9) Source(2, 5) + SourceIndex(0) +2 >Emitted(31, 10) Source(2, 6) + SourceIndex(0) +3 >Emitted(31, 11) Source(2, 7) + SourceIndex(0) --- >>> b; 1->^^^^^^^^ @@ -133,23 +134,22 @@ sourceFile:ES5For-of36.ts > 2 > b 3 > ; -1->Emitted(31, 9) Source(3, 5) + SourceIndex(0) -2 >Emitted(31, 10) Source(3, 6) + SourceIndex(0) -3 >Emitted(31, 11) Source(3, 7) + SourceIndex(0) +1->Emitted(32, 9) Source(3, 5) + SourceIndex(0) +2 >Emitted(32, 10) Source(3, 6) + SourceIndex(0) +3 >Emitted(32, 11) Source(3, 7) + SourceIndex(0) --- >>> } 1 >^^^^^ 1 > >} -1 >Emitted(32, 6) Source(4, 2) + SourceIndex(0) +1 >Emitted(33, 6) Source(4, 2) + SourceIndex(0) --- >>>} >>>catch (e_1_1) { e_1 = { error: e_1_1 }; } >>>finally { >>> try { ->>> if (_b && !_b.done && (_f = _a["return"])) _f.call(_a); +>>> if (_c && !_c.done && (_a = _b["return"])) _a.call(_b); >>> } >>> finally { if (e_1) throw e_1.error; } >>>} ->>>var e_1, _f; >>>//# sourceMappingURL=ES5For-of36.js.map \ No newline at end of file diff --git a/tests/baselines/reference/ES5SymbolProperty1.js b/tests/baselines/reference/ES5SymbolProperty1.js index ab3f420c95c..4300218c626 100644 --- a/tests/baselines/reference/ES5SymbolProperty1.js +++ b/tests/baselines/reference/ES5SymbolProperty1.js @@ -11,9 +11,9 @@ var obj = { obj[Symbol.foo]; //// [ES5SymbolProperty1.js] +var _a; var Symbol; var obj = (_a = {}, _a[Symbol.foo] = 0, _a); obj[Symbol.foo]; -var _a; diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.js b/tests/baselines/reference/FunctionDeclaration8_es6.js index 64f6bff50c0..2b2912ffcc7 100644 --- a/tests/baselines/reference/FunctionDeclaration8_es6.js +++ b/tests/baselines/reference/FunctionDeclaration8_es6.js @@ -2,5 +2,5 @@ var v = { [yield]: foo } //// [FunctionDeclaration8_es6.js] -var v = (_a = {}, _a[yield] = foo, _a); var _a; +var v = (_a = {}, _a[yield] = foo, _a); diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.Nested @param tags.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.Nested @param tags.json index 03cffdc49ff..73d3f598059 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.Nested @param tags.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.Nested @param tags.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 6, - "end": 63, + "end": 64, "atToken": { "kind": "AtToken", "pos": 6, @@ -21,11 +21,11 @@ "typeExpression": { "kind": "JSDocTypeExpression", "pos": 34, - "end": 63, + "end": 64, "type": { "kind": "JSDocTypeLiteral", "pos": 34, - "end": 63, + "end": 64, "jsDocPropertyTags": [ { "kind": "JSDocParameterTag", @@ -88,6 +88,6 @@ }, "length": 1, "pos": 6, - "end": 63 + "end": 64 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json index 00d7f0dcc30..cde6addda7c 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 40, + "end": 42, "atToken": { "kind": "AtToken", "pos": 8, @@ -40,6 +40,6 @@ }, "length": 1, "pos": 8, - "end": 40 + "end": 42 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json index 6953601f112..f193bc3fe9e 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 45, + "end": 47, "atToken": { "kind": "AtToken", "pos": 8, @@ -40,6 +40,6 @@ }, "length": 1, "pos": 8, - "end": 45 + "end": 47 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.less-than and greater-than characters.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.less-than and greater-than characters.json index 472fbbeb6bb..37d4610f987 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.less-than and greater-than characters.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.less-than and greater-than characters.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 7, - "end": 58, + "end": 59, "atToken": { "kind": "AtToken", "pos": 7, @@ -30,6 +30,6 @@ }, "length": 1, "pos": 7, - "end": 58 + "end": 59 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noReturnType.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noReturnType.json index 079d09c6eeb..204ba39d3dd 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noReturnType.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.noReturnType.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocReturnTag", "pos": 8, - "end": 16, + "end": 15, "atToken": { "kind": "AtToken", "pos": 8, @@ -21,6 +21,6 @@ }, "length": 1, "pos": 8, - "end": 16 + "end": 15 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json index 4940bcf325e..f5eee243cf5 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 30, + "end": 32, "atToken": { "kind": "AtToken", "pos": 8, @@ -39,6 +39,6 @@ }, "length": 1, "pos": 8, - "end": 30 + "end": 32 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json index b3e58d84923..cbbb64b5a73 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 55, + "end": 57, "atToken": { "kind": "AtToken", "pos": 8, @@ -40,6 +40,6 @@ }, "length": 1, "pos": 8, - "end": 55 + "end": 57 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json index 6721afb2ea7..a27e0d158e2 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 57, + "end": 59, "atToken": { "kind": "AtToken", "pos": 8, @@ -40,6 +40,6 @@ }, "length": 1, "pos": 8, - "end": 57 + "end": 59 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json index bf53423ad6a..d271a3b3483 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 62, + "end": 64, "atToken": { "kind": "AtToken", "pos": 8, @@ -40,6 +40,6 @@ }, "length": 1, "pos": 8, - "end": 62 + "end": 64 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json index 68edeb90190..57ab44a68b7 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 42, + "end": 44, "atToken": { "kind": "AtToken", "pos": 8, @@ -40,6 +40,6 @@ }, "length": 1, "pos": 8, - "end": 42 + "end": 44 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json index 3d511525c64..e85d787cd99 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocParameterTag", "pos": 8, - "end": 19, + "end": 21, "atToken": { "kind": "AtToken", "pos": 8, @@ -29,6 +29,6 @@ }, "length": 1, "pos": 8, - "end": 19 + "end": 21 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag.json index 8a146e3cfaf..4d16157d91d 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 20, + "end": 19, "atToken": { "kind": "AtToken", "pos": 8, @@ -22,7 +22,7 @@ "0": { "kind": "TypeParameter", "pos": 18, - "end": 20, + "end": 19, "name": { "kind": "Identifier", "pos": 18, @@ -32,11 +32,11 @@ }, "length": 1, "pos": 18, - "end": 20 + "end": 19 } }, "length": 1, "pos": 8, - "end": 20 + "end": 19 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag2.json index 5bb1df30665..3f5f2a54ec7 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag2.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 22, + "end": 21, "atToken": { "kind": "AtToken", "pos": 8, @@ -33,7 +33,7 @@ "1": { "kind": "TypeParameter", "pos": 20, - "end": 22, + "end": 21, "name": { "kind": "Identifier", "pos": 20, @@ -43,11 +43,11 @@ }, "length": 2, "pos": 18, - "end": 22 + "end": 21 } }, "length": 1, "pos": 8, - "end": 22 + "end": 21 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag3.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag3.json index 295b2122daa..ab1b9db8782 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag3.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag3.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 23, + "end": 22, "atToken": { "kind": "AtToken", "pos": 8, @@ -33,7 +33,7 @@ "1": { "kind": "TypeParameter", "pos": 21, - "end": 23, + "end": 22, "name": { "kind": "Identifier", "pos": 21, @@ -43,11 +43,11 @@ }, "length": 2, "pos": 18, - "end": 23 + "end": 22 } }, "length": 1, "pos": 8, - "end": 23 + "end": 22 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag4.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag4.json index 4aa29db3092..193c5c0eb01 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag4.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag4.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 23, + "end": 22, "atToken": { "kind": "AtToken", "pos": 8, @@ -33,7 +33,7 @@ "1": { "kind": "TypeParameter", "pos": 21, - "end": 23, + "end": 22, "name": { "kind": "Identifier", "pos": 21, @@ -43,11 +43,11 @@ }, "length": 2, "pos": 18, - "end": 23 + "end": 22 } }, "length": 1, "pos": 8, - "end": 23 + "end": 22 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag5.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag5.json index 5e707f6f03b..80e127b0759 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag5.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.templateTag5.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTemplateTag", "pos": 8, - "end": 24, + "end": 23, "atToken": { "kind": "AtToken", "pos": 8, @@ -33,7 +33,7 @@ "1": { "kind": "TypeParameter", "pos": 22, - "end": 24, + "end": 23, "name": { "kind": "Identifier", "pos": 22, @@ -43,11 +43,11 @@ }, "length": 2, "pos": 18, - "end": 24 + "end": 23 } }, "length": 1, "pos": 8, - "end": 24 + "end": 23 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json index 6f073802fcd..3a5e71ef8b1 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json @@ -40,7 +40,7 @@ "1": { "kind": "JSDocParameterTag", "pos": 34, - "end": 56, + "end": 58, "atToken": { "kind": "AtToken", "pos": 34, @@ -73,6 +73,6 @@ }, "length": 2, "pos": 8, - "end": 56 + "end": 58 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json index e1ef0adb926..51868df260b 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json @@ -40,7 +40,7 @@ "1": { "kind": "JSDocParameterTag", "pos": 30, - "end": 52, + "end": 54, "atToken": { "kind": "AtToken", "pos": 30, @@ -73,6 +73,6 @@ }, "length": 2, "pos": 8, - "end": 52 + "end": 54 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json index a4a69fc48a6..cf523b71c99 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json @@ -6,7 +6,7 @@ "0": { "kind": "JSDocTypedefTag", "pos": 8, - "end": 98, + "end": 100, "atToken": { "kind": "AtToken", "pos": 8, @@ -32,8 +32,8 @@ }, "typeExpression": { "kind": "JSDocTypeLiteral", - "pos": 26, - "end": 98, + "pos": 28, + "end": 100, "jsDocPropertyTags": [ { "kind": "JSDocPropertyTag", @@ -72,7 +72,7 @@ { "kind": "JSDocPropertyTag", "pos": 74, - "end": 98, + "end": 97, "atToken": { "kind": "AtToken", "pos": 74, @@ -108,6 +108,6 @@ }, "length": 1, "pos": 8, - "end": 98 + "end": 100 } } \ No newline at end of file diff --git a/tests/baselines/reference/SystemModuleForStatementNoInitializer.js b/tests/baselines/reference/SystemModuleForStatementNoInitializer.js index 2ab13a47c89..059e6175b30 100644 --- a/tests/baselines/reference/SystemModuleForStatementNoInitializer.js +++ b/tests/baselines/reference/SystemModuleForStatementNoInitializer.js @@ -19,9 +19,9 @@ for (; ;) { //// [SystemModuleForStatementNoInitializer.js] System.register([], function (exports_1, context_1) { + var i, limit; "use strict"; var __moduleName = context_1 && context_1.id; - var i, limit; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/aliasInaccessibleModule.errors.txt b/tests/baselines/reference/aliasInaccessibleModule.errors.txt deleted file mode 100644 index 3a9c64e50ab..00000000000 --- a/tests/baselines/reference/aliasInaccessibleModule.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/aliasInaccessibleModule.ts(4,23): error TS4000: Import declaration 'X' is using private name 'N'. - - -==== tests/cases/compiler/aliasInaccessibleModule.ts (1 errors) ==== - module M { - module N { - } - export import X = N; - ~ -!!! error TS4000: Import declaration 'X' is using private name 'N'. - } \ No newline at end of file diff --git a/tests/baselines/reference/aliasInaccessibleModule.js b/tests/baselines/reference/aliasInaccessibleModule.js index a0ecf3361fc..66a59a9f0ee 100644 --- a/tests/baselines/reference/aliasInaccessibleModule.js +++ b/tests/baselines/reference/aliasInaccessibleModule.js @@ -9,3 +9,11 @@ module M { var M; (function (M) { })(M || (M = {})); + + +//// [aliasInaccessibleModule.d.ts] +declare module M { + module N { + } + export import X = N; +} diff --git a/tests/baselines/reference/aliasInaccessibleModule2.errors.txt b/tests/baselines/reference/aliasInaccessibleModule2.errors.txt deleted file mode 100644 index 03a37147aba..00000000000 --- a/tests/baselines/reference/aliasInaccessibleModule2.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/compiler/aliasInaccessibleModule2.ts(7,16): error TS4000: Import declaration 'R' is using private name 'N'. - - -==== tests/cases/compiler/aliasInaccessibleModule2.ts (1 errors) ==== - module M { - module N { - class C { - } - - } - import R = N; - ~ -!!! error TS4000: Import declaration 'R' is using private name 'N'. - export import X = R; - } \ No newline at end of file diff --git a/tests/baselines/reference/aliasInaccessibleModule2.js b/tests/baselines/reference/aliasInaccessibleModule2.js index be208c07ca2..324581ce622 100644 --- a/tests/baselines/reference/aliasInaccessibleModule2.js +++ b/tests/baselines/reference/aliasInaccessibleModule2.js @@ -23,3 +23,12 @@ var M; var R = N; M.X = R; })(M || (M = {})); + + +//// [aliasInaccessibleModule2.d.ts] +declare module M { + module N { + } + import R = N; + export import X = R; +} diff --git a/tests/baselines/reference/aliasesInSystemModule1.js b/tests/baselines/reference/aliasesInSystemModule1.js index f940dd04597..340a8f53e3c 100644 --- a/tests/baselines/reference/aliasesInSystemModule1.js +++ b/tests/baselines/reference/aliasesInSystemModule1.js @@ -17,9 +17,9 @@ module M { //// [aliasesInSystemModule1.js] System.register(["foo"], function (exports_1, context_1) { + var alias, cls, cls2, x, y, z, M; "use strict"; var __moduleName = context_1 && context_1.id; - var alias, cls, cls2, x, y, z, M; return { setters: [ function (alias_1) { diff --git a/tests/baselines/reference/aliasesInSystemModule2.js b/tests/baselines/reference/aliasesInSystemModule2.js index 5ef48a52cde..88875297b2f 100644 --- a/tests/baselines/reference/aliasesInSystemModule2.js +++ b/tests/baselines/reference/aliasesInSystemModule2.js @@ -16,9 +16,9 @@ module M { //// [aliasesInSystemModule2.js] System.register(["foo"], function (exports_1, context_1) { + var foo_1, cls, cls2, x, y, z, M; "use strict"; var __moduleName = context_1 && context_1.id; - var foo_1, cls, cls2, x, y, z, M; return { setters: [ function (foo_1_1) { diff --git a/tests/baselines/reference/allowJscheckJsTypeParameterNoCrash.types b/tests/baselines/reference/allowJscheckJsTypeParameterNoCrash.types index 396cdd4445e..e1b331019bf 100644 --- a/tests/baselines/reference/allowJscheckJsTypeParameterNoCrash.types +++ b/tests/baselines/reference/allowJscheckJsTypeParameterNoCrash.types @@ -4,12 +4,12 @@ interface ComponentOptions { >V : V watch: Record>; ->watch : Record void> +>watch : Record> >Record : Record ->WatchHandler : (val: T) => void +>WatchHandler : WatchHandler } type WatchHandler = (val: T) => void; ->WatchHandler : (val: T) => void +>WatchHandler : WatchHandler >T : T >val : T >T : T diff --git a/tests/baselines/reference/allowSyntheticDefaultImports2.js b/tests/baselines/reference/allowSyntheticDefaultImports2.js index c1e43a4fc81..2ab6ae38c13 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports2.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports2.js @@ -11,9 +11,9 @@ export class Foo { //// [a.js] System.register(["./b"], function (exports_1, context_1) { + var b_1, x; "use strict"; var __moduleName = context_1 && context_1.id; - var b_1, x; return { setters: [ function (b_1_1) { diff --git a/tests/baselines/reference/allowSyntheticDefaultImports3.js b/tests/baselines/reference/allowSyntheticDefaultImports3.js index 45fb821a4e2..0e8207eaf26 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports3.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports3.js @@ -12,9 +12,9 @@ export class Foo { //// [b.js] System.register([], function (exports_1, context_1) { + var Foo; "use strict"; var __moduleName = context_1 && context_1.id; - var Foo; return { setters: [], execute: function () { @@ -29,9 +29,9 @@ System.register([], function (exports_1, context_1) { }); //// [a.js] System.register(["./b"], function (exports_1, context_1) { + var b_1, x; "use strict"; var __moduleName = context_1 && context_1.id; - var b_1, x; return { setters: [ function (b_1_1) { diff --git a/tests/baselines/reference/allowSyntheticDefaultImports5.js b/tests/baselines/reference/allowSyntheticDefaultImports5.js index 765d1140864..0ca15c82cde 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports5.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports5.js @@ -13,9 +13,9 @@ export var x = new Foo(); //// [a.js] System.register(["./b"], function (exports_1, context_1) { + var b_1, x; "use strict"; var __moduleName = context_1 && context_1.id; - var b_1, x; return { setters: [ function (b_1_1) { diff --git a/tests/baselines/reference/allowSyntheticDefaultImports6.js b/tests/baselines/reference/allowSyntheticDefaultImports6.js index 9ae7acae919..1d19b3fb46c 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports6.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports6.js @@ -13,9 +13,9 @@ export var x = new Foo(); //// [a.js] System.register(["./b"], function (exports_1, context_1) { + var b_1, x; "use strict"; var __moduleName = context_1 && context_1.id; - var b_1, x; return { setters: [ function (b_1_1) { diff --git a/tests/baselines/reference/allowSyntheticDefaultImports7.js b/tests/baselines/reference/allowSyntheticDefaultImports7.js index 6d0ea5b3be0..6a3d45ba59e 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports7.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports7.js @@ -12,9 +12,9 @@ Foo.foo(); //// [a.js] System.register(["./b"], function (exports_1, context_1) { + var b_1; "use strict"; var __moduleName = context_1 && context_1.id; - var b_1; return { setters: [ function (b_1_1) { diff --git a/tests/baselines/reference/allowSyntheticDefaultImports8.js b/tests/baselines/reference/allowSyntheticDefaultImports8.js index 5a77e51e6a2..dff56737805 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports8.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports8.js @@ -12,9 +12,9 @@ Foo.foo(); //// [a.js] System.register(["./b"], function (exports_1, context_1) { + var b_1; "use strict"; var __moduleName = context_1 && context_1.id; - var b_1; return { setters: [ function (b_1_1) { diff --git a/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.types b/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.types index 2953ede4026..d6f799c3667 100644 --- a/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.types +++ b/tests/baselines/reference/amdDeclarationEmitNoExtraDeclare.types @@ -1,6 +1,6 @@ === tests/cases/compiler/Class.ts === import { Configurable } from "./Configurable" ->Configurable : {}>(base: T) => T +>Configurable : >(base: T) => T export class HiddenClass {} >HiddenClass : HiddenClass @@ -8,7 +8,7 @@ export class HiddenClass {} export class ActualClass extends Configurable(HiddenClass) {} >ActualClass : ActualClass >Configurable(HiddenClass) : HiddenClass ->Configurable : {}>(base: T) => T +>Configurable : >(base: T) => T >HiddenClass : typeof HiddenClass === tests/cases/compiler/Configurable.ts === diff --git a/tests/baselines/reference/anonymousDefaultExportsSystem.js b/tests/baselines/reference/anonymousDefaultExportsSystem.js index c1d2cf522fb..bc3d35cda90 100644 --- a/tests/baselines/reference/anonymousDefaultExportsSystem.js +++ b/tests/baselines/reference/anonymousDefaultExportsSystem.js @@ -8,9 +8,9 @@ export default function() {} //// [a.js] System.register([], function (exports_1, context_1) { + var default_1; "use strict"; var __moduleName = context_1 && context_1.id; - var default_1; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index f6bc5e75781..cbf39a2a48f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -349,22 +349,24 @@ declare namespace ts { JSDocVariadicType = 284, JSDocComment = 285, JSDocTypeLiteral = 286, - JSDocTag = 287, - JSDocAugmentsTag = 288, - JSDocClassTag = 289, - JSDocParameterTag = 290, - JSDocReturnTag = 291, - JSDocTypeTag = 292, - JSDocTemplateTag = 293, - JSDocTypedefTag = 294, - JSDocPropertyTag = 295, - SyntaxList = 296, - NotEmittedStatement = 297, - PartiallyEmittedExpression = 298, - CommaListExpression = 299, - MergeDeclarationMarker = 300, - EndOfDeclarationMarker = 301, - Count = 302, + JSDocSignature = 287, + JSDocTag = 288, + JSDocAugmentsTag = 289, + JSDocClassTag = 290, + JSDocCallbackTag = 291, + JSDocParameterTag = 292, + JSDocReturnTag = 293, + JSDocTypeTag = 294, + JSDocTemplateTag = 295, + JSDocTypedefTag = 296, + JSDocPropertyTag = 297, + SyntaxList = 298, + NotEmittedStatement = 299, + PartiallyEmittedExpression = 300, + CommaListExpression = 301, + MergeDeclarationMarker = 302, + EndOfDeclarationMarker = 303, + Count = 304, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -391,9 +393,9 @@ declare namespace ts { LastBinaryOperator = 70, FirstNode = 145, FirstJSDocNode = 277, - LastJSDocNode = 295, - FirstJSDocTagNode = 287, - LastJSDocTagNode = 295 + LastJSDocNode = 297, + FirstJSDocTagNode = 288, + LastJSDocTagNode = 297 } enum NodeFlags { None = 0, @@ -1280,7 +1282,7 @@ declare namespace ts { block: Block; } type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; + type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; @@ -1537,6 +1539,19 @@ declare namespace ts { name?: Identifier; typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; } + interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { + parent: JSDoc; + kind: SyntaxKind.JSDocCallbackTag; + fullName?: JSDocNamespaceDeclaration | Identifier; + name?: Identifier; + typeExpression: JSDocSignature; + } + interface JSDocSignature extends JSDocType, Declaration { + kind: SyntaxKind.JSDocSignature; + typeParameters?: ReadonlyArray; + parameters: ReadonlyArray; + type: JSDocReturnTag | undefined; + } interface JSDocPropertyLikeTag extends JSDocTag, Declaration { parent: JSDoc; name: EntityName; @@ -1883,7 +1898,9 @@ declare namespace ts { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, + GenerateNamesForShadowedTypeParams = 4, UseStructuralFallback = 8, + ForbidIndexedAccessSymbolReferences = 16, WriteTypeArgumentsOfSignature = 32, UseFullyQualifiedType = 64, UseOnlyExternalAliasing = 128, @@ -2247,6 +2264,7 @@ declare namespace ts { objectType: Type; indexType: Type; constraint?: Type; + simplified?: Type; } type TypeVariable = TypeParameter | IndexedAccessType; interface IndexType extends InstantiableType { @@ -2281,7 +2299,7 @@ declare namespace ts { Construct = 1 } interface Signature { - declaration?: SignatureDeclaration; + declaration?: SignatureDeclaration | JSDocSignature; typeParameters?: TypeParameter[]; parameters: Symbol[]; } @@ -2979,10 +2997,11 @@ declare namespace ts { readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; getModifiedTime?(path: string): Date; /** - * This should be cryptographically secure. * A good implementation is node.js' `crypto.createHash`. (https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) */ createHash?(data: string): string; + /** This must be cryptographically secure. Only implement this method using `crypto.createHash("sha256")`. */ + createSHA256Hash?(data: string): string; getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; @@ -3359,6 +3378,8 @@ declare namespace ts { function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag; function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag; function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral; + function isJSDocCallbackTag(node: Node): node is JSDocCallbackTag; + function isJSDocSignature(node: Node): node is JSDocSignature; } declare namespace ts { /** @@ -3484,6 +3505,8 @@ declare namespace ts { function createLiteral(value: boolean): BooleanLiteral; function createLiteral(value: string | number | boolean): PrimaryExpression; function createNumericLiteral(value: string): NumericLiteral; + function createStringLiteral(text: string): StringLiteral; + function createRegularExpressionLiteral(text: string): RegularExpressionLiteral; function createIdentifier(text: string): Identifier; function updateIdentifier(node: Identifier): Identifier; /** Create a unique temporary variable. */ @@ -3855,6 +3878,7 @@ declare namespace ts { function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined; function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[]): T; function addSyntheticTrailingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; + function moveSyntheticComments(node: T, original: Node): T; /** * Gets the constant value to emit for an expression. */ @@ -4326,7 +4350,7 @@ declare namespace ts { getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; - getWidth(sourceFile?: SourceFile): number; + getWidth(sourceFile?: SourceFileLike): number; getFullWidth(): number; getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; @@ -4453,6 +4477,7 @@ declare namespace ts { fileExists?(path: string): boolean; getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; + getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getDirectories?(directoryName: string): string[]; /** @@ -4468,6 +4493,7 @@ declare namespace ts { readonly includeCompletionsForModuleExports?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; + readonly allowTextChangesInNewFiles?: boolean; } interface LanguageService { cleanupSemanticCache(): void; @@ -4611,6 +4637,7 @@ declare namespace ts { interface FileTextChanges { fileName: string; textChanges: TextChange[]; + isNewFile?: boolean; } interface CodeAction { /** Description of the code action to display in the UI of the editor */ @@ -4697,6 +4724,12 @@ declare namespace ts { interface DocumentSpan { textSpan: TextSpan; fileName: string; + /** + * If the span represents a location that was remapped (e.g. via a .d.ts.map file), + * then the original filename and span will be specified here + */ + originalTextSpan?: TextSpan; + originalFileName?: string; } interface RenameLocation extends DocumentSpan { } @@ -4794,9 +4827,7 @@ declare namespace ts { insertSpaceBeforeTypeAnnotation?: boolean; indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; } - interface DefinitionInfo { - fileName: string; - textSpan: TextSpan; + interface DefinitionInfo extends DocumentSpan { kind: ScriptElementKind; name: string; containerKind: ScriptElementKind; @@ -7569,6 +7600,7 @@ declare namespace ts.server.protocol { */ readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; + readonly allowTextChangesInNewFiles?: boolean; } interface CompilerOptions { allowJs?: boolean; @@ -7734,7 +7766,7 @@ declare namespace ts.server { enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray): void; attach(projectService: ProjectService): void; onProjectClosed(p: Project): void; - readonly globalTypingsCacheLocation: string; + readonly globalTypingsCacheLocation: string | undefined; } const nullTypingsInstaller: ITypingsInstaller; } @@ -7833,6 +7865,7 @@ declare namespace ts.server { readFile(fileName: string): string | undefined; fileExists(file: string): boolean; resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModuleFull[]; + getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations; resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists(path: string): boolean; getDirectories(path: string): string[]; @@ -7886,7 +7919,7 @@ declare namespace ts.server { private detachScriptInfoFromProject; private addMissingFileWatcher; private isWatchedMissingFile; - getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo | undefined; getScriptInfo(uncheckedFileName: string): ScriptInfo; filesToString(writeProjectFileNames: boolean): string; setCompilerOptions(compilerOptions: CompilerOptions): void; @@ -7971,6 +8004,7 @@ declare namespace ts.server { const ConfigFileDiagEvent = "configFileDiag"; const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; const ProjectInfoTelemetryEvent = "projectInfo"; + const OpenFileInfoTelemetryEvent = "openFileInfo"; interface ProjectsUpdatedInBackgroundEvent { eventName: typeof ProjectsUpdatedInBackgroundEvent; data: { @@ -8019,6 +8053,18 @@ declare namespace ts.server { /** 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; + } + interface OpenFileInfoTelemetryEventData { + readonly info: OpenFileInfo; + } interface ProjectInfoTypeAcquisitionData { readonly enable: boolean; readonly include: boolean; @@ -8030,8 +8076,12 @@ declare namespace ts.server { readonly ts: number; readonly tsx: number; readonly dts: number; + readonly deferred: number; } - type ProjectServiceEvent = ProjectsUpdatedInBackgroundEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent; + interface OpenFileInfo { + readonly checkJs: boolean; + } + type ProjectServiceEvent = ProjectsUpdatedInBackgroundEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void; interface SafeList { [name: string]: { @@ -8082,6 +8132,7 @@ declare namespace ts.server { * Container of all known scripts */ private readonly filenameToScriptInfo; + private readonly allJsFilesForOpenFileTelemetry; /** * maps external project file name to list of config files that were the part of this project */ @@ -8286,6 +8337,7 @@ declare namespace ts.server { 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 @@ -8387,6 +8439,7 @@ declare namespace ts.server { private getDefinition; private getDefinitionAndBoundSpan; private mapDefinitionInfo; + private static mapToOriginalLocation; private toFileSpan; private getTypeDefinition; private getImplementation; @@ -8460,6 +8513,7 @@ declare namespace ts.server { private mapTextChangesToCodeEdits; private mapTextChangesToCodeEditsUsingScriptinfo; private convertTextChangeToCodeEdit; + private convertNewFileTextChangeToCodeEdit; private getBraceMatching; private getDiagnosticsForProject; getCanonicalFileName(fileName: string): string; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index de20defcdcb..b449fc853c6 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -349,22 +349,24 @@ declare namespace ts { JSDocVariadicType = 284, JSDocComment = 285, JSDocTypeLiteral = 286, - JSDocTag = 287, - JSDocAugmentsTag = 288, - JSDocClassTag = 289, - JSDocParameterTag = 290, - JSDocReturnTag = 291, - JSDocTypeTag = 292, - JSDocTemplateTag = 293, - JSDocTypedefTag = 294, - JSDocPropertyTag = 295, - SyntaxList = 296, - NotEmittedStatement = 297, - PartiallyEmittedExpression = 298, - CommaListExpression = 299, - MergeDeclarationMarker = 300, - EndOfDeclarationMarker = 301, - Count = 302, + JSDocSignature = 287, + JSDocTag = 288, + JSDocAugmentsTag = 289, + JSDocClassTag = 290, + JSDocCallbackTag = 291, + JSDocParameterTag = 292, + JSDocReturnTag = 293, + JSDocTypeTag = 294, + JSDocTemplateTag = 295, + JSDocTypedefTag = 296, + JSDocPropertyTag = 297, + SyntaxList = 298, + NotEmittedStatement = 299, + PartiallyEmittedExpression = 300, + CommaListExpression = 301, + MergeDeclarationMarker = 302, + EndOfDeclarationMarker = 303, + Count = 304, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -391,9 +393,9 @@ declare namespace ts { LastBinaryOperator = 70, FirstNode = 145, FirstJSDocNode = 277, - LastJSDocNode = 295, - FirstJSDocTagNode = 287, - LastJSDocTagNode = 295 + LastJSDocNode = 297, + FirstJSDocTagNode = 288, + LastJSDocTagNode = 297 } enum NodeFlags { None = 0, @@ -1280,7 +1282,7 @@ declare namespace ts { block: Block; } type ObjectTypeDeclaration = ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode; - type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; + type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag | JSDocTypedefTag | JSDocCallbackTag | JSDocSignature; interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; @@ -1537,6 +1539,19 @@ declare namespace ts { name?: Identifier; typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; } + interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { + parent: JSDoc; + kind: SyntaxKind.JSDocCallbackTag; + fullName?: JSDocNamespaceDeclaration | Identifier; + name?: Identifier; + typeExpression: JSDocSignature; + } + interface JSDocSignature extends JSDocType, Declaration { + kind: SyntaxKind.JSDocSignature; + typeParameters?: ReadonlyArray; + parameters: ReadonlyArray; + type: JSDocReturnTag | undefined; + } interface JSDocPropertyLikeTag extends JSDocTag, Declaration { parent: JSDoc; name: EntityName; @@ -1883,7 +1898,9 @@ declare namespace ts { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, + GenerateNamesForShadowedTypeParams = 4, UseStructuralFallback = 8, + ForbidIndexedAccessSymbolReferences = 16, WriteTypeArgumentsOfSignature = 32, UseFullyQualifiedType = 64, UseOnlyExternalAliasing = 128, @@ -2247,6 +2264,7 @@ declare namespace ts { objectType: Type; indexType: Type; constraint?: Type; + simplified?: Type; } type TypeVariable = TypeParameter | IndexedAccessType; interface IndexType extends InstantiableType { @@ -2281,7 +2299,7 @@ declare namespace ts { Construct = 1 } interface Signature { - declaration?: SignatureDeclaration; + declaration?: SignatureDeclaration | JSDocSignature; typeParameters?: TypeParameter[]; parameters: Symbol[]; } @@ -2979,10 +2997,11 @@ declare namespace ts { readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; getModifiedTime?(path: string): Date; /** - * This should be cryptographically secure. * A good implementation is node.js' `crypto.createHash`. (https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) */ createHash?(data: string): string; + /** This must be cryptographically secure. Only implement this method using `crypto.createHash("sha256")`. */ + createSHA256Hash?(data: string): string; getMemoryUsage?(): number; exit(exitCode?: number): void; realpath?(path: string): string; @@ -3359,6 +3378,8 @@ declare namespace ts { function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag; function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag; function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral; + function isJSDocCallbackTag(node: Node): node is JSDocCallbackTag; + function isJSDocSignature(node: Node): node is JSDocSignature; } declare namespace ts { /** @@ -3484,6 +3505,8 @@ declare namespace ts { function createLiteral(value: boolean): BooleanLiteral; function createLiteral(value: string | number | boolean): PrimaryExpression; function createNumericLiteral(value: string): NumericLiteral; + function createStringLiteral(text: string): StringLiteral; + function createRegularExpressionLiteral(text: string): RegularExpressionLiteral; function createIdentifier(text: string): Identifier; function updateIdentifier(node: Identifier): Identifier; /** Create a unique temporary variable. */ @@ -3855,6 +3878,7 @@ declare namespace ts { function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined; function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[]): T; function addSyntheticTrailingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; + function moveSyntheticComments(node: T, original: Node): T; /** * Gets the constant value to emit for an expression. */ @@ -4326,7 +4350,7 @@ declare namespace ts { getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; - getWidth(sourceFile?: SourceFile): number; + getWidth(sourceFile?: SourceFileLike): number; getFullWidth(): number; getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; @@ -4453,6 +4477,7 @@ declare namespace ts { fileExists?(path: string): boolean; getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; + getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getDirectories?(directoryName: string): string[]; /** @@ -4468,6 +4493,7 @@ declare namespace ts { readonly includeCompletionsForModuleExports?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; + readonly allowTextChangesInNewFiles?: boolean; } interface LanguageService { cleanupSemanticCache(): void; @@ -4611,6 +4637,7 @@ declare namespace ts { interface FileTextChanges { fileName: string; textChanges: TextChange[]; + isNewFile?: boolean; } interface CodeAction { /** Description of the code action to display in the UI of the editor */ @@ -4697,6 +4724,12 @@ declare namespace ts { interface DocumentSpan { textSpan: TextSpan; fileName: string; + /** + * If the span represents a location that was remapped (e.g. via a .d.ts.map file), + * then the original filename and span will be specified here + */ + originalTextSpan?: TextSpan; + originalFileName?: string; } interface RenameLocation extends DocumentSpan { } @@ -4794,9 +4827,7 @@ declare namespace ts { insertSpaceBeforeTypeAnnotation?: boolean; indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; } - interface DefinitionInfo { - fileName: string; - textSpan: TextSpan; + interface DefinitionInfo extends DocumentSpan { kind: ScriptElementKind; name: string; containerKind: ScriptElementKind; diff --git a/tests/baselines/reference/assignmentTypeNarrowing.js b/tests/baselines/reference/assignmentTypeNarrowing.js index 92fd49d9941..4d6b911b88b 100644 --- a/tests/baselines/reference/assignmentTypeNarrowing.js +++ b/tests/baselines/reference/assignmentTypeNarrowing.js @@ -30,6 +30,7 @@ for (x of a) { //// [assignmentTypeNarrowing.js] +var _a, _b, _c; var x; x = ""; x; // string @@ -50,4 +51,3 @@ for (var _i = 0, a_1 = a; _i < a_1.length; _i++) { x = a_1[_i]; x; // string } -var _a, _b, _c; diff --git a/tests/baselines/reference/asyncArrowFunction7_es5.js b/tests/baselines/reference/asyncArrowFunction7_es5.js index b93966443ab..6988d1d019a 100644 --- a/tests/baselines/reference/asyncArrowFunction7_es5.js +++ b/tests/baselines/reference/asyncArrowFunction7_es5.js @@ -8,8 +8,8 @@ var bar = async (): Promise => { //// [asyncArrowFunction7_es5.js] var _this = this; var bar = function () { return __awaiter(_this, void 0, void 0, function () { - var _this = this; var foo; + var _this = this; return __generator(this, function (_a) { foo = function (a) { if (a === void 0) { a = yield ; } diff --git a/tests/baselines/reference/asyncArrowFunction8_es5.js b/tests/baselines/reference/asyncArrowFunction8_es5.js index 26153a59436..7e9e5a492be 100644 --- a/tests/baselines/reference/asyncArrowFunction8_es5.js +++ b/tests/baselines/reference/asyncArrowFunction8_es5.js @@ -6,7 +6,7 @@ var foo = async (): Promise => { //// [asyncArrowFunction8_es5.js] var _this = this; var foo = function () { return __awaiter(_this, void 0, void 0, function () { - var v, _a; + var _a, v; return __generator(this, function (_b) { switch (_b.label) { case 0: diff --git a/tests/baselines/reference/asyncAwaitNestedClasses_es5.js b/tests/baselines/reference/asyncAwaitNestedClasses_es5.js index ff806b76ff1..f72dda7bec2 100644 --- a/tests/baselines/reference/asyncAwaitNestedClasses_es5.js +++ b/tests/baselines/reference/asyncAwaitNestedClasses_es5.js @@ -20,6 +20,7 @@ A.B.C.func(); var A = /** @class */ (function () { function A() { } + var _a; A.B = (_a = /** @class */ (function () { function B() { } @@ -47,6 +48,5 @@ var A = /** @class */ (function () { }()), _a); return A; - var _a; }()); A.B.C.func(); diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es5.js b/tests/baselines/reference/asyncFunctionDeclaration8_es5.js index 3e518481178..994ebfe6c7c 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration8_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es5.js @@ -2,5 +2,5 @@ var v = { [await]: foo } //// [asyncFunctionDeclaration8_es5.js] -var v = (_a = {}, _a[await] = foo, _a); var _a; +var v = (_a = {}, _a[await] = foo, _a); diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es5.js b/tests/baselines/reference/asyncFunctionDeclaration9_es5.js index e35ec29595b..2fd29408422 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration9_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es5.js @@ -6,7 +6,7 @@ async function foo(): Promise { //// [asyncFunctionDeclaration9_es5.js] function foo() { return __awaiter(this, void 0, void 0, function () { - var v, _a; + var _a, v; return __generator(this, function (_b) { switch (_b.label) { case 0: diff --git a/tests/baselines/reference/asyncFunctionTempVariableScoping.js b/tests/baselines/reference/asyncFunctionTempVariableScoping.js index b4f8caa6508..fb4137e1671 100644 --- a/tests/baselines/reference/asyncFunctionTempVariableScoping.js +++ b/tests/baselines/reference/asyncFunctionTempVariableScoping.js @@ -51,8 +51,8 @@ var __rest = (this && this.__rest) || function (s, e) { }; var _this = this; (function (_a) { return __awaiter(_this, void 0, void 0, function () { - var foo = _a.foo, bar = _a.bar, rest = __rest(_a, ["foo", "bar"]); var _b; + var foo = _a.foo, bar = _a.bar, rest = __rest(_a, ["foo", "bar"]); return __generator(this, function (_c) { switch (_c.label) { case 0: diff --git a/tests/baselines/reference/asyncImportNestedYield.js b/tests/baselines/reference/asyncImportNestedYield.js index 776caed5167..74d6dd59629 100644 --- a/tests/baselines/reference/asyncImportNestedYield.js +++ b/tests/baselines/reference/asyncImportNestedYield.js @@ -38,7 +38,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } diff --git a/tests/baselines/reference/asyncWithVarShadowing_es6.js b/tests/baselines/reference/asyncWithVarShadowing_es6.js index 392bed9d294..ecdffcd25a5 100644 --- a/tests/baselines/reference/asyncWithVarShadowing_es6.js +++ b/tests/baselines/reference/asyncWithVarShadowing_es6.js @@ -224,14 +224,14 @@ async function fn40(x) { //// [asyncWithVarShadowing_es6.js] function fn1(x) { + var x; return __awaiter(this, void 0, void 0, function* () { }); - var x; } function fn2(x) { + var x, z; return __awaiter(this, void 0, void 0, function* () { }); - var x, z; } function fn3(x) { return __awaiter(this, void 0, void 0, function* () { @@ -239,139 +239,139 @@ function fn3(x) { }); } function fn4(x) { + var x; return __awaiter(this, void 0, void 0, function* () { x = y; }); - var x; } function fn5(x) { + var x; return __awaiter(this, void 0, void 0, function* () { ({ x } = y); }); - var x; } function fn6(x) { + var x, z; return __awaiter(this, void 0, void 0, function* () { ({ x, z } = y); }); - var x, z; } function fn7(x) { + var x; return __awaiter(this, void 0, void 0, function* () { ({ x = y } = y); }); - var x; } function fn8(x) { + var x; return __awaiter(this, void 0, void 0, function* () { ({ z: x } = y); }); - var x; } function fn9(x) { + var x; return __awaiter(this, void 0, void 0, function* () { ({ z: { x } } = y); }); - var x; } function fn10(x) { + var x; return __awaiter(this, void 0, void 0, function* () { ({ z: { x } = y } = y); }); - var x; } function fn11(x) { + var x; return __awaiter(this, void 0, void 0, function* () { x = __rest(y, []); }); - var x; } function fn12(x) { + var x; return __awaiter(this, void 0, void 0, function* () { [x] = y; }); - var x; } function fn13(x) { + var x; return __awaiter(this, void 0, void 0, function* () { [x = y] = y; }); - var x; } function fn14(x) { + var x; return __awaiter(this, void 0, void 0, function* () { [, x] = y; }); - var x; } function fn15(x) { + var x; return __awaiter(this, void 0, void 0, function* () { [...x] = y; }); - var x; } function fn16(x) { + var x; return __awaiter(this, void 0, void 0, function* () { [[x]] = y; }); - var x; } function fn17(x) { + var x; return __awaiter(this, void 0, void 0, function* () { [[x] = y] = y; }); - var x; } function fn18({ x }) { + var x; return __awaiter(this, void 0, void 0, function* () { }); - var x; } function fn19([x]) { + var x; return __awaiter(this, void 0, void 0, function* () { }); - var x; } function fn20(x) { + var x; return __awaiter(this, void 0, void 0, function* () { { } }); - var x; } function fn21(x) { + var x; return __awaiter(this, void 0, void 0, function* () { if (y) { } }); - var x; } function fn22(x) { + var x; return __awaiter(this, void 0, void 0, function* () { if (y) { } else { } }); - var x; } function fn23(x) { + var x; return __awaiter(this, void 0, void 0, function* () { try { } catch (e) { } }); - var x; } function fn24(x) { + var x; return __awaiter(this, void 0, void 0, function* () { try { } catch (e) { } }); - var x; } function fn25(x) { return __awaiter(this, void 0, void 0, function* () { @@ -392,106 +392,106 @@ function fn26(x) { }); } function fn27(x) { + var x; return __awaiter(this, void 0, void 0, function* () { try { } finally { } }); - var x; } function fn28(x) { + var x; return __awaiter(this, void 0, void 0, function* () { while (y) { } }); - var x; } function fn29(x) { + var x; return __awaiter(this, void 0, void 0, function* () { do { } while (y); }); - var x; } function fn30(x) { + var x; return __awaiter(this, void 0, void 0, function* () { for (x = y;;) { } }); - var x; } function fn31(x) { + var x; return __awaiter(this, void 0, void 0, function* () { for ({ x } = y;;) { } }); - var x; } function fn32(x) { + var x; return __awaiter(this, void 0, void 0, function* () { for (;;) { } }); - var x; } function fn33(x) { + var x; return __awaiter(this, void 0, void 0, function* () { for (x in y) { } }); - var x; } function fn34(x) { + var x; return __awaiter(this, void 0, void 0, function* () { for (var z in y) { } }); - var x; } function fn35(x) { + var x; return __awaiter(this, void 0, void 0, function* () { for (x of y) { } }); - var x; } function fn36(x) { + var x; return __awaiter(this, void 0, void 0, function* () { for ({ x } of y) { } }); - var x; } function fn37(x) { + var x; return __awaiter(this, void 0, void 0, function* () { for (var z of y) { } }); - var x; } function fn38(x) { + var x; return __awaiter(this, void 0, void 0, function* () { switch (y) { case y: } }); - var x; } function fn39(x) { + var x; return __awaiter(this, void 0, void 0, function* () { foo: { break foo; } }); - var x; } function fn40(x) { + var x; return __awaiter(this, void 0, void 0, function* () { try { } catch (_a) { } }); - var x; } diff --git a/tests/baselines/reference/augmentExportEquals5.types b/tests/baselines/reference/augmentExportEquals5.types index c071a195f0e..f9cc2bfeae9 100644 --- a/tests/baselines/reference/augmentExportEquals5.types +++ b/tests/baselines/reference/augmentExportEquals5.types @@ -18,7 +18,7 @@ declare module "express" { function e(): e.Express; >e : typeof e >e : any ->Express : Express +>Express : e.Express namespace e { >e : typeof e diff --git a/tests/baselines/reference/bindingPatternOmittedExpressionNesting.js b/tests/baselines/reference/bindingPatternOmittedExpressionNesting.js index cde242c14ea..e8a8e02a6a1 100644 --- a/tests/baselines/reference/bindingPatternOmittedExpressionNesting.js +++ b/tests/baselines/reference/bindingPatternOmittedExpressionNesting.js @@ -4,8 +4,8 @@ export let [,,[,[],,[],]] = undefined as any; //// [bindingPatternOmittedExpressionNesting.js] "use strict"; exports.__esModule = true; -exports._e = (_a = undefined, _b = _a[2], _c = _b[1], _d = _b[3]); var _a, _b, _c, _d; +exports._e = (_a = undefined, _b = _a[2], _c = _b[1], _d = _b[3]); //// [bindingPatternOmittedExpressionNesting.d.ts] diff --git a/tests/baselines/reference/blockScopedBindingsInDownlevelGenerator.js b/tests/baselines/reference/blockScopedBindingsInDownlevelGenerator.js index be2bcd0bb0c..5f3eed666ab 100644 --- a/tests/baselines/reference/blockScopedBindingsInDownlevelGenerator.js +++ b/tests/baselines/reference/blockScopedBindingsInDownlevelGenerator.js @@ -45,7 +45,7 @@ var __values = (this && this.__values) || function (o) { }; }; function a() { - var _loop_1, _a, _b, i, e_1_1, e_1, _c; + var e_1, _a, _loop_1, _b, _c, i, e_1_1; return __generator(this, function (_d) { switch (_d.label) { case 0: @@ -64,17 +64,17 @@ function a() { _d.label = 1; case 1: _d.trys.push([1, 6, 7, 8]); - _a = __values([1, 2, 3]), _b = _a.next(); + _b = __values([1, 2, 3]), _c = _b.next(); _d.label = 2; case 2: - if (!!_b.done) return [3 /*break*/, 5]; - i = _b.value; + if (!!_c.done) return [3 /*break*/, 5]; + i = _c.value; return [5 /*yield**/, _loop_1(i)]; case 3: _d.sent(); _d.label = 4; case 4: - _b = _a.next(); + _c = _b.next(); return [3 /*break*/, 2]; case 5: return [3 /*break*/, 8]; case 6: @@ -83,7 +83,7 @@ function a() { return [3 /*break*/, 8]; case 7: try { - if (_b && !_b.done && (_c = _a.return)) _c.call(_a); + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } return [7 /*endfinally*/]; diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js index b0e58c59f5f..b14ea2a3069 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js @@ -163,6 +163,7 @@ function foo8() { var x; } function foo9() { + var _a; var y = (_a = /** @class */ (function () { function class_3() { } @@ -171,7 +172,6 @@ function foo9() { _a.a = x, _a); var x; - var _a; } function foo10() { var A = /** @class */ (function () { @@ -184,6 +184,7 @@ function foo10() { } function foo11() { function f() { + var _a; var y = (_a = /** @class */ (function () { function class_4() { } @@ -191,7 +192,6 @@ function foo11() { }()), _a.a = x, _a); - var _a; } var x; } diff --git a/tests/baselines/reference/callWithSpread.js b/tests/baselines/reference/callWithSpread.js index 2059c7ab090..1b78ebeb8ec 100644 --- a/tests/baselines/reference/callWithSpread.js +++ b/tests/baselines/reference/callWithSpread.js @@ -69,6 +69,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +var _a, _b, _c, _d, _e, _f, _g; function foo(x, y) { var z = []; for (var _i = 2; _i < arguments.length; _i++) { @@ -128,4 +129,3 @@ var D = /** @class */ (function (_super) { }; return D; }(C)); -var _a, _b, _c, _d, _e, _f, _g; diff --git a/tests/baselines/reference/callbackCrossModule.symbols b/tests/baselines/reference/callbackCrossModule.symbols new file mode 100644 index 00000000000..be8175c4a11 --- /dev/null +++ b/tests/baselines/reference/callbackCrossModule.symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/jsdoc/mod1.js === +/** @callback Con - some kind of continuation + * @param {object | undefined} error + * @return {any} I don't even know what this should return + */ +module.exports = C +>module : Symbol(export=, Decl(mod1.js, 0, 0)) +>exports : Symbol(export=, Decl(mod1.js, 0, 0)) +>C : Symbol(C, Decl(mod1.js, 4, 18)) + +function C() { +>C : Symbol(C, Decl(mod1.js, 4, 18)) + + this.p = 1 +>p : Symbol(C.p, Decl(mod1.js, 5, 14)) +} + +=== tests/cases/conformance/jsdoc/use.js === +/** @param {import('./mod1').Con} k */ +function f(k) { +>f : Symbol(f, Decl(use.js, 0, 0)) +>k : Symbol(k, Decl(use.js, 1, 11)) + + if (1 === 2 - 1) { + // I guess basic math works! + } + return k({ ok: true}) +>k : Symbol(k, Decl(use.js, 1, 11)) +>ok : Symbol(ok, Decl(use.js, 5, 14)) +} + + diff --git a/tests/baselines/reference/callbackCrossModule.types b/tests/baselines/reference/callbackCrossModule.types new file mode 100644 index 00000000000..2f7619585b9 --- /dev/null +++ b/tests/baselines/reference/callbackCrossModule.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/jsdoc/mod1.js === +/** @callback Con - some kind of continuation + * @param {object | undefined} error + * @return {any} I don't even know what this should return + */ +module.exports = C +>module.exports = C : typeof C +>module.exports : any +>module : any +>exports : any +>C : typeof C + +function C() { +>C : typeof C + + this.p = 1 +>this.p = 1 : 1 +>this.p : any +>this : any +>p : any +>1 : 1 +} + +=== tests/cases/conformance/jsdoc/use.js === +/** @param {import('./mod1').Con} k */ +function f(k) { +>f : (k: import("tests/cases/conformance/jsdoc/mod1").Con) => any +>k : import("tests/cases/conformance/jsdoc/mod1").Con + + if (1 === 2 - 1) { +>1 === 2 - 1 : boolean +>1 : 1 +>2 - 1 : number +>2 : 2 +>1 : 1 + + // I guess basic math works! + } + return k({ ok: true}) +>k({ ok: true}) : any +>k : import("tests/cases/conformance/jsdoc/mod1").Con +>{ ok: true} : { ok: boolean; } +>ok : boolean +>true : true +} + + diff --git a/tests/baselines/reference/callbackTag1.symbols b/tests/baselines/reference/callbackTag1.symbols new file mode 100644 index 00000000000..b52ac8f92c8 --- /dev/null +++ b/tests/baselines/reference/callbackTag1.symbols @@ -0,0 +1,28 @@ +=== tests/cases/conformance/jsdoc/cb.js === +/** @callback Sid + * @param {string} s + * @returns {string} What were you expecting + */ +var x = 1 +>x : Symbol(x, Decl(cb.js, 4, 3)) + +/** @type {Sid} smallId */ +var sid = s => s + "!"; +>sid : Symbol(sid, Decl(cb.js, 7, 3)) +>s : Symbol(s, Decl(cb.js, 7, 9)) +>s : Symbol(s, Decl(cb.js, 7, 9)) + + +/** @type {NoReturn} */ +var noreturn = obj => void obj.title +>noreturn : Symbol(noreturn, Decl(cb.js, 11, 3)) +>obj : Symbol(obj, Decl(cb.js, 11, 14)) +>obj.title : Symbol(title, Decl(cb.js, 15, 34)) +>obj : Symbol(obj, Decl(cb.js, 11, 14)) +>title : Symbol(title, Decl(cb.js, 15, 34)) + +/** + * @callback NoReturn + * @param {{ e: number, m: number, title: string }} s - Knee deep, shores, etc + */ + diff --git a/tests/baselines/reference/callbackTag1.types b/tests/baselines/reference/callbackTag1.types new file mode 100644 index 00000000000..2f1e64c8edc --- /dev/null +++ b/tests/baselines/reference/callbackTag1.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/jsdoc/cb.js === +/** @callback Sid + * @param {string} s + * @returns {string} What were you expecting + */ +var x = 1 +>x : number +>1 : 1 + +/** @type {Sid} smallId */ +var sid = s => s + "!"; +>sid : Sid +>s => s + "!" : (s: string) => string +>s : string +>s + "!" : string +>s : string +>"!" : "!" + + +/** @type {NoReturn} */ +var noreturn = obj => void obj.title +>noreturn : (s: { e: number; m: number; title: string; }) => any +>obj => void obj.title : (obj: { e: number; m: number; title: string; }) => any +>obj : { e: number; m: number; title: string; } +>void obj.title : undefined +>obj.title : string +>obj : { e: number; m: number; title: string; } +>title : string + +/** + * @callback NoReturn + * @param {{ e: number, m: number, title: string }} s - Knee deep, shores, etc + */ + diff --git a/tests/baselines/reference/callbackTag2.errors.txt b/tests/baselines/reference/callbackTag2.errors.txt new file mode 100644 index 00000000000..8be9e901020 --- /dev/null +++ b/tests/baselines/reference/callbackTag2.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/jsdoc/cb.js(18,29): error TS2304: Cannot find name 'S'. + + +==== tests/cases/conformance/jsdoc/cb.js (1 errors) ==== + /** @template T + * @callback Id + * @param {T} t + * @returns {T} Maybe just return 120 and cast it? + */ + var x = 1 + + /** @type {Id} I actually wanted to write `const "120"` */ + var one_twenty = s => "120"; + + /** @template S + * @callback SharedId + * @param {S} ego + * @return {S} + */ + class SharedClass { + constructor() { + /** @type {SharedId} */ + ~ +!!! error TS2304: Cannot find name 'S'. + this.id; + } + } + /** @type {SharedId} */ + var outside = n => n + 1; + + /** @type {Final<{ fantasy }, { heroes }>} */ + var noreturn = (barts, tidus, noctis) => "cecil" + + /** + * @template V,X + * @callback Final + * @param {V} barts - "Barts" + * @param {X} tidus - Titus + * @param {X & V} noctis - "Prince Noctis Lucius Caelum" + * @return {"cecil" | "zidane"} + */ + \ No newline at end of file diff --git a/tests/baselines/reference/callbackTag2.symbols b/tests/baselines/reference/callbackTag2.symbols new file mode 100644 index 00000000000..36b810de465 --- /dev/null +++ b/tests/baselines/reference/callbackTag2.symbols @@ -0,0 +1,52 @@ +=== tests/cases/conformance/jsdoc/cb.js === +/** @template T + * @callback Id + * @param {T} t + * @returns {T} Maybe just return 120 and cast it? + */ +var x = 1 +>x : Symbol(x, Decl(cb.js, 5, 3)) + +/** @type {Id} I actually wanted to write `const "120"` */ +var one_twenty = s => "120"; +>one_twenty : Symbol(one_twenty, Decl(cb.js, 8, 3)) +>s : Symbol(s, Decl(cb.js, 8, 16)) + +/** @template S + * @callback SharedId + * @param {S} ego + * @return {S} + */ +class SharedClass { +>SharedClass : Symbol(SharedClass, Decl(cb.js, 8, 28)) + + constructor() { + /** @type {SharedId} */ + this.id; +>this.id : Symbol(SharedClass.id, Decl(cb.js, 16, 19)) +>this : Symbol(SharedClass, Decl(cb.js, 8, 28)) +>id : Symbol(SharedClass.id, Decl(cb.js, 16, 19)) + } +} +/** @type {SharedId} */ +var outside = n => n + 1; +>outside : Symbol(outside, Decl(cb.js, 22, 3)) +>n : Symbol(n, Decl(cb.js, 22, 13)) +>n : Symbol(n, Decl(cb.js, 22, 13)) + +/** @type {Final<{ fantasy }, { heroes }>} */ +var noreturn = (barts, tidus, noctis) => "cecil" +>noreturn : Symbol(noreturn, Decl(cb.js, 25, 3)) +>barts : Symbol(barts, Decl(cb.js, 25, 16)) +>tidus : Symbol(tidus, Decl(cb.js, 25, 22)) +>noctis : Symbol(noctis, Decl(cb.js, 25, 29)) + +/** + * @template V,X + * @callback Final + * @param {V} barts - "Barts" + * @param {X} tidus - Titus + * @param {X & V} noctis - "Prince Noctis Lucius Caelum" + * @return {"cecil" | "zidane"} + */ + diff --git a/tests/baselines/reference/callbackTag2.types b/tests/baselines/reference/callbackTag2.types new file mode 100644 index 00000000000..5a13438ebbe --- /dev/null +++ b/tests/baselines/reference/callbackTag2.types @@ -0,0 +1,60 @@ +=== tests/cases/conformance/jsdoc/cb.js === +/** @template T + * @callback Id + * @param {T} t + * @returns {T} Maybe just return 120 and cast it? + */ +var x = 1 +>x : number +>1 : 1 + +/** @type {Id} I actually wanted to write `const "120"` */ +var one_twenty = s => "120"; +>one_twenty : Id +>s => "120" : (s: string) => string +>s : string +>"120" : "120" + +/** @template S + * @callback SharedId + * @param {S} ego + * @return {S} + */ +class SharedClass { +>SharedClass : SharedClass + + constructor() { + /** @type {SharedId} */ + this.id; +>this.id : SharedId +>this : this +>id : SharedId + } +} +/** @type {SharedId} */ +var outside = n => n + 1; +>outside : SharedId +>n => n + 1 : (n: number) => number +>n : number +>n + 1 : number +>n : number +>1 : 1 + +/** @type {Final<{ fantasy }, { heroes }>} */ +var noreturn = (barts, tidus, noctis) => "cecil" +>noreturn : (barts: { fantasy: any; }, tidus: { heroes: any; }, noctis: { heroes: any; } & { fantasy: any; }) => "cecil" | "zidane" +>(barts, tidus, noctis) => "cecil" : (barts: { fantasy: any; }, tidus: { heroes: any; }, noctis: { heroes: any; } & { fantasy: any; }) => "cecil" +>barts : { fantasy: any; } +>tidus : { heroes: any; } +>noctis : { heroes: any; } & { fantasy: any; } +>"cecil" : "cecil" + +/** + * @template V,X + * @callback Final + * @param {V} barts - "Barts" + * @param {X} tidus - Titus + * @param {X & V} noctis - "Prince Noctis Lucius Caelum" + * @return {"cecil" | "zidane"} + */ + diff --git a/tests/baselines/reference/callbackTag3.symbols b/tests/baselines/reference/callbackTag3.symbols new file mode 100644 index 00000000000..88b53a4cdaa --- /dev/null +++ b/tests/baselines/reference/callbackTag3.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/jsdoc/cb.js === +/** @callback Miracle + * @returns {string} What were you expecting + */ +/** @type {Miracle} smallId */ +var sid = () => "!"; +>sid : Symbol(sid, Decl(cb.js, 4, 3)) + + diff --git a/tests/baselines/reference/callbackTag3.types b/tests/baselines/reference/callbackTag3.types new file mode 100644 index 00000000000..836897d0f30 --- /dev/null +++ b/tests/baselines/reference/callbackTag3.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsdoc/cb.js === +/** @callback Miracle + * @returns {string} What were you expecting + */ +/** @type {Miracle} smallId */ +var sid = () => "!"; +>sid : Miracle +>() => "!" : () => string +>"!" : "!" + + diff --git a/tests/baselines/reference/callbackTagNamespace.symbols b/tests/baselines/reference/callbackTagNamespace.symbols new file mode 100644 index 00000000000..b8cf7d95886 --- /dev/null +++ b/tests/baselines/reference/callbackTagNamespace.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/jsdoc/namespaced.js === +/** + * @callback NS.Nested.Inner + * @param {string} space - spaaaaaaaaace + * @param {string} peace - peaaaaaaaaace + * @return {string | number} + */ +var x = 1; +>x : Symbol(x, Decl(namespaced.js, 6, 3)) + +/** @type {NS.Nested.Inner} */ +function f(space, peace) { +>f : Symbol(f, Decl(namespaced.js, 6, 10)) +>space : Symbol(space, Decl(namespaced.js, 8, 11)) +>peace : Symbol(peace, Decl(namespaced.js, 8, 17)) + + return '1' +} + diff --git a/tests/baselines/reference/callbackTagNamespace.types b/tests/baselines/reference/callbackTagNamespace.types new file mode 100644 index 00000000000..0435320795d --- /dev/null +++ b/tests/baselines/reference/callbackTagNamespace.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/jsdoc/namespaced.js === +/** + * @callback NS.Nested.Inner + * @param {string} space - spaaaaaaaaace + * @param {string} peace - peaaaaaaaaace + * @return {string | number} + */ +var x = 1; +>x : number +>1 : 1 + +/** @type {NS.Nested.Inner} */ +function f(space, peace) { +>f : (space: string, peace: string) => string +>space : string +>peace : string + + return '1' +>'1' : "1" +} + diff --git a/tests/baselines/reference/capturedLetConstInLoop12.js b/tests/baselines/reference/capturedLetConstInLoop12.js index 1bb691bb72a..3625556c89a 100644 --- a/tests/baselines/reference/capturedLetConstInLoop12.js +++ b/tests/baselines/reference/capturedLetConstInLoop12.js @@ -20,8 +20,8 @@ "use strict"; var _loop_1 = function (i) { (function () { - return _a = [i + 1], i = _a[0], _a; var _a; + return _a = [i + 1], i = _a[0], _a; })(); out_i_1 = i; }; @@ -35,8 +35,8 @@ "use strict"; var _loop_2 = function (i) { (function () { - return (_a = { a: i + 1 }, i = _a.a, _a); var _a; + return (_a = { a: i + 1 }, i = _a.a, _a); })(); out_i_2 = i; }; diff --git a/tests/baselines/reference/capturedLetConstInLoop13.js b/tests/baselines/reference/capturedLetConstInLoop13.js index 03c1ebef8a8..628faa10485 100644 --- a/tests/baselines/reference/capturedLetConstInLoop13.js +++ b/tests/baselines/reference/capturedLetConstInLoop13.js @@ -34,10 +34,10 @@ var Main = /** @class */ (function () { names[_i] = arguments[_i]; } var _loop_1 = function (name_1) { + var _a; this_1.bar((_a = {}, _a[name_1 + ".a"] = function () { _this.foo(name_1); }, _a)); - var _a; }; var this_1 = this; for (var _a = 0, names_1 = names; _a < names_1.length; _a++) { diff --git a/tests/baselines/reference/capturedLetConstInLoop4.js b/tests/baselines/reference/capturedLetConstInLoop4.js index bc259a73a88..874a1d4130e 100644 --- a/tests/baselines/reference/capturedLetConstInLoop4.js +++ b/tests/baselines/reference/capturedLetConstInLoop4.js @@ -144,6 +144,7 @@ for (const y = 0; y < 1;) { //// [capturedLetConstInLoop4.js] System.register([], function (exports_1, context_1) { + var v0, v00, v1, v2, v3, v4, v5, v6, v7, v8, v0_c, v00_c, v1_c, v2_c, v3_c, v4_c, v5_c, v6_c, v7_c, v8_c; "use strict"; var __moduleName = context_1 && context_1.id; //======let @@ -156,7 +157,6 @@ System.register([], function (exports_1, context_1) { return v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c; } exports_1("exportedFoo2", exportedFoo2); - var v0, v00, v1, v2, v3, v4, v5, v6, v7, v8, v0_c, v00_c, v1_c, v2_c, v3_c, v4_c, v5_c, v6_c, v7_c, v8_c; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/capturedLetConstInLoop9.js b/tests/baselines/reference/capturedLetConstInLoop9.js index 3b162215918..0795d509f9b 100644 --- a/tests/baselines/reference/capturedLetConstInLoop9.js +++ b/tests/baselines/reference/capturedLetConstInLoop9.js @@ -178,15 +178,16 @@ for (var x = 0; x < 1; ++x) { } function foo() { var _loop_3 = function (a) { + var _a; if (a === 1) { return "break"; } if (a === 2) { return "break-l0"; } - for (var _i = 0, _a = []; _i < _a.length; _i++) { - var b = _a[_i]; - _d = [{ x: 1, y: 2 }][0], x = _d.x, z = _d.y; + for (var _i = 0, _b = []; _i < _b.length; _i++) { + var b = _b[_i]; + _a = [{ x: 1, y: 2 }][0], x = _a.x, z = _a.y; if (b === 1) { break; } @@ -199,6 +200,7 @@ function foo() { return { value: 50 }; } var _loop_4 = function (b) { + var _a; _a = [{ x1: 1, y: arguments_1.length }][0], x1 = _a.x1, z1 = _a.y; if (b === 1) { return "break"; @@ -208,10 +210,9 @@ function foo() { } (function () { return b; }); return { value: 100 }; - var _a; }; - for (var _b = 0, _c = []; _b < _c.length; _b++) { - var b = _c[_b]; + for (var _c = 0, _d = []; _c < _d.length; _c++) { + var b = _d[_c]; var state_2 = _loop_4(b); if (typeof state_2 === "object") return state_2; @@ -222,7 +223,6 @@ function foo() { } } (function () { return a; }); - var _d; }; var arguments_1 = arguments, x, z, x1, z1; l0: for (var _i = 0, _a = []; _i < _a.length; _i++) { diff --git a/tests/baselines/reference/capturedParametersInInitializers2.js b/tests/baselines/reference/capturedParametersInInitializers2.js index 481bed687bb..5b5f06fc5b0 100644 --- a/tests/baselines/reference/capturedParametersInInitializers2.js +++ b/tests/baselines/reference/capturedParametersInInitializers2.js @@ -15,8 +15,8 @@ function foo(y, x) { _a.c = x, _a); } if (x === void 0) { x = 1; } - y.c; var _a; + y.c; } function foo2(y, x) { if (y === void 0) { y = (_b = /** @class */ (function () { diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.js b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.js index 26f19815855..90f83b4ff99 100644 --- a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.js +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.js @@ -25,6 +25,7 @@ obj.bar1 = "42"; obj.arrowFunc(0); //// [0.js] +var _a; // @ts-check var lol = "hello Lol"; var obj = (_a = { @@ -50,4 +51,3 @@ obj.bar = undefined; var k = obj.method1(0); obj.bar1 = "42"; obj.arrowFunc(0); -var _a; diff --git a/tests/baselines/reference/checkJsdocTypedefInParamTag1.types b/tests/baselines/reference/checkJsdocTypedefInParamTag1.types index b0847a71522..ffc7fe505e6 100644 --- a/tests/baselines/reference/checkJsdocTypedefInParamTag1.types +++ b/tests/baselines/reference/checkJsdocTypedefInParamTag1.types @@ -10,18 +10,18 @@ * @param {Opts} opts */ function foo(opts) { ->foo : (opts: { x: string; y?: string; z?: string; w?: string; }) => void ->opts : { x: string; y?: string; z?: string; w?: string; } +>foo : (opts: Opts) => void +>opts : Opts opts.x; >opts.x : string ->opts : { x: string; y?: string; z?: string; w?: string; } +>opts : Opts >x : string } foo({x: 'abc'}); >foo({x: 'abc'}) : void ->foo : (opts: { x: string; y?: string; z?: string; w?: string; }) => void +>foo : (opts: Opts) => void >{x: 'abc'} : { x: string; } >x : string >'abc' : "abc" @@ -34,18 +34,18 @@ foo({x: 'abc'}); * @param {AnotherOpts} opts */ function foo1(opts) { ->foo1 : (opts: { anotherX: string; anotherY?: string; }) => void ->opts : { anotherX: string; anotherY?: string; } +>foo1 : (opts: AnotherOpts) => void +>opts : AnotherOpts opts.anotherX; >opts.anotherX : string ->opts : { anotherX: string; anotherY?: string; } +>opts : AnotherOpts >anotherX : string } foo1({anotherX: "world"}); >foo1({anotherX: "world"}) : void ->foo1 : (opts: { anotherX: string; anotherY?: string; }) => void +>foo1 : (opts: AnotherOpts) => void >{anotherX: "world"} : { anotherX: string; } >anotherX : string >"world" : "world" @@ -60,17 +60,17 @@ foo1({anotherX: "world"}); * @param {Opts1} opts */ function foo2(opts) { ->foo2 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void ->opts : { x: string; y?: string; z?: string; w?: string; } +>foo2 : (opts: Opts1) => void +>opts : Opts1 opts.x; >opts.x : string ->opts : { x: string; y?: string; z?: string; w?: string; } +>opts : Opts1 >x : string } foo2({x: 'abc'}); >foo2({x: 'abc'}) : void ->foo2 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void +>foo2 : (opts: Opts1) => void >{x: 'abc'} : { x: string; } >x : string >'abc' : "abc" diff --git a/tests/baselines/reference/circularConstrainedMappedTypeNoCrash.js b/tests/baselines/reference/circularConstrainedMappedTypeNoCrash.js new file mode 100644 index 00000000000..4448a5b8589 --- /dev/null +++ b/tests/baselines/reference/circularConstrainedMappedTypeNoCrash.js @@ -0,0 +1,6 @@ +//// [circularConstrainedMappedTypeNoCrash.ts] +type Loop> = { + [P in keyof T]: U[P] extends boolean ? number : string; +}; + +//// [circularConstrainedMappedTypeNoCrash.js] diff --git a/tests/baselines/reference/circularConstrainedMappedTypeNoCrash.symbols b/tests/baselines/reference/circularConstrainedMappedTypeNoCrash.symbols new file mode 100644 index 00000000000..a83439bafb9 --- /dev/null +++ b/tests/baselines/reference/circularConstrainedMappedTypeNoCrash.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/circularConstrainedMappedTypeNoCrash.ts === +type Loop> = { +>Loop : Symbol(Loop, Decl(circularConstrainedMappedTypeNoCrash.ts, 0, 0)) +>T : Symbol(T, Decl(circularConstrainedMappedTypeNoCrash.ts, 0, 10)) +>U : Symbol(U, Decl(circularConstrainedMappedTypeNoCrash.ts, 0, 12)) +>Loop : Symbol(Loop, Decl(circularConstrainedMappedTypeNoCrash.ts, 0, 0)) +>T : Symbol(T, Decl(circularConstrainedMappedTypeNoCrash.ts, 0, 10)) +>U : Symbol(U, Decl(circularConstrainedMappedTypeNoCrash.ts, 0, 12)) + + [P in keyof T]: U[P] extends boolean ? number : string; +>P : Symbol(P, Decl(circularConstrainedMappedTypeNoCrash.ts, 1, 5)) +>T : Symbol(T, Decl(circularConstrainedMappedTypeNoCrash.ts, 0, 10)) +>U : Symbol(U, Decl(circularConstrainedMappedTypeNoCrash.ts, 0, 12)) +>P : Symbol(P, Decl(circularConstrainedMappedTypeNoCrash.ts, 1, 5)) + +}; diff --git a/tests/baselines/reference/circularConstrainedMappedTypeNoCrash.types b/tests/baselines/reference/circularConstrainedMappedTypeNoCrash.types new file mode 100644 index 00000000000..315fa8351c1 --- /dev/null +++ b/tests/baselines/reference/circularConstrainedMappedTypeNoCrash.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/circularConstrainedMappedTypeNoCrash.ts === +type Loop> = { +>Loop : Loop +>T : T +>U : U +>Loop : Loop +>T : T +>U : U + + [P in keyof T]: U[P] extends boolean ? number : string; +>P : P +>T : T +>U : U +>P : P + +}; diff --git a/tests/baselines/reference/classBlockScoping.js b/tests/baselines/reference/classBlockScoping.js index f5a642ed8fc..ee3d9163b5e 100644 --- a/tests/baselines/reference/classBlockScoping.js +++ b/tests/baselines/reference/classBlockScoping.js @@ -35,6 +35,7 @@ function f(b: boolean) { //// [classBlockScoping.js] function f(b) { + var _a; var Foo; if (b) { Foo = (_a = /** @class */ (function () { @@ -67,5 +68,4 @@ function f(b) { }()); new Foo_1(); } - var _a; } diff --git a/tests/baselines/reference/classDeclarationShouldBeOutOfScopeInComputedNames.js b/tests/baselines/reference/classDeclarationShouldBeOutOfScopeInComputedNames.js index 2b59b358ffe..5367ef781a5 100644 --- a/tests/baselines/reference/classDeclarationShouldBeOutOfScopeInComputedNames.js +++ b/tests/baselines/reference/classDeclarationShouldBeOutOfScopeInComputedNames.js @@ -18,11 +18,11 @@ var A = /** @class */ (function () { A[(_a = A.p1, A.p2)] = function () { return 0; }; ; A.prototype[A.p1] = function () { }; + var _a, _b; _b = A.p2; A.p1 = Symbol(); A.p2 = Symbol(); // All of the below should be out of scope or TDZ - `A` has not finished being constructed as they are executed A[_a] = 0; return A; - var _a, _b; }()); diff --git a/tests/baselines/reference/classExpressionInClassStaticDeclarations.js b/tests/baselines/reference/classExpressionInClassStaticDeclarations.js new file mode 100644 index 00000000000..9fbaeef12b0 --- /dev/null +++ b/tests/baselines/reference/classExpressionInClassStaticDeclarations.js @@ -0,0 +1,37 @@ +//// [classExpressionInClassStaticDeclarations.ts] +class C { + static D = class extends C {}; +} + +//// [classExpressionInClassStaticDeclarations.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var C = /** @class */ (function () { + function C() { + } + C.D = /** @class */ (function (_super) { + __extends(class_1, _super); + function class_1() { + return _super !== null && _super.apply(this, arguments) || this; + } + return class_1; + }(C)); + return C; +}()); + + +//// [classExpressionInClassStaticDeclarations.d.ts] +declare class C { + static D: { + new (): {}; + D: any; + }; +} diff --git a/tests/baselines/reference/classExpressionInClassStaticDeclarations.symbols b/tests/baselines/reference/classExpressionInClassStaticDeclarations.symbols new file mode 100644 index 00000000000..99ca22158d6 --- /dev/null +++ b/tests/baselines/reference/classExpressionInClassStaticDeclarations.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/classExpressionInClassStaticDeclarations.ts === +class C { +>C : Symbol(C, Decl(classExpressionInClassStaticDeclarations.ts, 0, 0)) + + static D = class extends C {}; +>D : Symbol(C.D, Decl(classExpressionInClassStaticDeclarations.ts, 0, 9)) +>C : Symbol(C, Decl(classExpressionInClassStaticDeclarations.ts, 0, 0)) +} diff --git a/tests/baselines/reference/classExpressionInClassStaticDeclarations.types b/tests/baselines/reference/classExpressionInClassStaticDeclarations.types new file mode 100644 index 00000000000..da701149b1d --- /dev/null +++ b/tests/baselines/reference/classExpressionInClassStaticDeclarations.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/classExpressionInClassStaticDeclarations.ts === +class C { +>C : C + + static D = class extends C {}; +>D : typeof (Anonymous class) +>class extends C {} : typeof (Anonymous class) +>C : C +} diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.js b/tests/baselines/reference/classExpressionWithStaticProperties1.js index 03b67b32886..6d6795bc9f9 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.js +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.js @@ -6,6 +6,7 @@ var v = class C { }; //// [classExpressionWithStaticProperties1.js] +var _a; var v = (_a = /** @class */ (function () { function C() { } @@ -15,4 +16,3 @@ var v = (_a = /** @class */ (function () { _a.b = 2, _a.c = _a.a + _a.b, _a); -var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.js b/tests/baselines/reference/classExpressionWithStaticProperties2.js index f142f10cc33..355a6e16ee0 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.js +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.js @@ -9,6 +9,7 @@ var v = class C { }; //// [classExpressionWithStaticProperties2.js] +var _a; var v = (_a = /** @class */ (function () { function C() { } @@ -20,4 +21,3 @@ var v = (_a = /** @class */ (function () { }, _a.d = _a.c.x + " world", _a); -var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.js b/tests/baselines/reference/classExpressionWithStaticProperties3.js index 4a7ff96751c..d71f02f22cb 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties3.js +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.js @@ -10,6 +10,7 @@ for (let i = 0; i < 3; i++) { arr.forEach(C => console.log(C.y())); //// [classExpressionWithStaticProperties3.js] +var _a; var arr = []; var _loop_1 = function (i) { arr.push((_a = /** @class */ (function () { @@ -25,4 +26,3 @@ for (var i = 0; i < 3; i++) { _loop_1(i); } arr.forEach(function (C) { return console.log(C.y()); }); -var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.js b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.js index d3a210df7e2..e860c5be142 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.js +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.js @@ -6,10 +6,10 @@ var v = class C { }; //// [classExpressionWithStaticPropertiesES61.js] +var _a; var v = (_a = class C { }, _a.a = 1, _a.b = 2, _a.c = _a.a + 3, _a); -var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.js b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.js index d0f56131d54..5b5524b8856 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.js +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.js @@ -9,6 +9,7 @@ var v = class C { }; //// [classExpressionWithStaticPropertiesES62.js] +var _a; var v = (_a = class C { }, _a.a = 1, @@ -17,4 +18,3 @@ var v = (_a = class C { }, _a.d = _a.c.x + " world", _a); -var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.js b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.js index 0ac97e7a755..8ff0f242f19 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.js +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.js @@ -10,6 +10,7 @@ for (let i = 0; i < 3; i++) { arr.forEach(C => console.log(C.y())); //// [classExpressionWithStaticPropertiesES63.js] +var _a; const arr = []; for (let i = 0; i < 3; i++) { arr.push((_a = class C { @@ -19,4 +20,3 @@ for (let i = 0; i < 3; i++) { _a)); } arr.forEach(C => console.log(C.y())); -var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES64.js b/tests/baselines/reference/classExpressionWithStaticPropertiesES64.js index d2a62d62ce9..5567d7e7cee 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES64.js +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES64.js @@ -3,8 +3,8 @@ //// [classExpressionWithStaticPropertiesES64.js] +var _a; (_a = class { }, _a.x = 0, _a); -var _a; diff --git a/tests/baselines/reference/collectionPatternNoError.js b/tests/baselines/reference/collectionPatternNoError.js new file mode 100644 index 00000000000..eff09af0267 --- /dev/null +++ b/tests/baselines/reference/collectionPatternNoError.js @@ -0,0 +1,67 @@ +//// [collectionPatternNoError.ts] +interface MsgConstructor { + new(data: Array<{}>): T; +} +class Message { + clone(): this { + return this; + } +} +interface MessageList extends Message { + methodOnMessageList(): T[]; +} + +function fetchMsg(protoCtor: MsgConstructor): V { + return null!; +} + +class DataProvider> { + constructor( + private readonly message: MsgConstructor, + private readonly messageList: MsgConstructor, + ) { } + + fetch() { + const messageList = fetchMsg(this.messageList); + messageList.methodOnMessageList(); + } +} + +// The same bug as the above but using indexed accesses +// (won't surface directly unless unsound indexed access assignments are forbidden) +function f< + U extends {TType: MessageList}, + T extends Message +>(message: MsgConstructor, messageList: MsgConstructor) { + fetchMsg(messageList).methodOnMessageList(); +} + + +//// [collectionPatternNoError.js] +var Message = /** @class */ (function () { + function Message() { + } + Message.prototype.clone = function () { + return this; + }; + return Message; +}()); +function fetchMsg(protoCtor) { + return null; +} +var DataProvider = /** @class */ (function () { + function DataProvider(message, messageList) { + this.message = message; + this.messageList = messageList; + } + DataProvider.prototype.fetch = function () { + var messageList = fetchMsg(this.messageList); + messageList.methodOnMessageList(); + }; + return DataProvider; +}()); +// The same bug as the above but using indexed accesses +// (won't surface directly unless unsound indexed access assignments are forbidden) +function f(message, messageList) { + fetchMsg(messageList).methodOnMessageList(); +} diff --git a/tests/baselines/reference/collectionPatternNoError.symbols b/tests/baselines/reference/collectionPatternNoError.symbols new file mode 100644 index 00000000000..be9bffdac6d --- /dev/null +++ b/tests/baselines/reference/collectionPatternNoError.symbols @@ -0,0 +1,112 @@ +=== tests/cases/compiler/collectionPatternNoError.ts === +interface MsgConstructor { +>MsgConstructor : Symbol(MsgConstructor, Decl(collectionPatternNoError.ts, 0, 0)) +>T : Symbol(T, Decl(collectionPatternNoError.ts, 0, 25)) +>Message : Symbol(Message, Decl(collectionPatternNoError.ts, 2, 1)) + + new(data: Array<{}>): T; +>data : Symbol(data, Decl(collectionPatternNoError.ts, 1, 6)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(collectionPatternNoError.ts, 0, 25)) +} +class Message { +>Message : Symbol(Message, Decl(collectionPatternNoError.ts, 2, 1)) + + clone(): this { +>clone : Symbol(Message.clone, Decl(collectionPatternNoError.ts, 3, 15)) + + return this; +>this : Symbol(Message, Decl(collectionPatternNoError.ts, 2, 1)) + } +} +interface MessageList extends Message { +>MessageList : Symbol(MessageList, Decl(collectionPatternNoError.ts, 7, 1)) +>T : Symbol(T, Decl(collectionPatternNoError.ts, 8, 22)) +>Message : Symbol(Message, Decl(collectionPatternNoError.ts, 2, 1)) +>Message : Symbol(Message, Decl(collectionPatternNoError.ts, 2, 1)) + + methodOnMessageList(): T[]; +>methodOnMessageList : Symbol(MessageList.methodOnMessageList, Decl(collectionPatternNoError.ts, 8, 58)) +>T : Symbol(T, Decl(collectionPatternNoError.ts, 8, 22)) +} + +function fetchMsg(protoCtor: MsgConstructor): V { +>fetchMsg : Symbol(fetchMsg, Decl(collectionPatternNoError.ts, 10, 1)) +>V : Symbol(V, Decl(collectionPatternNoError.ts, 12, 18)) +>Message : Symbol(Message, Decl(collectionPatternNoError.ts, 2, 1)) +>protoCtor : Symbol(protoCtor, Decl(collectionPatternNoError.ts, 12, 37)) +>MsgConstructor : Symbol(MsgConstructor, Decl(collectionPatternNoError.ts, 0, 0)) +>V : Symbol(V, Decl(collectionPatternNoError.ts, 12, 18)) +>V : Symbol(V, Decl(collectionPatternNoError.ts, 12, 18)) + + return null!; +} + +class DataProvider> { +>DataProvider : Symbol(DataProvider, Decl(collectionPatternNoError.ts, 14, 1)) +>T : Symbol(T, Decl(collectionPatternNoError.ts, 16, 19)) +>Message : Symbol(Message, Decl(collectionPatternNoError.ts, 2, 1)) +>U : Symbol(U, Decl(collectionPatternNoError.ts, 16, 37)) +>MessageList : Symbol(MessageList, Decl(collectionPatternNoError.ts, 7, 1)) +>T : Symbol(T, Decl(collectionPatternNoError.ts, 16, 19)) + + constructor( + private readonly message: MsgConstructor, +>message : Symbol(DataProvider.message, Decl(collectionPatternNoError.ts, 17, 14)) +>MsgConstructor : Symbol(MsgConstructor, Decl(collectionPatternNoError.ts, 0, 0)) +>T : Symbol(T, Decl(collectionPatternNoError.ts, 16, 19)) + + private readonly messageList: MsgConstructor, +>messageList : Symbol(DataProvider.messageList, Decl(collectionPatternNoError.ts, 18, 48)) +>MsgConstructor : Symbol(MsgConstructor, Decl(collectionPatternNoError.ts, 0, 0)) +>U : Symbol(U, Decl(collectionPatternNoError.ts, 16, 37)) + + ) { } + + fetch() { +>fetch : Symbol(DataProvider.fetch, Decl(collectionPatternNoError.ts, 20, 7)) + + const messageList = fetchMsg(this.messageList); +>messageList : Symbol(messageList, Decl(collectionPatternNoError.ts, 23, 9)) +>fetchMsg : Symbol(fetchMsg, Decl(collectionPatternNoError.ts, 10, 1)) +>this.messageList : Symbol(DataProvider.messageList, Decl(collectionPatternNoError.ts, 18, 48)) +>this : Symbol(DataProvider, Decl(collectionPatternNoError.ts, 14, 1)) +>messageList : Symbol(DataProvider.messageList, Decl(collectionPatternNoError.ts, 18, 48)) + + messageList.methodOnMessageList(); +>messageList.methodOnMessageList : Symbol(MessageList.methodOnMessageList, Decl(collectionPatternNoError.ts, 8, 58)) +>messageList : Symbol(messageList, Decl(collectionPatternNoError.ts, 23, 9)) +>methodOnMessageList : Symbol(MessageList.methodOnMessageList, Decl(collectionPatternNoError.ts, 8, 58)) + } +} + +// The same bug as the above but using indexed accesses +// (won't surface directly unless unsound indexed access assignments are forbidden) +function f< +>f : Symbol(f, Decl(collectionPatternNoError.ts, 26, 1)) + + U extends {TType: MessageList}, +>U : Symbol(U, Decl(collectionPatternNoError.ts, 30, 11)) +>TType : Symbol(TType, Decl(collectionPatternNoError.ts, 31, 13)) +>MessageList : Symbol(MessageList, Decl(collectionPatternNoError.ts, 7, 1)) +>T : Symbol(T, Decl(collectionPatternNoError.ts, 31, 36)) + + T extends Message +>T : Symbol(T, Decl(collectionPatternNoError.ts, 31, 36)) +>Message : Symbol(Message, Decl(collectionPatternNoError.ts, 2, 1)) + +>(message: MsgConstructor, messageList: MsgConstructor) { +>message : Symbol(message, Decl(collectionPatternNoError.ts, 33, 2)) +>MsgConstructor : Symbol(MsgConstructor, Decl(collectionPatternNoError.ts, 0, 0)) +>T : Symbol(T, Decl(collectionPatternNoError.ts, 31, 36)) +>messageList : Symbol(messageList, Decl(collectionPatternNoError.ts, 33, 29)) +>MsgConstructor : Symbol(MsgConstructor, Decl(collectionPatternNoError.ts, 0, 0)) +>U : Symbol(U, Decl(collectionPatternNoError.ts, 30, 11)) + + fetchMsg(messageList).methodOnMessageList(); +>fetchMsg(messageList).methodOnMessageList : Symbol(MessageList.methodOnMessageList, Decl(collectionPatternNoError.ts, 8, 58)) +>fetchMsg : Symbol(fetchMsg, Decl(collectionPatternNoError.ts, 10, 1)) +>messageList : Symbol(messageList, Decl(collectionPatternNoError.ts, 33, 29)) +>methodOnMessageList : Symbol(MessageList.methodOnMessageList, Decl(collectionPatternNoError.ts, 8, 58)) +} + diff --git a/tests/baselines/reference/collectionPatternNoError.types b/tests/baselines/reference/collectionPatternNoError.types new file mode 100644 index 00000000000..c11af4e11d9 --- /dev/null +++ b/tests/baselines/reference/collectionPatternNoError.types @@ -0,0 +1,118 @@ +=== tests/cases/compiler/collectionPatternNoError.ts === +interface MsgConstructor { +>MsgConstructor : MsgConstructor +>T : T +>Message : Message + + new(data: Array<{}>): T; +>data : {}[] +>Array : T[] +>T : T +} +class Message { +>Message : Message + + clone(): this { +>clone : () => this + + return this; +>this : this + } +} +interface MessageList extends Message { +>MessageList : MessageList +>T : T +>Message : Message +>Message : Message + + methodOnMessageList(): T[]; +>methodOnMessageList : () => T[] +>T : T +} + +function fetchMsg(protoCtor: MsgConstructor): V { +>fetchMsg : (protoCtor: MsgConstructor) => V +>V : V +>Message : Message +>protoCtor : MsgConstructor +>MsgConstructor : MsgConstructor +>V : V +>V : V + + return null!; +>null! : null +>null : null +} + +class DataProvider> { +>DataProvider : DataProvider +>T : T +>Message : Message +>U : U +>MessageList : MessageList +>T : T + + constructor( + private readonly message: MsgConstructor, +>message : MsgConstructor +>MsgConstructor : MsgConstructor +>T : T + + private readonly messageList: MsgConstructor, +>messageList : MsgConstructor +>MsgConstructor : MsgConstructor +>U : U + + ) { } + + fetch() { +>fetch : () => void + + const messageList = fetchMsg(this.messageList); +>messageList : U +>fetchMsg(this.messageList) : U +>fetchMsg : (protoCtor: MsgConstructor) => V +>this.messageList : MsgConstructor +>this : this +>messageList : MsgConstructor + + messageList.methodOnMessageList(); +>messageList.methodOnMessageList() : T[] +>messageList.methodOnMessageList : () => T[] +>messageList : U +>methodOnMessageList : () => T[] + } +} + +// The same bug as the above but using indexed accesses +// (won't surface directly unless unsound indexed access assignments are forbidden) +function f< +>f : ; }, T extends Message>(message: MsgConstructor, messageList: MsgConstructor) => void + + U extends {TType: MessageList}, +>U : U +>TType : MessageList +>MessageList : MessageList +>T : T + + T extends Message +>T : T +>Message : Message + +>(message: MsgConstructor, messageList: MsgConstructor) { +>message : MsgConstructor +>MsgConstructor : MsgConstructor +>T : T +>messageList : MsgConstructor +>MsgConstructor : MsgConstructor +>U : U + + fetchMsg(messageList).methodOnMessageList(); +>fetchMsg(messageList).methodOnMessageList() : T[] +>fetchMsg(messageList).methodOnMessageList : () => T[] +>fetchMsg(messageList) : U["TType"] +>fetchMsg : (protoCtor: MsgConstructor) => V +>messageList : MsgConstructor +>methodOnMessageList : () => T[] +} + diff --git a/tests/baselines/reference/commaOperatorInConditionalExpression.js b/tests/baselines/reference/commaOperatorInConditionalExpression.js index be1705936e4..16de7776f64 100644 --- a/tests/baselines/reference/commaOperatorInConditionalExpression.js +++ b/tests/baselines/reference/commaOperatorInConditionalExpression.js @@ -8,7 +8,7 @@ function f (m: string) { //// [commaOperatorInConditionalExpression.js] function f(m) { [1, 2, 3].map(function (i) { - return true ? (_a = {}, _a[m] = i, _a) : (_b = {}, _b[m] = i + 1, _b); var _a, _b; + return true ? (_a = {}, _a[m] = i, _a) : (_b = {}, _b[m] = i + 1, _b); }); } diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsReference.js b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsReference.js index d5104f1dbdc..a53af0bfdb7 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsReference.js +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsReference.js @@ -27,6 +27,7 @@ function fn2(x4: number) { (x3['a']) **= value; //// [compoundExponentiationAssignmentLHSIsReference.js] +var _a, _b, _c; var value; // identifiers: variable and parameter var x1; @@ -45,4 +46,3 @@ function fn2(x4) { } (x3.a) = Math.pow((x3.a), value); (x3['a']) = Math.pow((x3['a']), value); -var _a, _b, _c; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js index 5288737805b..b84095ae6c7 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js @@ -96,6 +96,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +var _a; // expected error for all the LHS of compound assignments (arithmetic and addition) var value; // this @@ -144,18 +145,19 @@ _a = Math.pow(['', ''], value), '' = _a[0], '' = _a[1]; var Derived = /** @class */ (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super.call(this) || this; - (_a = _super.prototype). = Math.pow(_a., value); + var _this = this; var _a; + _this = _super.call(this) || this; + (_a = _super.prototype). = Math.pow(_a., value); return _this; } Derived.prototype.foo = function () { - (_a = _super.prototype). = Math.pow(_a., value); var _a; + (_a = _super.prototype). = Math.pow(_a., value); }; Derived.sfoo = function () { - (_a = _super). = Math.pow(_a., value); var _a; + (_a = _super). = Math.pow(_a., value); }; return Derived; }(C)); @@ -181,4 +183,3 @@ foo() = Math.pow(foo(), value); ([]) = Math.pow(([]), value); (function baz1() { }) = Math.pow((function baz1() { }), value); (foo()) = Math.pow((foo()), value); -var _a; diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1.js b/tests/baselines/reference/computedPropertiesInDestructuring1.js index e4f15e6b8bf..4a0d6db3c1d 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1.js +++ b/tests/baselines/reference/computedPropertiesInDestructuring1.js @@ -38,14 +38,15 @@ let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; //// [computedPropertiesInDestructuring1.js] +var _a, _b, _c, _d, _e, _f; // destructuring in variable declarations var foo = "bar"; -var _a = foo, bar = { bar: "bar" }[_a]; +var _g = foo, bar = { bar: "bar" }[_g]; var bar2 = { bar: "bar" }["bar"]; var foo2 = function () { return "bar"; }; -var _b = foo2(), bar3 = { bar: "bar" }[_b]; -var _c = foo, bar4 = [{ bar: "bar" }][0][_c]; -var _d = foo2(), bar5 = [{ bar: "bar" }][0][_d]; +var _h = foo2(), bar3 = { bar: "bar" }[_h]; +var _j = foo, bar4 = [{ bar: "bar" }][0][_j]; +var _k = foo2(), bar5 = [{ bar: "bar" }][0][_k]; function f1(_a) { var x = _a["bar"]; } @@ -62,14 +63,13 @@ function f5(_a) { var _b = foo2(), x = _a[0][_b]; } // report errors on type errors in computed properties used in destructuring -var _e = foo(), bar6 = [{ bar: "bar" }][0][_e]; -var _f = foo.toExponential(), bar7 = [{ bar: "bar" }][0][_f]; +var _l = foo(), bar6 = [{ bar: "bar" }][0][_l]; +var _m = foo.toExponential(), bar7 = [{ bar: "bar" }][0][_m]; // destructuring assignment -(_g = foo, bar = { bar: "bar" }[_g]); +(_a = foo, bar = { bar: "bar" }[_a]); (bar2 = { bar: "bar" }["bar"]); -(_h = foo2(), bar3 = { bar: "bar" }[_h]); -_j = foo, bar4 = [{ bar: "bar" }][0][_j]; -_k = foo2(), bar5 = [{ bar: "bar" }][0][_k]; -_l = foo(), bar4 = [{ bar: "bar" }][0][_l]; -_m = (1 + {}), bar4 = [{ bar: "bar" }][0][_m]; -var _g, _h, _j, _k, _l, _m; +(_b = foo2(), bar3 = { bar: "bar" }[_b]); +_c = foo, bar4 = [{ bar: "bar" }][0][_c]; +_d = foo2(), bar5 = [{ bar: "bar" }][0][_d]; +_e = foo(), bar4 = [{ bar: "bar" }][0][_e]; +_f = (1 + {}), bar4 = [{ bar: "bar" }][0][_f]; diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.js b/tests/baselines/reference/computedPropertyNames10_ES5.js index 302f9355be8..01e11d237f1 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.js +++ b/tests/baselines/reference/computedPropertyNames10_ES5.js @@ -17,6 +17,7 @@ var v = { } //// [computedPropertyNames10_ES5.js] +var _a; var s; var n; var a; @@ -33,4 +34,3 @@ var v = (_a = {}, _a["hello bye"] = function () { }, _a["hello " + a + " bye"] = function () { }, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.js b/tests/baselines/reference/computedPropertyNames11_ES5.js index 568cce441e1..78247461c14 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.js +++ b/tests/baselines/reference/computedPropertyNames11_ES5.js @@ -17,6 +17,7 @@ var v = { } //// [computedPropertyNames11_ES5.js] +var _a; var s; var n; var a; @@ -77,4 +78,3 @@ var v = (_a = {}, configurable: true }), _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.js b/tests/baselines/reference/computedPropertyNames12_ES5.js index e8bcf325c34..0245bfd3b2a 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.js +++ b/tests/baselines/reference/computedPropertyNames12_ES5.js @@ -26,8 +26,8 @@ var C = /** @class */ (function () { this[_b] = 2; this["hello bye"] = 0; } + var _a, _b, _c; _a = n, s + s, _b = s + n, +s, _c = "hello " + a + " bye"; C[_c] = 0; return C; - var _a, _b, _c; }()); diff --git a/tests/baselines/reference/computedPropertyNames12_ES6.js b/tests/baselines/reference/computedPropertyNames12_ES6.js index 6f91ec92cc9..f56dbf287a8 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES6.js +++ b/tests/baselines/reference/computedPropertyNames12_ES6.js @@ -17,6 +17,7 @@ class C { } //// [computedPropertyNames12_ES6.js] +var _a, _b, _c; var s; var n; var a; @@ -29,4 +30,3 @@ class C { } _a = n, s + s, _b = s + n, +s, _c = `hello ${a} bye`; C[_c] = 0; -var _a, _b, _c; diff --git a/tests/baselines/reference/computedPropertyNames18_ES5.js b/tests/baselines/reference/computedPropertyNames18_ES5.js index a62af506531..2f9a0dc689c 100644 --- a/tests/baselines/reference/computedPropertyNames18_ES5.js +++ b/tests/baselines/reference/computedPropertyNames18_ES5.js @@ -7,8 +7,8 @@ function foo() { //// [computedPropertyNames18_ES5.js] function foo() { + var _a; var obj = (_a = {}, _a[this.bar] = 0, _a); - var _a; } diff --git a/tests/baselines/reference/computedPropertyNames19_ES5.js b/tests/baselines/reference/computedPropertyNames19_ES5.js index bda3e01bbed..8d471863586 100644 --- a/tests/baselines/reference/computedPropertyNames19_ES5.js +++ b/tests/baselines/reference/computedPropertyNames19_ES5.js @@ -8,8 +8,8 @@ module M { //// [computedPropertyNames19_ES5.js] var M; (function (M) { + var _a; var obj = (_a = {}, _a[this.bar] = 0, _a); - var _a; })(M || (M = {})); diff --git a/tests/baselines/reference/computedPropertyNames1_ES5.js b/tests/baselines/reference/computedPropertyNames1_ES5.js index 75bbe909927..b93096f6821 100644 --- a/tests/baselines/reference/computedPropertyNames1_ES5.js +++ b/tests/baselines/reference/computedPropertyNames1_ES5.js @@ -5,6 +5,7 @@ var v = { } //// [computedPropertyNames1_ES5.js] +var _a; var v = (_a = {}, Object.defineProperty(_a, 0 + 1, { get: function () { return 0; }, @@ -18,4 +19,3 @@ var v = (_a = {}, configurable: true }), _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.js b/tests/baselines/reference/computedPropertyNames20_ES5.js index 1eec0a7bcdb..88e79b47143 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.js +++ b/tests/baselines/reference/computedPropertyNames20_ES5.js @@ -4,7 +4,7 @@ var obj = { } //// [computedPropertyNames20_ES5.js] +var _a; var obj = (_a = {}, _a[this.bar] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames22_ES5.js b/tests/baselines/reference/computedPropertyNames22_ES5.js index 10d34ef1fe0..68c6a36d217 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES5.js +++ b/tests/baselines/reference/computedPropertyNames22_ES5.js @@ -13,11 +13,11 @@ var C = /** @class */ (function () { function C() { } C.prototype.bar = function () { + var _a; var obj = (_a = {}, _a[this.bar()] = function () { }, _a); return 0; - var _a; }; return C; }()); diff --git a/tests/baselines/reference/computedPropertyNames23_ES5.js b/tests/baselines/reference/computedPropertyNames23_ES5.js index a98afb70108..1444218f32c 100644 --- a/tests/baselines/reference/computedPropertyNames23_ES5.js +++ b/tests/baselines/reference/computedPropertyNames23_ES5.js @@ -10,6 +10,7 @@ class C { //// [computedPropertyNames23_ES5.js] var C = /** @class */ (function () { + var _a; function C() { } C.prototype.bar = function () { @@ -17,5 +18,4 @@ var C = /** @class */ (function () { }; C.prototype[(_a = {}, _a[this.bar()] = 1, _a)[0]] = function () { }; return C; - var _a; }()); diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.js b/tests/baselines/reference/computedPropertyNames25_ES5.js index 5dcb4c7b163..ef64ae3c5bc 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.js +++ b/tests/baselines/reference/computedPropertyNames25_ES5.js @@ -38,11 +38,11 @@ var C = /** @class */ (function (_super) { return _super !== null && _super.apply(this, arguments) || this; } C.prototype.foo = function () { + var _a; var obj = (_a = {}, _a[_super.prototype.bar.call(this)] = function () { }, _a); return 0; - var _a; }; return C; }(Base)); diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 4bcb8188d1a..c9c0225dd1b 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -30,11 +30,11 @@ var Base = /** @class */ (function () { return Base; }()); var C = /** @class */ (function (_super) { + var _a; __extends(C, _super); function C() { return _super !== null && _super.apply(this, arguments) || this; } C.prototype[(_a = {}, _a[_super.bar.call(this)] = 1, _a)[0]] = function () { }; return C; - var _a; }(Base)); diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.js b/tests/baselines/reference/computedPropertyNames28_ES5.js index 76a50521a79..ee506fb1c1b 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.js +++ b/tests/baselines/reference/computedPropertyNames28_ES5.js @@ -29,12 +29,12 @@ var Base = /** @class */ (function () { var C = /** @class */ (function (_super) { __extends(C, _super); function C() { + var _a; var _this = _super.call(this) || this; var obj = (_a = {}, _a[(_this = _super.call(this) || this, "prop")] = function () { }, _a); return _this; - var _a; } return C; }(Base)); diff --git a/tests/baselines/reference/computedPropertyNames29_ES5.js b/tests/baselines/reference/computedPropertyNames29_ES5.js index 403f5aa2cec..18d90602d65 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES5.js +++ b/tests/baselines/reference/computedPropertyNames29_ES5.js @@ -17,11 +17,11 @@ var C = /** @class */ (function () { C.prototype.bar = function () { var _this = this; (function () { + var _a; var obj = (_a = {}, _a[_this.bar()] = function () { } // needs capture , _a); - var _a; }); return 0; }; diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.js b/tests/baselines/reference/computedPropertyNames30_ES5.js index 1c3b4caeb45..2cbad2aa19d 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.js +++ b/tests/baselines/reference/computedPropertyNames30_ES5.js @@ -36,13 +36,13 @@ var C = /** @class */ (function (_super) { function C() { var _this = _super.call(this) || this; (function () { + var _a; var obj = (_a = {}, // Ideally, we would capture this. But the reference is // illegal, and not capturing this is consistent with //treatment of other similar violations. _a[(_this = _super.call(this) || this, "prop")] = function () { }, _a); - var _a; }); return _this; } diff --git a/tests/baselines/reference/computedPropertyNames31_ES5.js b/tests/baselines/reference/computedPropertyNames31_ES5.js index b205c7025ca..8eacc21f680 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.js +++ b/tests/baselines/reference/computedPropertyNames31_ES5.js @@ -42,11 +42,11 @@ var C = /** @class */ (function (_super) { C.prototype.foo = function () { var _this = this; (function () { + var _a; var obj = (_a = {}, _a[_super.prototype.bar.call(_this)] = function () { } // needs capture , _a); - var _a; }); return 0; }; diff --git a/tests/baselines/reference/computedPropertyNames33_ES5.js b/tests/baselines/reference/computedPropertyNames33_ES5.js index 76f9e4c06d8..10a121031d5 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES5.js +++ b/tests/baselines/reference/computedPropertyNames33_ES5.js @@ -15,11 +15,11 @@ var C = /** @class */ (function () { function C() { } C.prototype.bar = function () { + var _a; var obj = (_a = {}, _a[foo()] = function () { }, _a); return 0; - var _a; }; return C; }()); diff --git a/tests/baselines/reference/computedPropertyNames34_ES5.js b/tests/baselines/reference/computedPropertyNames34_ES5.js index 315e41e403e..ab0c4c10e32 100644 --- a/tests/baselines/reference/computedPropertyNames34_ES5.js +++ b/tests/baselines/reference/computedPropertyNames34_ES5.js @@ -15,11 +15,11 @@ var C = /** @class */ (function () { function C() { } C.bar = function () { + var _a; var obj = (_a = {}, _a[foo()] = function () { }, _a); return 0; - var _a; }; return C; }()); diff --git a/tests/baselines/reference/computedPropertyNames46_ES5.js b/tests/baselines/reference/computedPropertyNames46_ES5.js index 815f5769f3b..5f826b8db4f 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES5.js +++ b/tests/baselines/reference/computedPropertyNames46_ES5.js @@ -4,7 +4,7 @@ var o = { }; //// [computedPropertyNames46_ES5.js] +var _a; var o = (_a = {}, _a["" || 0] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.js b/tests/baselines/reference/computedPropertyNames47_ES5.js index a2fff2110b4..f423d230fe9 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.js +++ b/tests/baselines/reference/computedPropertyNames47_ES5.js @@ -6,6 +6,7 @@ var o = { }; //// [computedPropertyNames47_ES5.js] +var _a; var E1; (function (E1) { E1[E1["x"] = 0] = "x"; @@ -17,4 +18,3 @@ var E2; var o = (_a = {}, _a[E1.x || E2.x] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.js b/tests/baselines/reference/computedPropertyNames48_ES5.js index 55b08ef8301..b4e2d95634b 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.js +++ b/tests/baselines/reference/computedPropertyNames48_ES5.js @@ -18,6 +18,7 @@ extractIndexer({ }); // Should return any (widened form of undefined) //// [computedPropertyNames48_ES5.js] +var _a, _b, _c; var E; (function (E) { E[E["x"] = 0] = "x"; @@ -32,4 +33,3 @@ extractIndexer((_b = {}, extractIndexer((_c = {}, _c["" || 0] = "", _c)); // Should return any (widened form of undefined) -var _a, _b, _c; diff --git a/tests/baselines/reference/computedPropertyNames49_ES5.js b/tests/baselines/reference/computedPropertyNames49_ES5.js index d5e250fb037..a1ec1540b6f 100644 --- a/tests/baselines/reference/computedPropertyNames49_ES5.js +++ b/tests/baselines/reference/computedPropertyNames49_ES5.js @@ -25,6 +25,7 @@ var x = { } //// [computedPropertyNames49_ES5.js] +var _a; var x = (_a = { p1: 10 }, @@ -61,4 +62,3 @@ var x = (_a = { }), _a.p2 = 20, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.js b/tests/baselines/reference/computedPropertyNames4_ES5.js index ac0fa8ec937..1c966e63bb5 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.js +++ b/tests/baselines/reference/computedPropertyNames4_ES5.js @@ -17,6 +17,7 @@ var v = { } //// [computedPropertyNames4_ES5.js] +var _a; var s; var n; var a; @@ -33,4 +34,3 @@ var v = (_a = {}, _a["hello bye"] = 0, _a["hello " + a + " bye"] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames50_ES5.js b/tests/baselines/reference/computedPropertyNames50_ES5.js index 5f1766c993e..86653855b55 100644 --- a/tests/baselines/reference/computedPropertyNames50_ES5.js +++ b/tests/baselines/reference/computedPropertyNames50_ES5.js @@ -25,6 +25,7 @@ var x = { } //// [computedPropertyNames50_ES5.js] +var _a; var x = (_a = { p1: 10, get foo() { @@ -57,4 +58,3 @@ var x = (_a = { }), _a.p2 = 20, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames51_ES5.js b/tests/baselines/reference/computedPropertyNames51_ES5.js index 9f138b37f3d..9766d6d1789 100644 --- a/tests/baselines/reference/computedPropertyNames51_ES5.js +++ b/tests/baselines/reference/computedPropertyNames51_ES5.js @@ -11,11 +11,11 @@ function f() { //// [computedPropertyNames51_ES5.js] function f() { + var _a; var t; var k; var v = (_a = {}, _a[t] = 0, _a[k] = 1, _a); - var _a; } diff --git a/tests/baselines/reference/computedPropertyNames5_ES5.js b/tests/baselines/reference/computedPropertyNames5_ES5.js index 3367faa2c20..1189830858f 100644 --- a/tests/baselines/reference/computedPropertyNames5_ES5.js +++ b/tests/baselines/reference/computedPropertyNames5_ES5.js @@ -10,6 +10,7 @@ var v = { } //// [computedPropertyNames5_ES5.js] +var _a; var b; var v = (_a = {}, _a[b] = 0, @@ -19,4 +20,3 @@ var v = (_a = {}, _a[undefined] = undefined, _a[null] = null, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames6_ES5.js b/tests/baselines/reference/computedPropertyNames6_ES5.js index 29d035bfcbf..0b3e1eeb742 100644 --- a/tests/baselines/reference/computedPropertyNames6_ES5.js +++ b/tests/baselines/reference/computedPropertyNames6_ES5.js @@ -9,6 +9,7 @@ var v = { } //// [computedPropertyNames6_ES5.js] +var _a; var p1; var p2; var p3; @@ -17,4 +18,3 @@ var v = (_a = {}, _a[p2] = 1, _a[p3] = 2, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.js b/tests/baselines/reference/computedPropertyNames7_ES5.js index 01cf2efc030..6adc38b410c 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.js +++ b/tests/baselines/reference/computedPropertyNames7_ES5.js @@ -7,6 +7,7 @@ var v = { } //// [computedPropertyNames7_ES5.js] +var _a; var E; (function (E) { E[E["member"] = 0] = "member"; @@ -14,4 +15,3 @@ var E; var v = (_a = {}, _a[E.member] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNames8_ES5.js b/tests/baselines/reference/computedPropertyNames8_ES5.js index 82d262c7e4e..cffe76ff996 100644 --- a/tests/baselines/reference/computedPropertyNames8_ES5.js +++ b/tests/baselines/reference/computedPropertyNames8_ES5.js @@ -10,11 +10,11 @@ function f() { //// [computedPropertyNames8_ES5.js] function f() { + var _a; var t; var u; var v = (_a = {}, _a[t] = 0, _a[u] = 1, _a); - var _a; } diff --git a/tests/baselines/reference/computedPropertyNames9_ES5.js b/tests/baselines/reference/computedPropertyNames9_ES5.js index b1ac6c9e3b6..0afb77c12f6 100644 --- a/tests/baselines/reference/computedPropertyNames9_ES5.js +++ b/tests/baselines/reference/computedPropertyNames9_ES5.js @@ -11,10 +11,10 @@ var v = { } //// [computedPropertyNames9_ES5.js] +var _a; function f(x) { } var v = (_a = {}, _a[f("")] = 0, _a[f(0)] = 0, _a[f(true)] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js index d8a33951d4a..b672ed16723 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js @@ -9,8 +9,8 @@ var o: I = { } //// [computedPropertyNamesContextualType10_ES5.js] +var _a; var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js index 1ee88351154..3b48f95c99d 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType1_ES5.js] +var _a; var o = (_a = {}, _a["" + 0] = function (y) { return y.length; }, _a["" + 1] = function (y) { return y.length; }, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js index 6be09e4bef3..c33ae2b10a2 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType2_ES5.js] +var _a; var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] = function (y) { return y.length; }, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js index b510cda2916..b0599c37bb0 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js @@ -9,8 +9,8 @@ var o: I = { } //// [computedPropertyNamesContextualType3_ES5.js] +var _a; var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] = function (y) { return y.length; }, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js index 0c319a526f4..f0c7a2db6d4 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType4_ES5.js] +var _a; var o = (_a = {}, _a["" + "foo"] = "", _a["" + "bar"] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js index 51d78be59d4..7faaeb62b1c 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType5_ES5.js] +var _a; var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js index c6ef45d7fab..a385d78079d 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js @@ -14,6 +14,7 @@ foo({ }); //// [computedPropertyNamesContextualType6_ES5.js] +var _a; foo((_a = { p: "", 0: function () { } @@ -22,4 +23,3 @@ foo((_a = { _a[0 + 1] = 0, _a[+"hi"] = [0], _a)); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js index 14165302d3b..7ec0fea3d8e 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js @@ -20,6 +20,7 @@ g({ p: "" }); //// [computedPropertyNamesContextualType7_ES5.js] +var _a; foo((_a = { 0: function () { } }, @@ -28,4 +29,3 @@ foo((_a = { _a[+"hi"] = [0], _a)); g({ p: "" }); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js index 24f6218864c..200acdefb1e 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType8_ES5.js] +var _a; var o = (_a = {}, _a["" + "foo"] = "", _a["" + "bar"] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js index 340802da2af..79eef211938 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js @@ -10,8 +10,8 @@ var o: I = { } //// [computedPropertyNamesContextualType9_ES5.js] +var _a; var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = 0, _a); -var _a; diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js index bf589768b72..0a7f9a7866a 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js @@ -7,6 +7,7 @@ var v = { } //// [computedPropertyNamesDeclarationEmit5_ES5.js] +var _a; var v = (_a = {}, _a["" + ""] = 0, _a["" + ""] = function () { }, @@ -21,7 +22,6 @@ var v = (_a = {}, configurable: true }), _a); -var _a; //// [computedPropertyNamesDeclarationEmit5_ES5.d.ts] diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js index d214a1ef99d..65dc5601878 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js @@ -9,6 +9,7 @@ var v = { } //// [computedPropertyNamesSourceMap2_ES5.js] +var _a; var v = (_a = {}, _a["hello"] = function () { debugger; @@ -21,5 +22,4 @@ var v = (_a = {}, configurable: true }), _a); -var _a; //# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map index 24dd2e2afb7..8be065a8182 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap2_ES5.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC;IACD,GAAC,OAAO,IAAR;QACI,QAAQ,CAAC;IAChB,CAAC;0BACM,aAAW;aAAf;YACF,OAAO,CAAC,CAAC;QACV,CAAC;;;;OACD,CAAA"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":";AAAA,IAAI,CAAC;IACD,GAAC,OAAO,IAAR;QACI,QAAQ,CAAC;IAChB,CAAC;0BACM,aAAW;aAAf;YACF,OAAO,CAAC,CAAC;QACV,CAAC;;;;OACD,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt index 9b44702cb22..f22de8aaeab 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt @@ -8,6 +8,7 @@ sources: computedPropertyNamesSourceMap2_ES5.ts emittedFile:tests/cases/conformance/es6/computedProperties/computedPropertyNamesSourceMap2_ES5.js sourceFile:computedPropertyNamesSourceMap2_ES5.ts ------------------------------------------------------------------- +>>>var _a; >>>var v = (_a = {}, 1 > 2 >^^^^ @@ -16,9 +17,9 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 1 > 2 >var 3 > v -1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) -3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0) +1 >Emitted(2, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(1, 5) + SourceIndex(0) +3 >Emitted(2, 6) Source(1, 6) + SourceIndex(0) --- >>> _a["hello"] = function () { 1->^^^^ @@ -30,10 +31,10 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 2 > [ 3 > "hello" 4 > -1->Emitted(2, 5) Source(2, 5) + SourceIndex(0) -2 >Emitted(2, 8) Source(2, 6) + SourceIndex(0) -3 >Emitted(2, 15) Source(2, 13) + SourceIndex(0) -4 >Emitted(2, 19) Source(2, 5) + SourceIndex(0) +1->Emitted(3, 5) Source(2, 5) + SourceIndex(0) +2 >Emitted(3, 8) Source(2, 6) + SourceIndex(0) +3 >Emitted(3, 15) Source(2, 13) + SourceIndex(0) +4 >Emitted(3, 19) Source(2, 5) + SourceIndex(0) --- >>> debugger; 1 >^^^^^^^^ @@ -43,9 +44,9 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts > 2 > debugger 3 > ; -1 >Emitted(3, 9) Source(3, 9) + SourceIndex(0) -2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) -3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) +1 >Emitted(4, 9) Source(3, 9) + SourceIndex(0) +2 >Emitted(4, 17) Source(3, 17) + SourceIndex(0) +3 >Emitted(4, 18) Source(3, 18) + SourceIndex(0) --- >>> }, 1 >^^^^ @@ -54,8 +55,8 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 1 > > 2 > } -1 >Emitted(4, 5) Source(4, 2) + SourceIndex(0) -2 >Emitted(4, 6) Source(4, 3) + SourceIndex(0) +1 >Emitted(5, 5) Source(4, 2) + SourceIndex(0) +2 >Emitted(5, 6) Source(4, 3) + SourceIndex(0) --- >>> Object.defineProperty(_a, "goodbye", { 1->^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,14 +64,14 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 1->, > get 2 > ["goodbye"] -1->Emitted(5, 27) Source(5, 9) + SourceIndex(0) -2 >Emitted(5, 40) Source(5, 20) + SourceIndex(0) +1->Emitted(6, 27) Source(5, 9) + SourceIndex(0) +2 >Emitted(6, 40) Source(5, 20) + SourceIndex(0) --- >>> get: function () { 1 >^^^^^^^^^^^^^ 2 > ^^^^^^^^^-> 1 > -1 >Emitted(6, 14) Source(5, 5) + SourceIndex(0) +1 >Emitted(7, 14) Source(5, 5) + SourceIndex(0) --- >>> return 0; 1->^^^^^^^^^^^^ @@ -82,10 +83,10 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 2 > return 3 > 0 4 > ; -1->Emitted(7, 13) Source(6, 3) + SourceIndex(0) -2 >Emitted(7, 20) Source(6, 10) + SourceIndex(0) -3 >Emitted(7, 21) Source(6, 11) + SourceIndex(0) -4 >Emitted(7, 22) Source(6, 12) + SourceIndex(0) +1->Emitted(8, 13) Source(6, 3) + SourceIndex(0) +2 >Emitted(8, 20) Source(6, 10) + SourceIndex(0) +3 >Emitted(8, 21) Source(6, 11) + SourceIndex(0) +4 >Emitted(8, 22) Source(6, 12) + SourceIndex(0) --- >>> }, 1 >^^^^^^^^ @@ -94,8 +95,8 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts 1 > > 2 > } -1 >Emitted(8, 9) Source(7, 2) + SourceIndex(0) -2 >Emitted(8, 10) Source(7, 3) + SourceIndex(0) +1 >Emitted(9, 9) Source(7, 2) + SourceIndex(0) +2 >Emitted(9, 10) Source(7, 3) + SourceIndex(0) --- >>> enumerable: true, >>> configurable: true @@ -103,11 +104,11 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts >>> _a); 1->^^^^^^^ 2 > ^ +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> >} 2 > -1->Emitted(12, 8) Source(8, 2) + SourceIndex(0) -2 >Emitted(12, 9) Source(8, 2) + SourceIndex(0) +1->Emitted(13, 8) Source(8, 2) + SourceIndex(0) +2 >Emitted(13, 9) Source(8, 2) + SourceIndex(0) --- ->>>var _a; >>>//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypes1.types b/tests/baselines/reference/conditionalTypes1.types index 90d2703d034..699808c1f78 100644 --- a/tests/baselines/reference/conditionalTypes1.types +++ b/tests/baselines/reference/conditionalTypes1.types @@ -927,9 +927,9 @@ type T52 = IsNever; // false >IsNever : IsNever function f22(x: T extends (infer U)[] ? U[] : never) { ->f22 : (x: T extends infer U[] ? U[] : never) => void +>f22 : (x: T extends (infer U)[] ? U[] : never) => void >T : T ->x : T extends infer U[] ? U[] : never +>x : T extends (infer U)[] ? U[] : never >T : T >U : U >U : U @@ -937,14 +937,14 @@ function f22(x: T extends (infer U)[] ? U[] : never) { let e = x[0]; // {} >e : {} >x[0] : {} ->x : T extends infer U[] ? U[] : never +>x : T extends (infer U)[] ? U[] : never >0 : 0 } function f23(x: T extends (infer U)[] ? U[] : never) { ->f23 : (x: T extends infer U[] ? U[] : never) => void +>f23 : (x: T extends (infer U)[] ? U[] : never) => void >T : T ->x : T extends infer U[] ? U[] : never +>x : T extends (infer U)[] ? U[] : never >T : T >U : U >U : U @@ -952,7 +952,7 @@ function f23(x: T extends (infer U)[] ? U[] : never) { let e = x[0]; // string >e : string >x[0] : string ->x : T extends infer U[] ? U[] : never +>x : T extends (infer U)[] ? U[] : never >0 : 0 } diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js index c50c771896b..5f8e4143f3e 100644 --- a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js @@ -60,6 +60,7 @@ function getFoo1() { }()); } function getFoo2() { + var _a; return _a = /** @class */ (function () { function class_2() { } @@ -72,9 +73,9 @@ function getFoo2() { arg.strProp = "hello"; }, _a; - var _a; } function getFoo3() { + var _a; return _a = /** @class */ (function () { function class_3() { } @@ -87,5 +88,4 @@ function getFoo3() { arg.strProp = "hello"; }, _a; - var _a; } diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.types b/tests/baselines/reference/controlFlowBinaryOrExpression.types index e843844ebf1..2cdf6b6bc19 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.types +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.types @@ -62,21 +62,21 @@ declare function isHTMLCollection(sourceObj: any): sourceObj is HTMLCollection; >HTMLCollection : HTMLCollection type EventTargetLike = {a: string} | HTMLCollection | NodeList; ->EventTargetLike : NodeList | HTMLCollection | { a: string; } +>EventTargetLike : EventTargetLike >a : string >HTMLCollection : HTMLCollection >NodeList : NodeList var sourceObj: EventTargetLike = undefined; ->sourceObj : NodeList | HTMLCollection | { a: string; } ->EventTargetLike : NodeList | HTMLCollection | { a: string; } +>sourceObj : EventTargetLike +>EventTargetLike : EventTargetLike >undefined : any >undefined : undefined if (isNodeList(sourceObj)) { >isNodeList(sourceObj) : boolean >isNodeList : (sourceObj: any) => sourceObj is NodeList ->sourceObj : NodeList | HTMLCollection | { a: string; } +>sourceObj : EventTargetLike sourceObj.length; >sourceObj.length : number @@ -87,7 +87,7 @@ if (isNodeList(sourceObj)) { if (isHTMLCollection(sourceObj)) { >isHTMLCollection(sourceObj) : boolean >isHTMLCollection : (sourceObj: any) => sourceObj is HTMLCollection ->sourceObj : NodeList | HTMLCollection | { a: string; } +>sourceObj : EventTargetLike sourceObj.length; >sourceObj.length : number @@ -99,7 +99,7 @@ if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { >isNodeList(sourceObj) || isHTMLCollection(sourceObj) : boolean >isNodeList(sourceObj) : boolean >isNodeList : (sourceObj: any) => sourceObj is NodeList ->sourceObj : NodeList | HTMLCollection | { a: string; } +>sourceObj : EventTargetLike >isHTMLCollection(sourceObj) : boolean >isHTMLCollection : (sourceObj: any) => sourceObj is HTMLCollection >sourceObj : { a: string; } diff --git a/tests/baselines/reference/correctOrderOfPromiseMethod.js b/tests/baselines/reference/correctOrderOfPromiseMethod.js index d28dbd66098..d0b8adf9eed 100644 --- a/tests/baselines/reference/correctOrderOfPromiseMethod.js +++ b/tests/baselines/reference/correctOrderOfPromiseMethod.js @@ -63,8 +63,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; function countEverything() { return __awaiter(this, void 0, void 0, function () { - var _this = this; var providerA, providerB, _a, resultA, resultB, dataA, dataB; + var _this = this; return __generator(this, function (_b) { switch (_b.label) { case 0: diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.errors.txt b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.errors.txt deleted file mode 100644 index 4ea18c15901..00000000000 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.errors.txt +++ /dev/null @@ -1,132 +0,0 @@ -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(15,21): error TS4043: Return type of public getter 'foo1' from exported class has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(20,13): error TS4043: Return type of public getter 'foo2' from exported class has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(25,25): error TS4037: Parameter type of public setter 'foo3' from exported class has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(32,25): error TS4037: Parameter type of public setter 'foo4' from exported class has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(36,21): error TS4043: Return type of public getter 'foo5' from exported class has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(71,23): error TS4043: Return type of public getter 'foo111' from exported class has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(76,13): error TS4042: Return type of public getter 'foo112' from exported class has or is using name 'm2.public2' from private module 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(81,27): error TS4037: Parameter type of public setter 'foo113' from exported class has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(88,27): error TS4037: Parameter type of public setter 'foo114' from exported class has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts(92,23): error TS4043: Return type of public getter 'foo115' from exported class has or is using private name 'm2'. - - -==== tests/cases/compiler/declFileTypeAnnotationVisibilityErrorAccessors.ts (10 errors) ==== - module m { - class private1 { - } - - export class public1 { - } - - module m2 { - export class public2 { - } - } - - export class c { - // getter with annotation - get foo1(): private1 { - ~~~~~~~~ -!!! error TS4043: Return type of public getter 'foo1' from exported class has or is using private name 'private1'. - return; - } - - // getter without annotation - get foo2() { - ~~~~ -!!! error TS4043: Return type of public getter 'foo2' from exported class has or is using private name 'private1'. - return new private1(); - } - - // setter with annotation - set foo3(param: private1) { - ~~~~~~~~ -!!! error TS4037: Parameter type of public setter 'foo3' from exported class has or is using private name 'private1'. - } - - // Both - getter without annotation, setter with annotation - get foo4() { - return new private1(); - } - set foo4(param: private1) { - ~~~~~~~~ -!!! error TS4037: Parameter type of public setter 'foo4' from exported class has or is using private name 'private1'. - } - - // Both - with annotation - get foo5(): private1 { - ~~~~~~~~ -!!! error TS4043: Return type of public getter 'foo5' from exported class has or is using private name 'private1'. - return; - } - set foo5(param: private1) { - } - - // getter with annotation - get foo11(): public1 { - return; - } - - // getter without annotation - get foo12() { - return new public1(); - } - - // setter with annotation - set foo13(param: public1) { - } - - // Both - getter without annotation, setter with annotation - get foo14() { - return new public1(); - } - set foo14(param: public1) { - } - - // Both - with annotation - get foo15(): public1 { - return; - } - set foo15(param: public1) { - } - - // getter with annotation - get foo111(): m2.public2 { - ~~ -!!! error TS4043: Return type of public getter 'foo111' from exported class has or is using private name 'm2'. - return; - } - - // getter without annotation - get foo112() { - ~~~~~~ -!!! error TS4042: Return type of public getter 'foo112' from exported class has or is using name 'm2.public2' from private module 'm2'. - return new m2.public2(); - } - - // setter with annotation - set foo113(param: m2.public2) { - ~~ -!!! error TS4037: Parameter type of public setter 'foo113' from exported class has or is using private name 'm2'. - } - - // Both - getter without annotation, setter with annotation - get foo114() { - return new m2.public2(); - } - set foo114(param: m2.public2) { - ~~ -!!! error TS4037: Parameter type of public setter 'foo114' from exported class has or is using private name 'm2'. - } - - // Both - with annotation - get foo115(): m2.public2 { - ~~ -!!! error TS4043: Return type of public getter 'foo115' from exported class has or is using private name 'm2'. - return; - } - set foo115(param: m2.public2) { - } - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.js b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.js index c02807207ca..20d784489d9 100644 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.js +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorAccessors.js @@ -258,3 +258,33 @@ var m; }()); m.c = c; })(m || (m = {})); + + +//// [declFileTypeAnnotationVisibilityErrorAccessors.d.ts] +declare module m { + class private1 { + } + class public1 { + } + module m2 { + class public2 { + } + } + class c { + readonly foo1: private1; + readonly foo2: private1; + foo3: private1; + foo4: private1; + foo5: private1; + readonly foo11: public1; + readonly foo12: public1; + foo13: public1; + foo14: public1; + foo15: public1; + readonly foo111: m2.public2; + readonly foo112: m2.public2; + foo113: m2.public2; + foo114: m2.public2; + foo115: m2.public2; + } +} diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorParameterOfFunction.errors.txt b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorParameterOfFunction.errors.txt deleted file mode 100644 index 339ae67eea4..00000000000 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorParameterOfFunction.errors.txt +++ /dev/null @@ -1,59 +0,0 @@ -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorParameterOfFunction.ts(14,34): error TS4078: Parameter 'param' of exported function has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorParameterOfFunction.ts(16,26): error TS4078: Parameter 'param' of exported function has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorParameterOfFunction.ts(39,35): error TS4078: Parameter 'param' of exported function has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorParameterOfFunction.ts(41,28): error TS4077: Parameter 'param' of exported function has or is using name 'm2.public2' from private module 'm2'. - - -==== tests/cases/compiler/declFileTypeAnnotationVisibilityErrorParameterOfFunction.ts (4 errors) ==== - module m { - class private1 { - } - - export class public1 { - } - - // Directly using names from this module - function foo1(param: private1) { - } - function foo2(param = new private1()) { - } - - export function foo3(param : private1) { - ~~~~~~~~ -!!! error TS4078: Parameter 'param' of exported function has or is using private name 'private1'. - } - export function foo4(param = new private1()) { - ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4078: Parameter 'param' of exported function has or is using private name 'private1'. - } - - function foo11(param: public1) { - } - function foo12(param = new public1()) { - } - - export function foo13(param: public1) { - } - export function foo14(param = new public1()) { - } - - module m2 { - export class public2 { - } - } - - function foo111(param: m2.public2) { - } - function foo112(param = new m2.public2()) { - } - - export function foo113(param: m2.public2) { - ~~ -!!! error TS4078: Parameter 'param' of exported function has or is using private name 'm2'. - } - export function foo114(param = new m2.public2()) { - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4077: Parameter 'param' of exported function has or is using name 'm2.public2' from private module 'm2'. - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorParameterOfFunction.js b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorParameterOfFunction.js index 1c4a27cee61..4e1edd7fe39 100644 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorParameterOfFunction.js +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorParameterOfFunction.js @@ -105,3 +105,22 @@ var m; } m.foo114 = foo114; })(m || (m = {})); + + +//// [declFileTypeAnnotationVisibilityErrorParameterOfFunction.d.ts] +declare module m { + class private1 { + } + class public1 { + } + function foo3(param: private1): void; + function foo4(param?: private1): void; + function foo13(param: public1): void; + function foo14(param?: public1): void; + module m2 { + class public2 { + } + } + function foo113(param: m2.public2): void; + function foo114(param?: m2.public2): void; +} diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.errors.txt b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.errors.txt deleted file mode 100644 index 492e6615efa..00000000000 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.errors.txt +++ /dev/null @@ -1,71 +0,0 @@ -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.ts(16,29): error TS4060: Return type of exported function has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.ts(19,21): error TS4060: Return type of exported function has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.ts(49,31): error TS4060: Return type of exported function has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.ts(52,21): error TS4059: Return type of exported function has or is using name 'm2.public2' from private module 'm2'. - - -==== tests/cases/compiler/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.ts (4 errors) ==== - module m { - class private1 { - } - - export class public1 { - } - - // Directly using names from this module - function foo1(): private1 { - return; - } - function foo2() { - return new private1(); - } - - export function foo3(): private1 { - ~~~~~~~~ -!!! error TS4060: Return type of exported function has or is using private name 'private1'. - return; - } - export function foo4() { - ~~~~ -!!! error TS4060: Return type of exported function has or is using private name 'private1'. - return new private1(); - } - - function foo11(): public1 { - return; - } - function foo12() { - return new public1(); - } - - export function foo13(): public1 { - return; - } - export function foo14() { - return new public1(); - } - - module m2 { - export class public2 { - } - } - - function foo111(): m2.public2 { - return; - } - function foo112() { - return new m2.public2(); - } - - export function foo113(): m2.public2 { - ~~ -!!! error TS4060: Return type of exported function has or is using private name 'm2'. - return; - } - export function foo114() { - ~~~~~~ -!!! error TS4059: Return type of exported function has or is using name 'm2.public2' from private module 'm2'. - return new m2.public2(); - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.js b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.js index a0e43b6521d..8a2437a2ac4 100644 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.js +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.js @@ -123,3 +123,22 @@ var m; } m.foo114 = foo114; })(m || (m = {})); + + +//// [declFileTypeAnnotationVisibilityErrorReturnTypeOfFunction.d.ts] +declare module m { + class private1 { + } + class public1 { + } + function foo3(): private1; + function foo4(): private1; + function foo13(): public1; + function foo14(): public1; + module m2 { + class public2 { + } + } + function foo113(): m2.public2; + function foo114(): m2.public2; +} diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.errors.txt b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.errors.txt deleted file mode 100644 index 919fd5cd657..00000000000 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.errors.txt +++ /dev/null @@ -1,55 +0,0 @@ -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeAlias.ts(9,23): error TS4025: Exported variable 'p' has or is using private name 'W'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeAlias.ts(32,22): error TS4081: Exported type alias 't2' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeAlias.ts(35,23): error TS4081: Exported type alias 't12' has or is using private name 'public1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeAlias.ts(38,24): error TS4081: Exported type alias 't112' has or is using private name 'm3'. - - -==== tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeAlias.ts (4 errors) ==== - interface Window { - someMethod(); - } - - module M { - type W = Window | string; - export module N { - export class Window { } - export var p: W; // Should report error that W is private - ~ -!!! error TS4025: Exported variable 'p' has or is using private name 'W'. - } - } - - module M1 { - export type W = Window | string; - export module N { - export class Window { } - export var p: W; // No error - } - } - - module M2 { - class private1 { - } - class public1 { - } - module m3 { - export class public1 { - } - } - - type t1 = private1; - export type t2 = private1; // error - ~~~~~~~~ -!!! error TS4081: Exported type alias 't2' has or is using private name 'private1'. - - type t11 = public1; - export type t12 = public1; - ~~~~~~~ -!!! error TS4081: Exported type alias 't12' has or is using private name 'public1'. - - type t111 = m3.public1; - export type t112 = m3.public1; // error - ~~ -!!! error TS4081: Exported type alias 't112' has or is using private name 'm3'. - } - \ No newline at end of file diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.js b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.js index 2d1e3d1880e..fd39a6e20d9 100644 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.js +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.js @@ -87,3 +87,38 @@ var M2; m3.public1 = public1; })(m3 || (m3 = {})); })(M2 || (M2 = {})); + + +//// [declFileTypeAnnotationVisibilityErrorTypeAlias.d.ts] +interface Window { + someMethod(): any; +} +declare module M { + type W = Window | string; + module N { + class Window { + } + var p: W; + } +} +declare module M1 { + type W = Window | string; + module N { + class Window { + } + var p: W; + } +} +declare module M2 { + class private1 { + } + class public1 { + } + module m3 { + class public1 { + } + } + type t2 = private1; + type t12 = public1; + type t112 = m3.public1; +} diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.types b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.types index 5d467f07df4..24911343bea 100644 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.types +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeAlias.types @@ -10,7 +10,7 @@ module M { >M : typeof M type W = Window | string; ->W : string | Window +>W : W >Window : Window export module N { @@ -20,8 +20,8 @@ module M { >Window : Window export var p: W; // Should report error that W is private ->p : string | Window ->W : string | Window +>p : W +>W : W } } diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.errors.txt b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.errors.txt deleted file mode 100644 index a8d8023e830..00000000000 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.errors.txt +++ /dev/null @@ -1,90 +0,0 @@ -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(10,12): error TS4025: Exported variable 'x' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(11,12): error TS4025: Exported variable 'x' has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(12,13): error TS4025: Exported variable 'x' has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(13,19): error TS4025: Exported variable 'x' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(14,22): error TS4025: Exported variable 'x' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(15,22): error TS4025: Exported variable 'x' has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(17,16): error TS4024: Exported variable 'x2' has or is using name 'm2.public1' from private module 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(17,16): error TS4025: Exported variable 'x2' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(24,16): error TS4024: Exported variable 'x3' has or is using name 'm2.public1' from private module 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(24,16): error TS4025: Exported variable 'x3' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(27,23): error TS4025: Exported variable 'y' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(27,36): error TS4025: Exported variable 'y' has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(28,16): error TS4024: Exported variable 'y2' has or is using name 'm2.public1' from private module 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(28,16): error TS4025: Exported variable 'y2' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(31,27): error TS4025: Exported variable 'z' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(31,40): error TS4025: Exported variable 'z' has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(32,16): error TS4024: Exported variable 'z2' has or is using name 'm2.public1' from private module 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts(32,16): error TS4025: Exported variable 'z2' has or is using private name 'private1'. - - -==== tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts (18 errors) ==== - module m { - class private1 { - } - module m2 { - export class public1 { - } - } - - export var x: { - x: private1; - ~~~~~~~~ -!!! error TS4025: Exported variable 'x' has or is using private name 'private1'. - y: m2.public1; - ~~ -!!! error TS4025: Exported variable 'x' has or is using private name 'm2'. - (): m2.public1[]; - ~~ -!!! error TS4025: Exported variable 'x' has or is using private name 'm2'. - method(): private1; - ~~~~~~~~ -!!! error TS4025: Exported variable 'x' has or is using private name 'private1'. - [n: number]: private1; - ~~~~~~~~ -!!! error TS4025: Exported variable 'x' has or is using private name 'private1'. - [s: string]: m2.public1; - ~~ -!!! error TS4025: Exported variable 'x' has or is using private name 'm2'. - }; - export var x2 = { - ~~ -!!! error TS4024: Exported variable 'x2' has or is using name 'm2.public1' from private module 'm2'. - ~~ -!!! error TS4025: Exported variable 'x2' has or is using private name 'private1'. - x: new private1(), - y: new m2.public1(), - method() { - return new private1(); - } - }; - export var x3 = x; - ~~ -!!! error TS4024: Exported variable 'x3' has or is using name 'm2.public1' from private module 'm2'. - ~~ -!!! error TS4025: Exported variable 'x3' has or is using private name 'private1'. - - // Function type - export var y: (a: private1) => m2.public1; - ~~~~~~~~ -!!! error TS4025: Exported variable 'y' has or is using private name 'private1'. - ~~ -!!! error TS4025: Exported variable 'y' has or is using private name 'm2'. - export var y2 = y; - ~~ -!!! error TS4024: Exported variable 'y2' has or is using name 'm2.public1' from private module 'm2'. - ~~ -!!! error TS4025: Exported variable 'y2' has or is using private name 'private1'. - - // constructor type - export var z: new (a: private1) => m2.public1; - ~~~~~~~~ -!!! error TS4025: Exported variable 'z' has or is using private name 'private1'. - ~~ -!!! error TS4025: Exported variable 'z' has or is using private name 'm2'. - export var z2 = z; - ~~ -!!! error TS4024: Exported variable 'z2' has or is using name 'm2.public1' from private module 'm2'. - ~~ -!!! error TS4025: Exported variable 'z2' has or is using private name 'private1'. - } \ No newline at end of file diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.js b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.js index 687ab02fdb6..ecb3e035e2a 100644 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.js +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorTypeLiteral.js @@ -61,3 +61,39 @@ var m; m.y2 = m.y; m.z2 = m.z; })(m || (m = {})); + + +//// [declFileTypeAnnotationVisibilityErrorTypeLiteral.d.ts] +declare module m { + class private1 { + } + module m2 { + class public1 { + } + } + var x: { + x: private1; + y: m2.public1; + (): m2.public1[]; + method(): private1; + [n: number]: private1; + [s: string]: m2.public1; + }; + var x2: { + x: private1; + y: m2.public1; + method(): private1; + }; + var x3: { + (): m2.public1[]; + [s: string]: m2.public1; + [n: number]: private1; + x: private1; + y: m2.public1; + method(): private1; + }; + var y: (a: private1) => m2.public1; + var y2: (a: private1) => m2.public1; + var z: new (a: private1) => m2.public1; + var z2: new (a: private1) => m2.public1; +} diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorVariableDeclaration.errors.txt b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorVariableDeclaration.errors.txt deleted file mode 100644 index 6a9e5961831..00000000000 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorVariableDeclaration.errors.txt +++ /dev/null @@ -1,47 +0,0 @@ -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorVariableDeclaration.ts(12,19): error TS4025: Exported variable 'k' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorVariableDeclaration.ts(13,16): error TS4025: Exported variable 'l' has or is using private name 'private1'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorVariableDeclaration.ts(29,20): error TS4025: Exported variable 'k3' has or is using private name 'm2'. -tests/cases/compiler/declFileTypeAnnotationVisibilityErrorVariableDeclaration.ts(30,16): error TS4024: Exported variable 'l3' has or is using name 'm2.public2' from private module 'm2'. - - -==== tests/cases/compiler/declFileTypeAnnotationVisibilityErrorVariableDeclaration.ts (4 errors) ==== - module m { - class private1 { - } - - export class public1 { - } - - // Directly using names from this module - var x: private1; - var y = new private1(); - - export var k: private1; - ~~~~~~~~ -!!! error TS4025: Exported variable 'k' has or is using private name 'private1'. - export var l = new private1(); - ~ -!!! error TS4025: Exported variable 'l' has or is using private name 'private1'. - - var x2: public1; - var y2 = new public1(); - - export var k2: public1; - export var l2 = new public1(); - - module m2 { - export class public2 { - } - } - - var x3: m2.public2; - var y3 = new m2.public2(); - - export var k3: m2.public2; - ~~ -!!! error TS4025: Exported variable 'k3' has or is using private name 'm2'. - export var l3 = new m2.public2(); - ~~ -!!! error TS4024: Exported variable 'l3' has or is using name 'm2.public2' from private module 'm2'. - } - \ No newline at end of file diff --git a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorVariableDeclaration.js b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorVariableDeclaration.js index 56f959a1356..6bdcedae7d7 100644 --- a/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorVariableDeclaration.js +++ b/tests/baselines/reference/declFileTypeAnnotationVisibilityErrorVariableDeclaration.js @@ -66,3 +66,22 @@ var m; var y3 = new m2.public2(); m.l3 = new m2.public2(); })(m || (m = {})); + + +//// [declFileTypeAnnotationVisibilityErrorVariableDeclaration.d.ts] +declare module m { + class private1 { + } + class public1 { + } + var k: private1; + var l: private1; + var k2: public1; + var l2: public1; + module m2 { + class public2 { + } + } + var k3: m2.public2; + var l3: m2.public2; +} diff --git a/tests/baselines/reference/declInput-2.errors.txt b/tests/baselines/reference/declInput-2.errors.txt deleted file mode 100644 index f151f3e7122..00000000000 --- a/tests/baselines/reference/declInput-2.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -tests/cases/compiler/declInput-2.ts(10,21): error TS4031: Public property 'm22' of exported class has or is using private name 'C'. -tests/cases/compiler/declInput-2.ts(13,21): error TS4031: Public property 'm25' of exported class has or is using private name 'I2'. -tests/cases/compiler/declInput-2.ts(16,24): error TS4055: Return type of public method from exported class has or is using private name 'I2'. -tests/cases/compiler/declInput-2.ts(18,23): error TS4073: Parameter 'i' of public method from exported class has or is using private name 'I2'. -tests/cases/compiler/declInput-2.ts(19,21): error TS4055: Return type of public method from exported class has or is using private name 'C'. - - -==== tests/cases/compiler/declInput-2.ts (5 errors) ==== - module M { - class C { } - export class E {} - export interface I1 {} - interface I2 {} - export class D { - private c: C; // don't generate - public m1: number; - public m2: string; - public m22: C; // don't generate - ~ -!!! error TS4031: Public property 'm22' of exported class has or is using private name 'C'. - public m23: E; - public m24: I1; - public m25: I2; // don't generate - ~~ -!!! error TS4031: Public property 'm25' of exported class has or is using private name 'I2'. - public m232(): E { return null;} - public m242(): I1 { return null; } - public m252(): I2 { return null; } // don't generate - ~~ -!!! error TS4055: Return type of public method from exported class has or is using private name 'I2'. - public m26(i:I1) {} - public m262(i:I2) {} - ~~ -!!! error TS4073: Parameter 'i' of public method from exported class has or is using private name 'I2'. - public m3():C { return new C(); } - ~ -!!! error TS4055: Return type of public method from exported class has or is using private name 'C'. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/declInput-2.js b/tests/baselines/reference/declInput-2.js index 02dc3cd2819..f1f23b7f22e 100644 --- a/tests/baselines/reference/declInput-2.js +++ b/tests/baselines/reference/declInput-2.js @@ -48,3 +48,31 @@ var M; }()); M.D = D; })(M || (M = {})); + + +//// [declInput-2.d.ts] +declare module M { + class C { + } + class E { + } + interface I1 { + } + interface I2 { + } + class D { + private c; + m1: number; + m2: string; + m22: C; + m23: E; + m24: I1; + m25: I2; + m232(): E; + m242(): I1; + m252(): I2; + m26(i: I1): void; + m262(i: I2): void; + m3(): C; + } +} diff --git a/tests/baselines/reference/declarationEmitAliasFromIndirectFile.js b/tests/baselines/reference/declarationEmitAliasFromIndirectFile.js index 1d55514eb9d..105b406cdad 100644 --- a/tests/baselines/reference/declarationEmitAliasFromIndirectFile.js +++ b/tests/baselines/reference/declarationEmitAliasFromIndirectFile.js @@ -36,24 +36,9 @@ exports["default"] = fp.l10ns; //// [app.d.ts] declare const _default: { - ar?: { - weekdays: { - shorthand: [string, string, string, string, string, string, string]; - longhand: [string, string, string, string, string, string, string]; - }; - }; - bg?: { - weekdays: { - shorthand: [string, string, string, string, string, string, string]; - longhand: [string, string, string, string, string, string, string]; - }; - }; + ar?: import("./locale").CustomLocale; + bg?: import("./locale").CustomLocale; } & { - default: { - weekdays: { - shorthand: [string, string, string, string, string, string, string]; - longhand: [string, string, string, string, string, string, string]; - }; - }; + default: import("./locale").Locale; }; export default _default; diff --git a/tests/baselines/reference/declarationEmitAliasFromIndirectFile.types b/tests/baselines/reference/declarationEmitAliasFromIndirectFile.types index 16730debf8e..35557a1fd1d 100644 --- a/tests/baselines/reference/declarationEmitAliasFromIndirectFile.types +++ b/tests/baselines/reference/declarationEmitAliasFromIndirectFile.types @@ -62,7 +62,7 @@ const fp = { l10ns: {} } as FlatpickrFn; >FlatpickrFn : FlatpickrFn export default fp.l10ns; ->fp.l10ns : { ar?: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; bg?: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; } & { default: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; } +>fp.l10ns : { ar?: import("tests/cases/compiler/locale").CustomLocale; bg?: import("tests/cases/compiler/locale").CustomLocale; } & { default: import("tests/cases/compiler/locale").Locale; } >fp : FlatpickrFn ->l10ns : { ar?: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; bg?: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; } & { default: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; } +>l10ns : { ar?: import("tests/cases/compiler/locale").CustomLocale; bg?: import("tests/cases/compiler/locale").CustomLocale; } & { default: import("tests/cases/compiler/locale").Locale; } diff --git a/tests/baselines/reference/declarationEmitClassPrivateConstructor2.errors.txt b/tests/baselines/reference/declarationEmitClassPrivateConstructor2.errors.txt deleted file mode 100644 index a31454a4760..00000000000 --- a/tests/baselines/reference/declarationEmitClassPrivateConstructor2.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -tests/cases/compiler/declarationEmitClassPrivateConstructor2.ts(5,38): error TS4031: Public property 'data' of exported class has or is using private name 'PrivateInterface'. -tests/cases/compiler/declarationEmitClassPrivateConstructor2.ts(10,33): error TS4063: Parameter 'data' of constructor from exported class has or is using private name 'PrivateInterface'. - - -==== tests/cases/compiler/declarationEmitClassPrivateConstructor2.ts (2 errors) ==== - interface PrivateInterface { - } - - export class ExportedClass1 { - private constructor(public data: PrivateInterface) { } - ~~~~~~~~~~~~~~~~ -!!! error TS4031: Public property 'data' of exported class has or is using private name 'PrivateInterface'. - } - - - export class ExportedClass2 { - protected constructor(data: PrivateInterface) { } - ~~~~~~~~~~~~~~~~ -!!! error TS4063: Parameter 'data' of constructor from exported class has or is using private name 'PrivateInterface'. - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitClassPrivateConstructor2.js b/tests/baselines/reference/declarationEmitClassPrivateConstructor2.js index 863b295751f..445270e00c5 100644 --- a/tests/baselines/reference/declarationEmitClassPrivateConstructor2.js +++ b/tests/baselines/reference/declarationEmitClassPrivateConstructor2.js @@ -27,3 +27,16 @@ var ExportedClass2 = /** @class */ (function () { return ExportedClass2; }()); exports.ExportedClass2 = ExportedClass2; + + +//// [declarationEmitClassPrivateConstructor2.d.ts] +interface PrivateInterface { +} +export declare class ExportedClass1 { + data: PrivateInterface; + private constructor(); +} +export declare class ExportedClass2 { + protected constructor(data: PrivateInterface); +} +export {}; diff --git a/tests/baselines/reference/declarationEmitDefaultExport7.errors.txt b/tests/baselines/reference/declarationEmitDefaultExport7.errors.txt deleted file mode 100644 index f19766cbb00..00000000000 --- a/tests/baselines/reference/declarationEmitDefaultExport7.errors.txt +++ /dev/null @@ -1,9 +0,0 @@ -tests/cases/compiler/declarationEmitDefaultExport7.ts(2,1): error TS4082: Default export of the module has or is using private name 'A'. - - -==== tests/cases/compiler/declarationEmitDefaultExport7.ts (1 errors) ==== - class A {} - export default new A(); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4082: Default export of the module has or is using private name 'A'. - \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDefaultExport7.js b/tests/baselines/reference/declarationEmitDefaultExport7.js index 99751113dd6..e0c72ee4225 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport7.js +++ b/tests/baselines/reference/declarationEmitDefaultExport7.js @@ -7,3 +7,10 @@ export default new A(); class A { } export default new A(); + + +//// [declarationEmitDefaultExport7.d.ts] +declare class A { +} +declare const _default: A; +export default _default; diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.js b/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.js index 84ab9f242e9..b4aea71a241 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.js +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.js @@ -6,8 +6,8 @@ module M { //// [declarationEmitDestructuringArrayPattern3.js] var M; (function (M) { - _a = [1, 2], M.a = _a[0], M.b = _a[1]; var _a; + _a = [1, 2], M.a = _a[0], M.b = _a[1]; })(M || (M = {})); diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js index 0414017b776..10d7427388a 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern.js @@ -39,8 +39,8 @@ function f15() { var _f = f15(), a4 = _f.a4, b4 = _f.b4, c4 = _f.c4; var m; (function (m) { - _a = f15(), m.a4 = _a.a4, m.b4 = _a.b4, m.c4 = _a.c4; var _a; + _a = f15(), m.a4 = _a.a4, m.b4 = _a.b4, m.c4 = _a.c4; })(m || (m = {})); diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js index 6b8add193f2..66dfe225e83 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.js @@ -24,8 +24,8 @@ function f15() { var _c = f15(), a4 = _c.a4, b4 = _c.b4, c4 = _c.c4; var m; (function (m) { - _a = f15(), m.a4 = _a.a4, m.b4 = _a.b4, m.c4 = _a.c4; var _a; + _a = f15(), m.a4 = _a.a4, m.b4 = _a.b4, m.c4 = _a.c4; })(m || (m = {})); diff --git a/tests/baselines/reference/declarationEmitDestructuringPrivacyError.errors.txt b/tests/baselines/reference/declarationEmitDestructuringPrivacyError.errors.txt deleted file mode 100644 index e464b96a8bf..00000000000 --- a/tests/baselines/reference/declarationEmitDestructuringPrivacyError.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/declarationEmitDestructuringPrivacyError.ts(4,20): error TS4025: Exported variable 'y' has or is using private name 'c'. - - -==== tests/cases/compiler/declarationEmitDestructuringPrivacyError.ts (1 errors) ==== - module m { - class c { - } - export var [x, y, z] = [10, new c(), 30]; - ~ -!!! error TS4025: Exported variable 'y' has or is using private name 'c'. - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitDestructuringPrivacyError.js b/tests/baselines/reference/declarationEmitDestructuringPrivacyError.js index 23b93d14e15..dc037d7db11 100644 --- a/tests/baselines/reference/declarationEmitDestructuringPrivacyError.js +++ b/tests/baselines/reference/declarationEmitDestructuringPrivacyError.js @@ -8,11 +8,19 @@ module m { //// [declarationEmitDestructuringPrivacyError.js] var m; (function (m) { + var _a; var c = /** @class */ (function () { function c() { } return c; }()); _a = [10, new c(), 30], m.x = _a[0], m.y = _a[1], m.z = _a[2]; - var _a; })(m || (m = {})); + + +//// [declarationEmitDestructuringPrivacyError.d.ts] +declare module m { + class c { + } + var x: number, y: c, z: number; +} diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt b/tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt deleted file mode 100644 index 4864a3bcdc2..00000000000 --- a/tests/baselines/reference/declarationEmitExpressionInExtends3.errors.txt +++ /dev/null @@ -1,51 +0,0 @@ -tests/cases/compiler/declarationEmitExpressionInExtends3.ts(28,30): error TS4020: 'extends' clause of exported class 'MyClass' has or is using private name 'LocalClass'. -tests/cases/compiler/declarationEmitExpressionInExtends3.ts(36,75): error TS4020: 'extends' clause of exported class 'MyClass3' has or is using private name 'LocalInterface'. - - -==== tests/cases/compiler/declarationEmitExpressionInExtends3.ts (2 errors) ==== - export class ExportedClass { - x: T; - } - - class LocalClass { - x: T; - y: U; - } - - export interface ExportedInterface { - x: number; - } - - interface LocalInterface { - x: number; - } - - function getLocalClass(c: T) { - return LocalClass; - } - - function getExportedClass(c: T) { - return ExportedClass; - } - - - - export class MyClass extends getLocalClass(undefined) { // error LocalClass is inaccisible - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS4020: 'extends' clause of exported class 'MyClass' has or is using private name 'LocalClass'. - } - - - export class MyClass2 extends getExportedClass(undefined) { // OK - } - - - export class MyClass3 extends getExportedClass(undefined) { // Error LocalInterface is inaccisble - ~~~~~~~~~~~~~~ -!!! error TS4020: 'extends' clause of exported class 'MyClass3' has or is using private name 'LocalInterface'. - } - - - export class MyClass4 extends getExportedClass(undefined) { // OK - } - \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitExpressionInExtends3.js b/tests/baselines/reference/declarationEmitExpressionInExtends3.js index c97587620fd..c73268f7c55 100644 --- a/tests/baselines/reference/declarationEmitExpressionInExtends3.js +++ b/tests/baselines/reference/declarationEmitExpressionInExtends3.js @@ -104,3 +104,32 @@ var MyClass4 = /** @class */ (function (_super) { return MyClass4; }(getExportedClass(undefined))); exports.MyClass4 = MyClass4; + + +//// [declarationEmitExpressionInExtends3.d.ts] +export declare class ExportedClass { + x: T; +} +declare class LocalClass { + x: T; + y: U; +} +export interface ExportedInterface { + x: number; +} +interface LocalInterface { + x: number; +} +declare const MyClass_base: typeof LocalClass; +export declare class MyClass extends MyClass_base { +} +declare const MyClass2_base: typeof ExportedClass; +export declare class MyClass2 extends MyClass2_base { +} +declare const MyClass3_base: typeof ExportedClass; +export declare class MyClass3 extends MyClass3_base { +} +declare const MyClass4_base: typeof ExportedClass; +export declare class MyClass4 extends MyClass4_base { +} +export {}; diff --git a/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.errors.txt b/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.errors.txt deleted file mode 100644 index 37a4853b649..00000000000 --- a/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicatesWithPrivateName01.ts(5,33): error TS4060: Return type of exported function has or is using private name 'I'. - - -==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicatesWithPrivateName01.ts (1 errors) ==== - interface I { - a: number; - } - - export function f(x: any): x is I { - ~ -!!! error TS4060: Return type of exported function has or is using private name 'I'. - return typeof x.a === "number"; - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.js b/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.js index 74da01ce683..1531d09a88f 100644 --- a/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.js +++ b/tests/baselines/reference/declarationEmitIdentifierPredicatesWithPrivateName01.js @@ -14,3 +14,11 @@ function f(x) { return typeof x.a === "number"; } exports.f = f; + + +//// [declarationEmitIdentifierPredicatesWithPrivateName01.d.ts] +interface I { + a: number; +} +export declare function f(x: any): x is I; +export {}; diff --git a/tests/baselines/reference/declarationEmitInferredTypeAlias7.js b/tests/baselines/reference/declarationEmitInferredTypeAlias7.js index ff44c18f918..d2977b6b78c 100644 --- a/tests/baselines/reference/declarationEmitInferredTypeAlias7.js +++ b/tests/baselines/reference/declarationEmitInferredTypeAlias7.js @@ -22,5 +22,5 @@ exports.v = v; //// [0.d.ts] export declare type Data = string | boolean; //// [1.d.ts] -declare let v: string | boolean; +declare let v: import("./0").Data; export { v }; diff --git a/tests/baselines/reference/declarationEmitInferredTypeAlias7.types b/tests/baselines/reference/declarationEmitInferredTypeAlias7.types index 72289ce63dd..a1af3ba3790 100644 --- a/tests/baselines/reference/declarationEmitInferredTypeAlias7.types +++ b/tests/baselines/reference/declarationEmitInferredTypeAlias7.types @@ -9,11 +9,11 @@ let obj: Data = true; === tests/cases/compiler/1.ts === let v = "str" || true; ->v : string | boolean +>v : import("tests/cases/compiler/0").Data >"str" || true : true | "str" >"str" : "str" >true : true export { v } ->v : string | boolean +>v : import("tests/cases/compiler/0").Data diff --git a/tests/baselines/reference/declarationEmitInferredTypeAlias9.js b/tests/baselines/reference/declarationEmitInferredTypeAlias9.js index 8d03c6b70d2..8539cfaf03e 100644 --- a/tests/baselines/reference/declarationEmitInferredTypeAlias9.js +++ b/tests/baselines/reference/declarationEmitInferredTypeAlias9.js @@ -17,6 +17,8 @@ exports.returnSomeGlobalValue = returnSomeGlobalValue; //// [declarationEmitInferredTypeAlias9.d.ts] -export declare function returnSomeGlobalValue(): number[] | { - x: number[] | any; +declare type Foo = T | { + x: Foo; }; +export declare function returnSomeGlobalValue(): Foo; +export {}; diff --git a/tests/baselines/reference/declarationEmitInferredTypeAlias9.types b/tests/baselines/reference/declarationEmitInferredTypeAlias9.types index 30a15aff6fb..ab03db6da4f 100644 --- a/tests/baselines/reference/declarationEmitInferredTypeAlias9.types +++ b/tests/baselines/reference/declarationEmitInferredTypeAlias9.types @@ -1,19 +1,19 @@ === tests/cases/compiler/declarationEmitInferredTypeAlias9.ts === type Foo = T | { x: Foo }; ->Foo : T | { x: T | any; } +>Foo : Foo >T : T >T : T ->x : T | { x: T | any; } ->Foo : T | { x: T | any; } +>x : Foo +>Foo : Foo >T : T var x: Foo; ->x : number[] | { x: number[] | any; } ->Foo : T | { x: T | any; } +>x : Foo +>Foo : Foo export function returnSomeGlobalValue() { ->returnSomeGlobalValue : () => number[] | { x: number[] | any; } +>returnSomeGlobalValue : () => Foo return x; ->x : number[] | { x: number[] | any; } +>x : Foo } diff --git a/tests/baselines/reference/declarationEmitLocalClassDeclarationMixin.js b/tests/baselines/reference/declarationEmitLocalClassDeclarationMixin.js index 352520ff575..3cbbc0e0763 100644 --- a/tests/baselines/reference/declarationEmitLocalClassDeclarationMixin.js +++ b/tests/baselines/reference/declarationEmitLocalClassDeclarationMixin.js @@ -107,3 +107,4 @@ declare const FilteredThing_base: { export declare class FilteredThing extends FilteredThing_base { match(path: string): boolean; } +export {}; diff --git a/tests/baselines/reference/declarationEmitNestedGenerics.js b/tests/baselines/reference/declarationEmitNestedGenerics.js new file mode 100644 index 00000000000..04d74e3f8db --- /dev/null +++ b/tests/baselines/reference/declarationEmitNestedGenerics.js @@ -0,0 +1,25 @@ +//// [declarationEmitNestedGenerics.ts] +function f(p: T) { + let g: (x: T) => typeof p = null as any; + return g; +} + +function g(x: T) { + let y: typeof x extends (infer T)[] ? T : typeof x = null as any; + return y; +} + +//// [declarationEmitNestedGenerics.js] +function f(p) { + var g = null; + return g; +} +function g(x) { + var y = null; + return y; +} + + +//// [declarationEmitNestedGenerics.d.ts] +declare function f(p: T): (x: T_1) => T; +declare function g(x: T): T extends (infer T_1)[] ? T_1 : T; diff --git a/tests/baselines/reference/declarationEmitNestedGenerics.symbols b/tests/baselines/reference/declarationEmitNestedGenerics.symbols new file mode 100644 index 00000000000..b2f657e6f08 --- /dev/null +++ b/tests/baselines/reference/declarationEmitNestedGenerics.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/declarationEmitNestedGenerics.ts === +function f(p: T) { +>f : Symbol(f, Decl(declarationEmitNestedGenerics.ts, 0, 0)) +>T : Symbol(T, Decl(declarationEmitNestedGenerics.ts, 0, 11)) +>p : Symbol(p, Decl(declarationEmitNestedGenerics.ts, 0, 14)) +>T : Symbol(T, Decl(declarationEmitNestedGenerics.ts, 0, 11)) + + let g: (x: T) => typeof p = null as any; +>g : Symbol(g, Decl(declarationEmitNestedGenerics.ts, 1, 7)) +>T : Symbol(T, Decl(declarationEmitNestedGenerics.ts, 1, 12)) +>x : Symbol(x, Decl(declarationEmitNestedGenerics.ts, 1, 15)) +>T : Symbol(T, Decl(declarationEmitNestedGenerics.ts, 1, 12)) +>p : Symbol(p, Decl(declarationEmitNestedGenerics.ts, 0, 14)) + + return g; +>g : Symbol(g, Decl(declarationEmitNestedGenerics.ts, 1, 7)) +} + +function g(x: T) { +>g : Symbol(g, Decl(declarationEmitNestedGenerics.ts, 3, 1)) +>T : Symbol(T, Decl(declarationEmitNestedGenerics.ts, 5, 11)) +>x : Symbol(x, Decl(declarationEmitNestedGenerics.ts, 5, 14)) +>T : Symbol(T, Decl(declarationEmitNestedGenerics.ts, 5, 11)) + + let y: typeof x extends (infer T)[] ? T : typeof x = null as any; +>y : Symbol(y, Decl(declarationEmitNestedGenerics.ts, 6, 7)) +>x : Symbol(x, Decl(declarationEmitNestedGenerics.ts, 5, 14)) +>T : Symbol(T, Decl(declarationEmitNestedGenerics.ts, 6, 34)) +>T : Symbol(T, Decl(declarationEmitNestedGenerics.ts, 6, 34)) +>x : Symbol(x, Decl(declarationEmitNestedGenerics.ts, 5, 14)) + + return y; +>y : Symbol(y, Decl(declarationEmitNestedGenerics.ts, 6, 7)) +} diff --git a/tests/baselines/reference/declarationEmitNestedGenerics.types b/tests/baselines/reference/declarationEmitNestedGenerics.types new file mode 100644 index 00000000000..778ecd8290b --- /dev/null +++ b/tests/baselines/reference/declarationEmitNestedGenerics.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/declarationEmitNestedGenerics.ts === +function f(p: T) { +>f : (p: T) => (x: T) => T +>T : T +>p : T +>T : T + + let g: (x: T) => typeof p = null as any; +>g : (x: T) => T +>T : T +>x : T +>T : T +>p : T +>null as any : any +>null : null + + return g; +>g : (x: T) => T +} + +function g(x: T) { +>g : (x: T) => T extends (infer T)[] ? T : T +>T : T +>x : T +>T : T + + let y: typeof x extends (infer T)[] ? T : typeof x = null as any; +>y : T extends (infer T)[] ? T : T +>x : T +>T : T +>T : T +>x : T +>null as any : any +>null : null + + return y; +>y : T extends (infer T)[] ? T : T +} diff --git a/tests/baselines/reference/declarationEmitPrivateNameCausesError.js b/tests/baselines/reference/declarationEmitPrivateNameCausesError.js index 802195e4cca..66cb88ba4db 100644 --- a/tests/baselines/reference/declarationEmitPrivateNameCausesError.js +++ b/tests/baselines/reference/declarationEmitPrivateNameCausesError.js @@ -24,6 +24,7 @@ exports.__esModule = true; var IGNORE_EXTRA_VARIABLES = Symbol(); //Notice how this is unexported //This is exported function ignoreExtraVariables(ctor) { + var _a, _b; return _b = /** @class */ (function (_super) { __extends(class_1, _super); function class_1() { @@ -35,7 +36,6 @@ function ignoreExtraVariables(ctor) { }(ctor)), _a = IGNORE_EXTRA_VARIABLES, _b; - var _a, _b; } exports.ignoreExtraVariables = ignoreExtraVariables; diff --git a/tests/baselines/reference/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.js b/tests/baselines/reference/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.js index 13063135daf..91ca8405868 100644 --- a/tests/baselines/reference/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.js +++ b/tests/baselines/reference/declarationEmitPrivateSymbolCausesVarDeclarationEmit2.js @@ -26,6 +26,7 @@ exports.x = Symbol(); //// [b.js] "use strict"; exports.__esModule = true; +var _a; var a_1 = require("./a"); var C = /** @class */ (function () { function C() { @@ -35,7 +36,6 @@ var C = /** @class */ (function () { }()); _a = a_1.x; exports.C = C; -var _a; //// [c.js] "use strict"; var __extends = (this && this.__extends) || (function () { @@ -49,6 +49,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); exports.__esModule = true; +var _a; var a_1 = require("./a"); var b_1 = require("./b"); var D = /** @class */ (function (_super) { @@ -62,7 +63,6 @@ var D = /** @class */ (function (_super) { }(b_1.C)); _a = a_1.x; exports.D = D; -var _a; //// [a.d.ts] diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.errors.txt b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.errors.txt deleted file mode 100644 index ea59c8fa9e8..00000000000 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts(2,18): error TS4055: Return type of public method from exported class has or is using private name 'D'. - - -==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts (1 errors) ==== - export class C { - m(): this is D { - ~ -!!! error TS4055: Return type of public method from exported class has or is using private name 'D'. - return this instanceof D; - } - } - - class D extends C { - } \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.js b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.js index 5bb662b5907..10305b8ed64 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.js +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName01.js @@ -37,3 +37,12 @@ var D = /** @class */ (function (_super) { } return D; }(C)); + + +//// [declarationEmitThisPredicatesWithPrivateName01.d.ts] +export declare class C { + m(): this is D; +} +declare class D extends C { +} +export {}; diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt index f80c2bd0d6f..a01ebbb4864 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.errors.txt @@ -1,8 +1,7 @@ -tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(7,14): error TS4025: Exported variable 'obj' has or is using private name 'Foo'. tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(8,10): error TS2526: A 'this' type is available only in a non-static member of a class or interface. -==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (2 errors) ==== +==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (1 errors) ==== interface Foo { a: string; b: number; @@ -10,8 +9,6 @@ tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredic } export const obj = { - ~~~ -!!! error TS4025: Exported variable 'obj' has or is using private name 'Foo'. m(): this is Foo { ~~~~ !!! error TS2526: A 'this' type is available only in a non-static member of a class or interface. diff --git a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js index 86fb2e05607..96b580a68b9 100644 --- a/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js +++ b/tests/baselines/reference/declarationEmitThisPredicatesWithPrivateName02.js @@ -21,3 +21,15 @@ exports.obj = { return dis.a != null && dis.b != null && dis.c != null; } }; + + +//// [declarationEmitThisPredicatesWithPrivateName02.d.ts] +interface Foo { + a: string; + b: number; + c: boolean; +} +export declare const obj: { + m(): this is Foo; +}; +export {}; diff --git a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.errors.txt b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.errors.txt deleted file mode 100644 index 9552adfc0af..00000000000 --- a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters5.ts(4,25): error TS4081: Exported type alias 'SubFoo' has or is using private name 'Foo'. - - -==== tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters5.ts (1 errors) ==== - type Foo = { - foo(): Foo - }; - export type SubFoo = Foo; - ~~~ -!!! error TS4081: Exported type alias 'SubFoo' has or is using private name 'Foo'. - - function foo() { - return {} as SubFoo; - } - \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.js b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.js index cee701c0455..1b29acc164e 100644 --- a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.js +++ b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.js @@ -15,3 +15,11 @@ exports.__esModule = true; function foo() { return {}; } + + +//// [declarationEmitTypeAliasWithTypeParameters5.d.ts] +declare type Foo = { + foo(): Foo; +}; +export declare type SubFoo = Foo; +export {}; diff --git a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.types b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.types index 18ef901dbdc..cd98b3706f6 100644 --- a/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.types +++ b/tests/baselines/reference/declarationEmitTypeAliasWithTypeParameters5.types @@ -1,30 +1,30 @@ === tests/cases/compiler/declarationEmitTypeAliasWithTypeParameters5.ts === type Foo = { ->Foo : { foo(): Foo; } +>Foo : Foo >T : T >Y : Y foo(): Foo ->foo : () => { foo(): Foo; } +>foo : () => Foo >U : U >J : J ->Foo : { foo(): Foo; } +>Foo : Foo >U : U >J : J }; export type SubFoo = Foo; ->SubFoo : { foo(): Foo; } +>SubFoo : Foo >R : R ->Foo : { foo(): Foo; } +>Foo : Foo >R : R function foo() { ->foo : () => { foo(): Foo; } +>foo : () => Foo return {} as SubFoo; ->{} as SubFoo : { foo(): Foo; } +>{} as SubFoo : Foo >{} : {} ->SubFoo : { foo(): Foo; } +>SubFoo : Foo } diff --git a/tests/baselines/reference/declarationFilesGeneratingTypeReferences.js b/tests/baselines/reference/declarationFilesGeneratingTypeReferences.js new file mode 100644 index 00000000000..f928b064667 --- /dev/null +++ b/tests/baselines/reference/declarationFilesGeneratingTypeReferences.js @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/declarationFilesGeneratingTypeReferences.ts] //// + +//// [index.d.ts] +interface JQuery { + +} + +//// [app.ts] +/// +namespace Test { + export var x: JQuery; +} + +//// [out.js] +/// +var Test; +(function (Test) { +})(Test || (Test = {})); + + +//// [out.d.ts] +/// +declare namespace Test { + var x: JQuery; +} + + +//// [DtsFileErrors] + + +out.d.ts(1,23): error TS2688: Cannot find type definition file for 'jquery'. + + +==== /a/node_modules/@types/jquery/index.d.ts (0 errors) ==== + interface JQuery { + + } + +==== out.d.ts (1 errors) ==== + /// + ~~~~~~ +!!! error TS2688: Cannot find type definition file for 'jquery'. + declare namespace Test { + var x: JQuery; + } + \ No newline at end of file diff --git a/tests/baselines/reference/declarationFilesGeneratingTypeReferences.symbols b/tests/baselines/reference/declarationFilesGeneratingTypeReferences.symbols new file mode 100644 index 00000000000..28ae63fa4a9 --- /dev/null +++ b/tests/baselines/reference/declarationFilesGeneratingTypeReferences.symbols @@ -0,0 +1,15 @@ +=== /a/node_modules/@types/jquery/index.d.ts === +interface JQuery { +>JQuery : Symbol(JQuery, Decl(index.d.ts, 0, 0)) + +} + +=== /a/app.ts === +/// +namespace Test { +>Test : Symbol(Test, Decl(app.ts, 0, 0)) + + export var x: JQuery; +>x : Symbol(x, Decl(app.ts, 2, 14)) +>JQuery : Symbol(JQuery, Decl(index.d.ts, 0, 0)) +} diff --git a/tests/baselines/reference/declarationFilesGeneratingTypeReferences.types b/tests/baselines/reference/declarationFilesGeneratingTypeReferences.types new file mode 100644 index 00000000000..88c225f5d58 --- /dev/null +++ b/tests/baselines/reference/declarationFilesGeneratingTypeReferences.types @@ -0,0 +1,15 @@ +=== /a/node_modules/@types/jquery/index.d.ts === +interface JQuery { +>JQuery : JQuery + +} + +=== /a/app.ts === +/// +namespace Test { +>Test : typeof Test + + export var x: JQuery; +>x : JQuery +>JQuery : JQuery +} diff --git a/tests/baselines/reference/declarationFunctionTypeNonlocalShouldNotBeAnError.js b/tests/baselines/reference/declarationFunctionTypeNonlocalShouldNotBeAnError.js index 6faa0bfca60..88343a7d08e 100644 --- a/tests/baselines/reference/declarationFunctionTypeNonlocalShouldNotBeAnError.js +++ b/tests/baselines/reference/declarationFunctionTypeNonlocalShouldNotBeAnError.js @@ -20,7 +20,8 @@ var foo; //// [declarationFunctionTypeNonlocalShouldNotBeAnError.d.ts] declare namespace foo { + function bar(): void; const obj: { - bar: () => void; + bar: typeof bar; }; } diff --git a/tests/baselines/reference/declarationNoDanglingGenerics.js b/tests/baselines/reference/declarationNoDanglingGenerics.js index 9045be6827b..9ff7dfefd49 100644 --- a/tests/baselines/reference/declarationNoDanglingGenerics.js +++ b/tests/baselines/reference/declarationNoDanglingGenerics.js @@ -53,6 +53,7 @@ function register(kind) { kindCache[kind] = true; } function ClassFactory(kind) { + var _a; register(kind); return _a = /** @class */ (function () { function class_1() { @@ -62,7 +63,6 @@ function ClassFactory(kind) { }()), _a.THE_KIND = kind, _a; - var _a; } var Kinds = /** @class */ (function () { function Kinds() { @@ -123,3 +123,4 @@ declare const CKind_base: { }; export declare class CKind extends CKind_base { } +export {}; diff --git a/tests/baselines/reference/declarationsAndAssignments.js b/tests/baselines/reference/declarationsAndAssignments.js index 3a2f9ef3b4e..74d7cd94156 100644 --- a/tests/baselines/reference/declarationsAndAssignments.js +++ b/tests/baselines/reference/declarationsAndAssignments.js @@ -277,8 +277,8 @@ f14([2, ["abc", { x: 0 }]]); f14([2, ["abc", { y: false }]]); // Error, no x var M; (function (M) { - _a = [1, 2], M.a = _a[0], M.b = _a[1]; var _a; + _a = [1, 2], M.a = _a[0], M.b = _a[1]; })(M || (M = {})); function f15() { var a = "hello"; @@ -297,6 +297,7 @@ f17({ a: "hello" }); f17({ c: true }); f17(f15()); function f18() { + var _a, _b, _c, _d, _e, _f, _g; var a; var b; var aa; @@ -305,44 +306,43 @@ function f18() { _c = [a, b], aa[0] = _c[0], b = _c[1]; _d = [b, a], a = _d[0], b = _d[1]; // Error _e = [2, "def"], _f = _e[0], a = _f === void 0 ? 1 : _f, _g = _e[1], b = _g === void 0 ? "abc" : _g; - var _a, _b, _c, _d, _e, _f, _g; } function f19() { + var _a, _b, _c, _d, _e, _f; var a, b; _a = [1, 2], a = _a[0], b = _a[1]; _b = [b, a], a = _b[0], b = _b[1]; (_c = { b: b, a: a }, a = _c.a, b = _c.b); _d = [[2, 3]][0], _e = _d === void 0 ? [1, 2] : _d, a = _e[0], b = _e[1]; var x = (_f = [1, 2], a = _f[0], b = _f[1], _f); - var _a, _b, _c, _d, _e, _f; } function f20() { + var _a, _b, _c; var a; var x; var y; var z; var a = [1, 2, 3].slice(0); - var _a = [1, 2, 3], x = _a[0], a = _a.slice(1); - var _b = [1, 2, 3], x = _b[0], y = _b[1], a = _b.slice(2); - var _c = [1, 2, 3], x = _c[0], y = _c[1], z = _c[2], a = _c.slice(3); + var _d = [1, 2, 3], x = _d[0], a = _d.slice(1); + var _e = [1, 2, 3], x = _e[0], y = _e[1], a = _e.slice(2); + var _f = [1, 2, 3], x = _f[0], y = _f[1], z = _f[2], a = _f.slice(3); a = [1, 2, 3].slice(0); - _d = [1, 2, 3], x = _d[0], a = _d.slice(1); - _e = [1, 2, 3], x = _e[0], y = _e[1], a = _e.slice(2); - _f = [1, 2, 3], x = _f[0], y = _f[1], z = _f[2], a = _f.slice(3); - var _d, _e, _f; + _a = [1, 2, 3], x = _a[0], a = _a.slice(1); + _b = [1, 2, 3], x = _b[0], y = _b[1], a = _b.slice(2); + _c = [1, 2, 3], x = _c[0], y = _c[1], z = _c[2], a = _c.slice(3); } function f21() { + var _a, _b, _c; var a; var x; var y; var z; var a = [1, "hello", true].slice(0); - var _a = [1, "hello", true], x = _a[0], a = _a.slice(1); - var _b = [1, "hello", true], x = _b[0], y = _b[1], a = _b.slice(2); - var _c = [1, "hello", true], x = _c[0], y = _c[1], z = _c[2], a = _c.slice(3); + var _d = [1, "hello", true], x = _d[0], a = _d.slice(1); + var _e = [1, "hello", true], x = _e[0], y = _e[1], a = _e.slice(2); + var _f = [1, "hello", true], x = _f[0], y = _f[1], z = _f[2], a = _f.slice(3); a = [1, "hello", true].slice(0); - _d = [1, "hello", true], x = _d[0], a = _d.slice(1); - _e = [1, "hello", true], x = _e[0], y = _e[1], a = _e.slice(2); - _f = [1, "hello", true], x = _f[0], y = _f[1], z = _f[2], a = _f.slice(3); - var _d, _e, _f; + _a = [1, "hello", true], x = _a[0], a = _a.slice(1); + _b = [1, "hello", true], x = _b[0], y = _b[1], a = _b.slice(2); + _c = [1, "hello", true], x = _c[0], y = _c[1], z = _c[2], a = _c.slice(3); } diff --git a/tests/baselines/reference/declarationsForInferredTypeFromOtherFile.js b/tests/baselines/reference/declarationsForInferredTypeFromOtherFile.js new file mode 100644 index 00000000000..51d9b02b2b2 --- /dev/null +++ b/tests/baselines/reference/declarationsForInferredTypeFromOtherFile.js @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/declarationsForInferredTypeFromOtherFile.ts] //// + +//// [file1.ts] +export class Foo {} +//// [file2.ts] +export function foo(): import("./file1").Foo { + return null as any; +} +//// [file3.ts] +import {foo} from "./file2"; +export function bar() { + return foo(); +} + + +//// [file1.js] +"use strict"; +exports.__esModule = true; +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +exports.Foo = Foo; +//// [file2.js] +"use strict"; +exports.__esModule = true; +function foo() { + return null; +} +exports.foo = foo; +//// [file3.js] +"use strict"; +exports.__esModule = true; +var file2_1 = require("./file2"); +function bar() { + return file2_1.foo(); +} +exports.bar = bar; + + +//// [file1.d.ts] +export declare class Foo { +} +//// [file2.d.ts] +export declare function foo(): import("./file1").Foo; +//// [file3.d.ts] +export declare function bar(): import("./file1").Foo; diff --git a/tests/baselines/reference/declarationsForInferredTypeFromOtherFile.symbols b/tests/baselines/reference/declarationsForInferredTypeFromOtherFile.symbols new file mode 100644 index 00000000000..7fdd97737f4 --- /dev/null +++ b/tests/baselines/reference/declarationsForInferredTypeFromOtherFile.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/file1.ts === +export class Foo {} +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) + +=== tests/cases/compiler/file2.ts === +export function foo(): import("./file1").Foo { +>foo : Symbol(foo, Decl(file2.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(file1.ts, 0, 0)) + + return null as any; +} +=== tests/cases/compiler/file3.ts === +import {foo} from "./file2"; +>foo : Symbol(foo, Decl(file3.ts, 0, 8)) + +export function bar() { +>bar : Symbol(bar, Decl(file3.ts, 0, 28)) + + return foo(); +>foo : Symbol(foo, Decl(file3.ts, 0, 8)) +} + diff --git a/tests/baselines/reference/declarationsForInferredTypeFromOtherFile.types b/tests/baselines/reference/declarationsForInferredTypeFromOtherFile.types new file mode 100644 index 00000000000..587fefaacc1 --- /dev/null +++ b/tests/baselines/reference/declarationsForInferredTypeFromOtherFile.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/file1.ts === +export class Foo {} +>Foo : Foo + +=== tests/cases/compiler/file2.ts === +export function foo(): import("./file1").Foo { +>foo : () => import("tests/cases/compiler/file1").Foo +>Foo : import("tests/cases/compiler/file1").Foo + + return null as any; +>null as any : any +>null : null +} +=== tests/cases/compiler/file3.ts === +import {foo} from "./file2"; +>foo : () => import("tests/cases/compiler/file1").Foo + +export function bar() { +>bar : () => import("tests/cases/compiler/file1").Foo + + return foo(); +>foo() : import("tests/cases/compiler/file1").Foo +>foo : () => import("tests/cases/compiler/file1").Foo +} + diff --git a/tests/baselines/reference/decoratedClassExportsCommonJS1.js b/tests/baselines/reference/decoratedClassExportsCommonJS1.js index b624c11e79d..befb1f9586b 100644 --- a/tests/baselines/reference/decoratedClassExportsCommonJS1.js +++ b/tests/baselines/reference/decoratedClassExportsCommonJS1.js @@ -15,6 +15,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); +var Testing123_1; let Testing123 = Testing123_1 = class Testing123 { }; Testing123.prop1 = Testing123_1.prop0; @@ -22,4 +23,3 @@ Testing123 = Testing123_1 = __decorate([ Something({ v: () => Testing123_1 }) ], Testing123); exports.Testing123 = Testing123; -var Testing123_1; diff --git a/tests/baselines/reference/decoratedClassExportsCommonJS2.js b/tests/baselines/reference/decoratedClassExportsCommonJS2.js index b9ef278ac73..b93e63c7406 100644 --- a/tests/baselines/reference/decoratedClassExportsCommonJS2.js +++ b/tests/baselines/reference/decoratedClassExportsCommonJS2.js @@ -13,10 +13,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); +var Testing123_1; let Testing123 = Testing123_1 = class Testing123 { }; Testing123 = Testing123_1 = __decorate([ Something({ v: () => Testing123_1 }) ], Testing123); exports.Testing123 = Testing123; -var Testing123_1; diff --git a/tests/baselines/reference/decoratedClassExportsSystem1.js b/tests/baselines/reference/decoratedClassExportsSystem1.js index b32c2c9b445..5921a424524 100644 --- a/tests/baselines/reference/decoratedClassExportsSystem1.js +++ b/tests/baselines/reference/decoratedClassExportsSystem1.js @@ -9,15 +9,15 @@ export class Testing123 { //// [a.js] System.register([], function (exports_1, context_1) { - "use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; + var Testing123_1, Testing123; + "use strict"; var __moduleName = context_1 && context_1.id; - var Testing123, Testing123_1; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/decoratedClassExportsSystem2.js b/tests/baselines/reference/decoratedClassExportsSystem2.js index 99ddd29bc2c..e3f0a97b64d 100644 --- a/tests/baselines/reference/decoratedClassExportsSystem2.js +++ b/tests/baselines/reference/decoratedClassExportsSystem2.js @@ -6,15 +6,15 @@ export class Testing123 { } //// [a.js] System.register([], function (exports_1, context_1) { - "use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; + var Testing123_1, Testing123; + "use strict"; var __moduleName = context_1 && context_1.id; - var Testing123, Testing123_1; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/decoratedDefaultExportsGetExportedSystem.js b/tests/baselines/reference/decoratedDefaultExportsGetExportedSystem.js index 4628fc5e81c..837fdc103f8 100644 --- a/tests/baselines/reference/decoratedDefaultExportsGetExportedSystem.js +++ b/tests/baselines/reference/decoratedDefaultExportsGetExportedSystem.js @@ -14,15 +14,15 @@ export default class {} //// [a.js] System.register([], function (exports_1, context_1) { - "use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; - var __moduleName = context_1 && context_1.id; var decorator, Foo; + "use strict"; + var __moduleName = context_1 && context_1.id; return { setters: [], execute: function () { @@ -37,15 +37,15 @@ System.register([], function (exports_1, context_1) { }); //// [b.js] System.register([], function (exports_1, context_1) { - "use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; - var __moduleName = context_1 && context_1.id; var decorator, default_1; + "use strict"; + var __moduleName = context_1 && context_1.id; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js index bec7400996e..a20ff821148 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -46,11 +46,11 @@ var MyClass = /** @class */ (function () { this.db = db; this.db.doSomething(); } + var _a; MyClass = __decorate([ someDecorator, __metadata("design:paramtypes", [typeof (_a = (typeof db_1.default !== "undefined" && db_1.default).db) === "function" && _a || Object]) ], MyClass); return MyClass; - var _a; }()); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorOnClass5.es6.js b/tests/baselines/reference/decoratorOnClass5.es6.js index 426a93668e7..b1c45cbce31 100644 --- a/tests/baselines/reference/decoratorOnClass5.es6.js +++ b/tests/baselines/reference/decoratorOnClass5.es6.js @@ -16,6 +16,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +var C_1; let C = C_1 = class C { static x() { return C_1.y; } }; @@ -24,4 +25,3 @@ C = C_1 = __decorate([ dec ], C); let c = new C(); -var C_1; diff --git a/tests/baselines/reference/decoratorOnClass6.es6.js b/tests/baselines/reference/decoratorOnClass6.es6.js index 7da4a20bb93..f9d8d2f4199 100644 --- a/tests/baselines/reference/decoratorOnClass6.es6.js +++ b/tests/baselines/reference/decoratorOnClass6.es6.js @@ -16,6 +16,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +var C_1; let C = C_1 = class C { static x() { return C_1.y; } }; @@ -25,4 +26,3 @@ C = C_1 = __decorate([ ], C); export { C }; let c = new C(); -var C_1; diff --git a/tests/baselines/reference/decoratorOnClass7.es6.js b/tests/baselines/reference/decoratorOnClass7.es6.js index 92ee02c899e..aefc9536a87 100644 --- a/tests/baselines/reference/decoratorOnClass7.es6.js +++ b/tests/baselines/reference/decoratorOnClass7.es6.js @@ -16,6 +16,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +var C_1; let C = C_1 = class C { static x() { return C_1.y; } }; @@ -25,4 +26,3 @@ C = C_1 = __decorate([ ], C); export default C; let c = new C(); -var C_1; diff --git a/tests/baselines/reference/decoratorOnClass9.js b/tests/baselines/reference/decoratorOnClass9.js index 84ce76dba29..e92717f9b8a 100644 --- a/tests/baselines/reference/decoratorOnClass9.js +++ b/tests/baselines/reference/decoratorOnClass9.js @@ -45,11 +45,11 @@ var B = /** @class */ (function (_super) { B.prototype.m = function () { return B_1.x; }; + var B_1; B.x = 1; B.y = B_1.x; B = B_1 = __decorate([ dec ], B); return B; - var B_1; }(A)); diff --git a/tests/baselines/reference/decoratorsOnComputedProperties.js b/tests/baselines/reference/decoratorsOnComputedProperties.js index 4e7cf4a6ac1..2af6b460c05 100644 --- a/tests/baselines/reference/decoratorsOnComputedProperties.js +++ b/tests/baselines/reference/decoratorsOnComputedProperties.js @@ -196,6 +196,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21; function x(o, k) { } let i = 0; function foo() { return ++i + ""; } @@ -454,4 +455,3 @@ void (_21 = class J { }, _20 = fieldNameC, _21); -var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21; diff --git a/tests/baselines/reference/deduplicateImportsInSystem.js b/tests/baselines/reference/deduplicateImportsInSystem.js index f0ac7c83ed8..8bf49a449cc 100644 --- a/tests/baselines/reference/deduplicateImportsInSystem.js +++ b/tests/baselines/reference/deduplicateImportsInSystem.js @@ -10,9 +10,9 @@ console.log(A + B + C + D + E + F) //// [deduplicateImportsInSystem.js] System.register(["f1", "f2", "f3"], function (exports_1, context_1) { + var f1_1, f2_1, f3_1, f2_2, f2_3, f1_2; "use strict"; var __moduleName = context_1 && context_1.id; - var f1_1, f2_1, f3_1, f2_2, f2_3, f1_2; return { setters: [ function (f1_1_1) { diff --git a/tests/baselines/reference/defaultExportsGetExportedSystem.js b/tests/baselines/reference/defaultExportsGetExportedSystem.js index 089551195ae..0269905baba 100644 --- a/tests/baselines/reference/defaultExportsGetExportedSystem.js +++ b/tests/baselines/reference/defaultExportsGetExportedSystem.js @@ -9,9 +9,9 @@ export default function foo() {} //// [a.js] System.register([], function (exports_1, context_1) { + var Foo; "use strict"; var __moduleName = context_1 && context_1.id; - var Foo; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/destructuringAssignmentWithDefault.js b/tests/baselines/reference/destructuringAssignmentWithDefault.js index fe3ccdcee53..df4addf0269 100644 --- a/tests/baselines/reference/destructuringAssignmentWithDefault.js +++ b/tests/baselines/reference/destructuringAssignmentWithDefault.js @@ -5,7 +5,7 @@ let x = 0; //// [destructuringAssignmentWithDefault.js] +var _a; var a = {}; var x = 0; (_a = a.x, x = _a === void 0 ? 1 : _a); -var _a; diff --git a/tests/baselines/reference/destructuringAssignmentWithExportedName.js b/tests/baselines/reference/destructuringAssignmentWithExportedName.js index a23bec7b5d8..81f38a383ab 100644 --- a/tests/baselines/reference/destructuringAssignmentWithExportedName.js +++ b/tests/baselines/reference/destructuringAssignmentWithExportedName.js @@ -26,6 +26,7 @@ export { nonexportedFoo }; export { exportedFoo as foo, nonexportedFoo as nfoo }; //// [destructuringAssignmentWithExportedName.js] +var _a, _b, _c, _d, _e; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.foo = exports.exportedFoo; @@ -50,4 +51,3 @@ else if (null) { else { (_e = null[0], exports.foo = exports.exportedFoo = _e[0], exports.nfoo = exports.nonexportedFoo = nonexportedFoo = _e[1]); } -var _a, _b, _c, _d, _e; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations7.js b/tests/baselines/reference/destructuringInVariableDeclarations7.js index 82f28b09672..aabbb822523 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations7.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations7.js @@ -7,9 +7,9 @@ export let { toString } = 1; //// [destructuringInVariableDeclarations7.js] System.register([], function (exports_1, context_1) { + var toString; "use strict"; var __moduleName = context_1 && context_1.id; - var toString; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/destructuringInVariableDeclarations8.js b/tests/baselines/reference/destructuringInVariableDeclarations8.js index bf4be279e78..5455061cbc3 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations8.js +++ b/tests/baselines/reference/destructuringInVariableDeclarations8.js @@ -8,9 +8,9 @@ export {}; //// [destructuringInVariableDeclarations8.js] System.register([], function (exports_1, context_1) { + var toString; "use strict"; var __moduleName = context_1 && context_1.id; - var toString; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment5.js b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment5.js new file mode 100644 index 00000000000..4eb341b0561 --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment5.js @@ -0,0 +1,24 @@ +//// [destructuringObjectBindingPatternAndAssignment5.ts] +function a () { + let x: number; + let y: any + ({ x, ...y } = ({ } as any)); +} + + +//// [destructuringObjectBindingPatternAndAssignment5.js] +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) + t[p[i]] = s[p[i]]; + return t; +}; +function a() { + var _a; + var x; + var y; + (_a = {}, (x = _a.x, _a), y = __rest(_a, ["x"])); +} diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment5.symbols b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment5.symbols new file mode 100644 index 00000000000..9769a26fc99 --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment5.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment5.ts === +function a () { +>a : Symbol(a, Decl(destructuringObjectBindingPatternAndAssignment5.ts, 0, 0)) + + let x: number; +>x : Symbol(x, Decl(destructuringObjectBindingPatternAndAssignment5.ts, 1, 7)) + + let y: any +>y : Symbol(y, Decl(destructuringObjectBindingPatternAndAssignment5.ts, 2, 7)) + + ({ x, ...y } = ({ } as any)); +>x : Symbol(x, Decl(destructuringObjectBindingPatternAndAssignment5.ts, 3, 6)) +>y : Symbol(y, Decl(destructuringObjectBindingPatternAndAssignment5.ts, 2, 7)) +} + diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment5.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment5.types new file mode 100644 index 00000000000..20c42266cba --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment5.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment5.ts === +function a () { +>a : () => void + + let x: number; +>x : number + + let y: any +>y : any + + ({ x, ...y } = ({ } as any)); +>({ x, ...y } = ({ } as any)) : any +>{ x, ...y } = ({ } as any) : any +>{ x, ...y } : any +>x : number +>y : any +>({ } as any) : any +>{ } as any : any +>{ } : {} +} + diff --git a/tests/baselines/reference/destructuringReassignsRightHandSide.js b/tests/baselines/reference/destructuringReassignsRightHandSide.js index bf24fa937b1..0e5cccff64d 100644 --- a/tests/baselines/reference/destructuringReassignsRightHandSide.js +++ b/tests/baselines/reference/destructuringReassignsRightHandSide.js @@ -9,10 +9,10 @@ var bar: any; var { foo, baz } = foo; //// [destructuringReassignsRightHandSide.js] +var _a; var foo = { foo: 1, bar: 2 }; var bar; // reassignment in destructuring pattern -(_b = foo, foo = _b.foo, bar = _b.bar); +(_a = foo, foo = _a.foo, bar = _a.bar); // reassignment in subsequent var -var _a = foo, foo = _a.foo, baz = _a.baz; -var _b; +var _b = foo, foo = _b.foo, baz = _b.baz; diff --git a/tests/baselines/reference/dottedNamesInSystem.js b/tests/baselines/reference/dottedNamesInSystem.js index 257d7e616af..c2a5f7e882a 100644 --- a/tests/baselines/reference/dottedNamesInSystem.js +++ b/tests/baselines/reference/dottedNamesInSystem.js @@ -9,13 +9,13 @@ export function bar() { //// [dottedNamesInSystem.js] System.register([], function (exports_1, context_1) { + var A; "use strict"; var __moduleName = context_1 && context_1.id; function bar() { return A.B.C.foo(); } exports_1("bar", bar); - var A; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/doubleMixinConditionalTypeBaseClassWorks.types b/tests/baselines/reference/doubleMixinConditionalTypeBaseClassWorks.types index 5fd92f6e2eb..7fbf4e36586 100644 --- a/tests/baselines/reference/doubleMixinConditionalTypeBaseClassWorks.types +++ b/tests/baselines/reference/doubleMixinConditionalTypeBaseClassWorks.types @@ -4,39 +4,39 @@ type Constructor = new (...args: any[]) => {}; >args : any[] const Mixin1 = (Base: C) => class extends Base { private _fooPrivate: {}; } ->Mixin1 : (Base: C) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & C ->(Base: C) => class extends Base { private _fooPrivate: {}; } : (Base: C) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & C +>Mixin1 : (Base: C) => { new (...args: any[]): (Anonymous class); prototype: Mixin1.(Anonymous class); } & C +>(Base: C) => class extends Base { private _fooPrivate: {}; } : (Base: C) => { new (...args: any[]): (Anonymous class); prototype: Mixin1.(Anonymous class); } & C >C : C >Constructor : Constructor >Base : C >C : C ->class extends Base { private _fooPrivate: {}; } : { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & C +>class extends Base { private _fooPrivate: {}; } : { new (...args: any[]): (Anonymous class); prototype: Mixin1.(Anonymous class); } & C >Base : {} >_fooPrivate : {} type FooConstructor = typeof Mixin1 extends (a: Constructor) => infer Cls ? Cls : never; ->FooConstructor : { new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); } & Constructor ->Mixin1 : (Base: C) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & C +>FooConstructor : { new (...args: any[]): Mixin1.(Anonymous class); prototype: Mixin1.(Anonymous class); } & Constructor +>Mixin1 : (Base: C) => { new (...args: any[]): (Anonymous class); prototype: Mixin1.(Anonymous class); } & C >a : Constructor >Constructor : Constructor >Cls : Cls >Cls : Cls const Mixin2 = (Base: C) => class extends Base {}; ->Mixin2 : .(Anonymous class); prototype: .(Anonymous class); } & Constructor>(Base: C) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & C ->(Base: C) => class extends Base {} : .(Anonymous class); prototype: .(Anonymous class); } & Constructor>(Base: C) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & C +>Mixin2 : .(Anonymous class); prototype: Mixin1.(Anonymous class); } & Constructor>(Base: C) => { new (...args: any[]): (Anonymous class); prototype: Mixin2.(Anonymous class); } & C +>(Base: C) => class extends Base {} : .(Anonymous class); prototype: Mixin1.(Anonymous class); } & Constructor>(Base: C) => { new (...args: any[]): (Anonymous class); prototype: Mixin2.(Anonymous class); } & C >C : C ->FooConstructor : { new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); } & Constructor +>FooConstructor : { new (...args: any[]): Mixin1.(Anonymous class); prototype: Mixin1.(Anonymous class); } & Constructor >Base : C >C : C ->class extends Base {} : { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & C ->Base : .(Anonymous class) +>class extends Base {} : { new (...args: any[]): (Anonymous class); prototype: Mixin2.(Anonymous class); } & C +>Base : Mixin1.(Anonymous class) class C extends Mixin2(Mixin1(Object)) {} >C : C ->Mixin2(Mixin1(Object)) : <{ new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); } & ObjectConstructor>.(Anonymous class) & .(Anonymous class) & Object ->Mixin2 : .(Anonymous class); prototype: .(Anonymous class); } & Constructor>(Base: C) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & C ->Mixin1(Object) : { new (...args: any[]): .(Anonymous class); prototype: .(Anonymous class); } & ObjectConstructor ->Mixin1 : (Base: C) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & C +>Mixin2(Mixin1(Object)) : Mixin2<{ new (...args: any[]): Mixin1.(Anonymous class); prototype: Mixin1.(Anonymous class); } & ObjectConstructor>.(Anonymous class) & Mixin1.(Anonymous class) & Object +>Mixin2 : .(Anonymous class); prototype: Mixin1.(Anonymous class); } & Constructor>(Base: C) => { new (...args: any[]): (Anonymous class); prototype: Mixin2.(Anonymous class); } & C +>Mixin1(Object) : { new (...args: any[]): Mixin1.(Anonymous class); prototype: Mixin1.(Anonymous class); } & ObjectConstructor +>Mixin1 : (Base: C) => { new (...args: any[]): (Anonymous class); prototype: Mixin1.(Anonymous class); } & C >Object : ObjectConstructor diff --git a/tests/baselines/reference/duplicatePackage.errors.txt b/tests/baselines/reference/duplicatePackage.errors.txt index 917ed711c64..99d5a3f29cc 100644 --- a/tests/baselines/reference/duplicatePackage.errors.txt +++ b/tests/baselines/reference/duplicatePackage.errors.txt @@ -1,4 +1,4 @@ -/src/a.ts(5,3): error TS2345: Argument of type 'X' is not assignable to parameter of type 'X'. +/src/a.ts(5,3): error TS2345: Argument of type 'import("/node_modules/c/node_modules/x/index").default' is not assignable to parameter of type 'import("/node_modules/a/node_modules/x/index").default'. Types have separate declarations of a private property 'x'. @@ -9,7 +9,7 @@ a(b); // Works a(c); // Error, these are from different versions of the library. ~ -!!! error TS2345: Argument of type 'X' is not assignable to parameter of type 'X'. +!!! error TS2345: Argument of type 'import("/node_modules/c/node_modules/x/index").default' is not assignable to parameter of type 'import("/node_modules/a/node_modules/x/index").default'. !!! error TS2345: Types have separate declarations of a private property 'x'. ==== /node_modules/a/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/duplicatePackage.types b/tests/baselines/reference/duplicatePackage.types index 689d7a5c5bc..261b87595b7 100644 --- a/tests/baselines/reference/duplicatePackage.types +++ b/tests/baselines/reference/duplicatePackage.types @@ -1,22 +1,22 @@ === /src/a.ts === import { a } from "a"; ->a : (x: default) => void +>a : (x: import("/node_modules/a/node_modules/x/index").default) => void import { b } from "b"; ->b : default +>b : import("/node_modules/a/node_modules/x/index").default import { c } from "c"; ->c : default +>c : import("/node_modules/c/node_modules/x/index").default a(b); // Works >a(b) : void ->a : (x: default) => void ->b : default +>a : (x: import("/node_modules/a/node_modules/x/index").default) => void +>b : import("/node_modules/a/node_modules/x/index").default a(c); // Error, these are from different versions of the library. >a(c) : void ->a : (x: default) => void ->c : default +>a : (x: import("/node_modules/a/node_modules/x/index").default) => void +>c : import("/node_modules/c/node_modules/x/index").default === /node_modules/a/index.d.ts === import X from "x"; diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json index d592022e2e1..d75683d210f 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json @@ -40,6 +40,7 @@ "File '/node_modules/a/node_modules/foo.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", "File '/node_modules/a/node_modules/foo/index.ts' does not exist.", "File '/node_modules/a/node_modules/foo/index.tsx' does not exist.", "File '/node_modules/a/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.types b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.types index 33931774a1b..e7079388c42 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.types +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.types @@ -1,14 +1,14 @@ === /index.ts === import { use } from "foo/use"; ->use : (o: C) => void +>use : (o: import("/node_modules/foo/index").C) => void import { o } from "a"; ->o : C +>o : import("/node_modules/foo/index").C use(o); >use(o) : void ->use : (o: C) => void ->o : C +>use : (o: import("/node_modules/foo/index").C) => void +>o : import("/node_modules/foo/index").C === /node_modules/a/node_modules/foo/index.d.ts === export class C { diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json index 108873d70f9..7b07ecd66e4 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json @@ -40,6 +40,7 @@ "File '/node_modules/a/node_modules/@foo/bar.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", "File '/node_modules/a/node_modules/@foo/bar/index.ts' does not exist.", "File '/node_modules/a/node_modules/@foo/bar/index.tsx' does not exist.", "File '/node_modules/a/node_modules/@foo/bar/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.types b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.types index 7be2442bf3b..e38678b7acf 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.types +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.types @@ -1,14 +1,14 @@ === /index.ts === import { use } from "@foo/bar/use"; ->use : (o: C) => void +>use : (o: import("/node_modules/@foo/bar/index").C) => void import { o } from "a"; ->o : C +>o : import("/node_modules/@foo/bar/index").C use(o); >use(o) : void ->use : (o: C) => void ->o : C +>use : (o: import("/node_modules/@foo/bar/index").C) => void +>o : import("/node_modules/@foo/bar/index").C === /node_modules/a/node_modules/@foo/bar/index.d.ts === export class C { diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js index 4f79e0caec1..cace97fcc2e 100644 --- a/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js @@ -29,8 +29,8 @@ c.dynamic(); this._path = './other'; } dynamic() { - return _a = this._path, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); }); var _a; + return _a = this._path, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); }); } } const c = new C(); diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es5.js b/tests/baselines/reference/dynamicImportWithNestedThis_es5.js index fcfde9e9887..39fa9fea4a7 100644 --- a/tests/baselines/reference/dynamicImportWithNestedThis_es5.js +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es5.js @@ -29,9 +29,9 @@ c.dynamic(); this._path = './other'; } C.prototype.dynamic = function () { + var _a; var _this = this; return _a = this._path, __syncRequire ? Promise.resolve().then(function () { return require(_a); }) : new Promise(function (resolve_1, reject_1) { require([_a], resolve_1, reject_1); }); - var _a; }; return C; }()); diff --git a/tests/baselines/reference/dynamicNames.types b/tests/baselines/reference/dynamicNames.types index 8535d7454a1..174aff77424 100644 --- a/tests/baselines/reference/dynamicNames.types +++ b/tests/baselines/reference/dynamicNames.types @@ -213,7 +213,7 @@ declare class T10 extends T9 { >T9 : T9 } declare type T11 = { ->T11 : { [c4]: number; [c5]: string; [s2]: boolean; } +>T11 : T11 [c4]: number; >[c4] : number @@ -261,7 +261,7 @@ declare class T14 extends T13 { >T13 : T13 } declare type T15 = { ->T15 : { a: number; 1: string; [s2]: boolean; } +>T15 : T15 a: number; >a : number @@ -341,9 +341,9 @@ let t6: N.T6; >T6 : N.T6 let t7: N.T7; ->t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t7 : N.T7 >N : any ->T7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>T7 : N.T7 let t8: T8; >t8 : T8 @@ -358,8 +358,8 @@ let t10: T10; >T10 : T10 let t11: T11; ->t11 : { [c4]: number; [c5]: string; [s2]: boolean; } ->T11 : { [c4]: number; [c5]: string; [s2]: boolean; } +>t11 : T11 +>T11 : T11 let t12: T12; >t12 : T12 @@ -374,8 +374,8 @@ let t14: T14; >T14 : T14 let t15: T15; ->t15 : { a: number; 1: string; [s2]: boolean; } ->T15 : { a: number; 1: string; [s2]: boolean; } +>t15 : T15 +>T15 : T15 // assignability t0 = t1, t0 = t2, t0 = t3, t1 = t0, t1 = t2, t1 = t3, t2 = t0, t2 = t1, t2 = t3, t3 = t0, t3 = t1, t3 = t2; @@ -431,13 +431,13 @@ t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5, t7 = t6 : N.T6 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4, t7 = t5 : N.T5 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, t7 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7 : N.T7 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5 : N.T5 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7 : N.T7 >t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6 : N.T6 >t4 = t5, t4 = t6, t4 = t7, t5 = t4 : N.T4 ->t4 = t5, t4 = t6, t4 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t4 = t5, t4 = t6, t4 = t7 : N.T7 >t4 = t5, t4 = t6 : N.T6 >t4 = t5 : N.T5 >t4 : N.T4 @@ -445,35 +445,35 @@ t4 = t5, t4 = t6, t4 = t7, t5 = t4, t5 = t6, t5 = t7, t6 = t4, t6 = t5, t6 = t7, >t4 = t6 : N.T6 >t4 : N.T4 >t6 : N.T6 ->t4 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t4 = t7 : N.T7 >t4 : N.T4 ->t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t7 : N.T7 >t5 = t4 : N.T4 >t5 : N.T5 >t4 : N.T4 >t5 = t6 : N.T6 >t5 : N.T5 >t6 : N.T6 ->t5 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t5 = t7 : N.T7 >t5 : N.T5 ->t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t7 : N.T7 >t6 = t4 : N.T4 >t6 : N.T6 >t4 : N.T4 >t6 = t5 : N.T5 >t6 : N.T6 >t5 : N.T5 ->t6 = t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t6 = t7 : N.T7 >t6 : N.T6 ->t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t7 : N.T7 >t7 = t4 : N.T4 ->t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t7 : N.T7 >t4 : N.T4 >t7 = t5 : N.T5 ->t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t7 : N.T7 >t5 : N.T5 >t7 = t6 : N.T6 ->t7 : { [N.c2]: number; [N.c3]: string; [N.s1]: boolean; } +>t7 : N.T7 >t6 : N.T6 t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; @@ -481,7 +481,7 @@ t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; >t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0 : T0 >t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0 : T0 >t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0 : T0 ->t0 = t12, t0 = t13, t0 = t14, t0 = t15 : { a: number; 1: string; [s2]: boolean; } +>t0 = t12, t0 = t13, t0 = t14, t0 = t15 : T15 >t0 = t12, t0 = t13, t0 = t14 : T14 >t0 = t12, t0 = t13 : T13 >t0 = t12 : T12 @@ -493,9 +493,9 @@ t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; >t0 = t14 : T14 >t0 : T0 >t14 : T14 ->t0 = t15 : { a: number; 1: string; [s2]: boolean; } +>t0 = t15 : T15 >t0 : T0 ->t15 : { a: number; 1: string; [s2]: boolean; } +>t15 : T15 >t12 = t0 : T0 >t12 : T12 >t0 : T0 @@ -506,7 +506,7 @@ t0 = t12, t0 = t13, t0 = t14, t0 = t15, t12 = t0, t13 = t0, t14 = t0, t15 = t0; >t14 : T14 >t0 : T0 >t15 = t0 : T0 ->t15 : { a: number; 1: string; [s2]: boolean; } +>t15 : T15 >t0 : T0 t0 = C; // static side diff --git a/tests/baselines/reference/emitClassExpressionInDeclarationFile.js b/tests/baselines/reference/emitClassExpressionInDeclarationFile.js index 53fead2d987..cc8848a1a20 100644 --- a/tests/baselines/reference/emitClassExpressionInDeclarationFile.js +++ b/tests/baselines/reference/emitClassExpressionInDeclarationFile.js @@ -130,3 +130,4 @@ declare const Test_base: { } & typeof FooItem; export declare class Test extends Test_base { } +export {}; diff --git a/tests/baselines/reference/emitClassExpressionInDeclarationFile2.js b/tests/baselines/reference/emitClassExpressionInDeclarationFile2.js index 3f7c5c6eb75..8ef0f902778 100644 --- a/tests/baselines/reference/emitClassExpressionInDeclarationFile2.js +++ b/tests/baselines/reference/emitClassExpressionInDeclarationFile2.js @@ -42,6 +42,7 @@ var __extends = (this && this.__extends) || (function () { }; })(); exports.__esModule = true; +var _a; exports.noPrivates = (_a = /** @class */ (function () { function class_1() { this.p = 12; @@ -84,4 +85,3 @@ exports.Test = Test; var test = new Test(); Test.getTags(); test.tags(); -var _a; diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS1.js b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS1.js index af13c31ab75..e97825c7c6f 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS1.js +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS1.js @@ -16,6 +16,7 @@ var j0 = 0, j1 = 1; array3[j0++] **= array3[j1++] **= array3[j0++] **= 1; //// [emitCompoundExponentiationAssignmentWithIndexingOnLHS1.js] +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; var array0 = [1, 2, 3]; var i0 = 0; (_a = array0)[_b = ++i0] = Math.pow(_a[_b], 2); @@ -28,4 +29,3 @@ var i2 = 0; var array3 = [2, 2, 3]; var j0 = 0, j1 = 1; (_o = array3)[_p = j0++] = Math.pow(_o[_p], (_l = array3)[_m = j1++] = Math.pow(_l[_m], (_j = array3)[_k = j0++] = Math.pow(_j[_k], 1))); -var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS2.js b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS2.js index 37da00f81ce..04f550a0484 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS2.js +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS2.js @@ -12,6 +12,7 @@ foo()[0] **= foo()[0] ** 2; var result_foo3 = foo()[0] **= foo()[0] ** 2; //// [emitCompoundExponentiationAssignmentWithIndexingOnLHS2.js] +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; var globalCounter = 0; function foo() { globalCounter += 1; @@ -23,4 +24,3 @@ var result_foo1 = (_c = foo())[_d = 0] = Math.pow(_c[_d], foo()[0]); var result_foo2 = (_l = foo())[_m = 0] = Math.pow(_l[_m], (_j = foo())[_k = 0] = Math.pow(_j[_k], 2)); (_o = foo())[_p = 0] = Math.pow(_o[_p], Math.pow(foo()[0], 2)); var result_foo3 = (_q = foo())[_r = 0] = Math.pow(_q[_r], Math.pow(foo()[0], 2)); -var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.js b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.js index 6d09af018f1..f12ded9c375 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.js +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.js @@ -13,6 +13,7 @@ object[0] **= object[0] **= 2; object[0] **= object[0] ** 2; //// [emitCompoundExponentiationAssignmentWithIndexingOnLHS3.js] +var _a, _b, _c, _d, _e, _f, _g, _h; var object = { _0: 2, get 0() { @@ -25,4 +26,3 @@ var object = { (_a = object)[_b = 0] = Math.pow(_a[_b], object[0]); (_e = object)[_f = 0] = Math.pow(_e[_f], (_c = object)[_d = 0] = Math.pow(_c[_d], 2)); (_g = object)[_h = 0] = Math.pow(_g[_h], Math.pow(object[0], 2)); -var _a, _b, _c, _d, _e, _f, _g, _h; diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS4.js b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS4.js index 759dac3c194..119049235f3 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS4.js +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS4.js @@ -15,6 +15,7 @@ array1[incrementIdx(array1.length)] **= array1[incrementIdx(array1.length)] **= array1[incrementIdx(array1.length)] **= array1[incrementIdx(array1.length)] ** 2; //// [emitCompoundExponentiationAssignmentWithIndexingOnLHS4.js] +var _a, _b, _c, _d, _e, _f, _g, _h; var globalCounter = 0; function incrementIdx(max) { globalCounter += 1; @@ -25,4 +26,3 @@ var array1 = [1, 2, 3, 4, 5]; (_a = array1)[_b = incrementIdx(array1.length)] = Math.pow(_a[_b], 3); (_e = array1)[_f = incrementIdx(array1.length)] = Math.pow(_e[_f], (_c = array1)[_d = incrementIdx(array1.length)] = Math.pow(_c[_d], 2)); (_g = array1)[_h = incrementIdx(array1.length)] = Math.pow(_g[_h], Math.pow(array1[incrementIdx(array1.length)], 2)); -var _a, _b, _c, _d, _e, _f, _g, _h; diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithPropertyAccessingOnLHS1.js b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithPropertyAccessingOnLHS1.js index 9754f0163c2..82101e32835 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithPropertyAccessingOnLHS1.js +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithPropertyAccessingOnLHS1.js @@ -12,6 +12,7 @@ foo().prop **= foo().prop ** 2; var result2 = foo().prop **= foo().prop ** 2; //// [emitCompoundExponentiationAssignmentWithPropertyAccessingOnLHS1.js] +var _a, _b, _c, _d, _e, _f, _g, _h; var globalCounter = 0; function foo() { globalCounter += 1; @@ -23,4 +24,3 @@ var result0 = (_b = foo()).prop = Math.pow(_b.prop, 2); var result1 = (_f = foo()).prop = Math.pow(_f.prop, (_e = foo()).prop = Math.pow(_e.prop, 2)); (_g = foo()).prop = Math.pow(_g.prop, Math.pow(foo().prop, 2)); var result2 = (_h = foo()).prop = Math.pow(_h.prop, Math.pow(foo().prop, 2)); -var _a, _b, _c, _d, _e, _f, _g, _h; diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js index 58dbe061d18..821bd29afab 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.js @@ -68,7 +68,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -87,7 +87,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -107,7 +107,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -122,14 +122,16 @@ class C3 { //// [C4.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); @@ -137,7 +139,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -157,20 +159,22 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; class C5 { f() { @@ -187,7 +191,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -207,7 +211,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -227,7 +231,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -249,7 +253,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js index 0387225261c..ed20f908dba 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.js @@ -95,7 +95,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -147,7 +147,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -206,7 +206,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -260,14 +260,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); @@ -275,7 +277,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -344,20 +346,22 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __values = (this && this.__values) || function (o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; @@ -431,7 +435,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -489,7 +493,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -541,7 +545,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -606,7 +610,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js index 1d242f4ce6b..c0a16fa076b 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.js @@ -37,7 +37,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -54,7 +54,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -72,7 +72,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -85,14 +85,16 @@ function f3() { //// [F4.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); @@ -100,7 +102,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -118,20 +120,22 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; function f5() { return __asyncGenerator(this, arguments, function* f5_1() { @@ -146,7 +150,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -164,7 +168,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js index 88a39d18cd0..eda35c42755 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.js @@ -64,7 +64,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -111,7 +111,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -165,7 +165,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -214,14 +214,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); @@ -229,7 +231,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -293,20 +295,22 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __values = (this && this.__values) || function (o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; @@ -375,7 +379,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -428,7 +432,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js index 9c964275ff3..890ab5e89b6 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.js @@ -37,7 +37,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -54,7 +54,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -72,7 +72,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -85,14 +85,16 @@ const f3 = function () { //// [F4.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); @@ -100,7 +102,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -118,20 +120,22 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; const f5 = function () { return __asyncGenerator(this, arguments, function* () { @@ -146,7 +150,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -164,7 +168,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js index 969036e96af..80c790a9cdf 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.js @@ -64,7 +64,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -111,7 +111,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -165,7 +165,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -214,14 +214,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); @@ -229,7 +231,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -293,20 +295,22 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __values = (this && this.__values) || function (o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; @@ -375,7 +379,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -428,7 +432,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js index 0f64e788b29..43203397b0f 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.js @@ -51,7 +51,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -70,7 +70,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -90,7 +90,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -105,14 +105,16 @@ const o3 = { //// [O4.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); @@ -120,7 +122,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -140,20 +142,22 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; const o5 = { f() { @@ -170,7 +174,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -190,7 +194,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js index ae217449715..ac2930de783 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.js @@ -78,7 +78,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -127,7 +127,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -183,7 +183,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -234,14 +234,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); @@ -249,7 +251,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -315,20 +317,22 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } }; var __values = (this && this.__values) || function (o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; @@ -399,7 +403,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -454,7 +458,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } diff --git a/tests/baselines/reference/emitter.forAwait.es2015.js b/tests/baselines/reference/emitter.forAwait.es2015.js index 980dc3a8e3b..6a29e7fad0a 100644 --- a/tests/baselines/reference/emitter.forAwait.es2015.js +++ b/tests/baselines/reference/emitter.forAwait.es2015.js @@ -52,11 +52,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; function f1() { return __awaiter(this, void 0, void 0, function* () { + var e_1, _a; let y; try { for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = yield y_1.next(), !y_1_1.done;) { @@ -70,7 +73,6 @@ function f1() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; }); } //// [file2.js] @@ -84,11 +86,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; function f2() { return __awaiter(this, void 0, void 0, function* () { + var e_1, _a; let x, y; try { for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = yield y_1.next(), !y_1_1.done;) { @@ -102,14 +107,15 @@ function f2() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; }); } //// [file3.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { @@ -118,13 +124,14 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; function f3() { return __asyncGenerator(this, arguments, function* f3_1() { + var e_1, _a; let y; try { for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), !y_1_1.done;) { @@ -138,14 +145,15 @@ function f3() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; }); } //// [file4.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { @@ -154,13 +162,14 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; function f4() { return __asyncGenerator(this, arguments, function* f4_1() { + var e_1, _a; let x, y; try { for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), !y_1_1.done;) { @@ -174,7 +183,6 @@ function f4() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; }); } //// [file5.js] @@ -188,12 +196,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; // https://github.com/Microsoft/TypeScript/issues/21363 function f5() { return __awaiter(this, void 0, void 0, function* () { + var e_1, _a; let y; try { outer: for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = yield y_1.next(), !y_1_1.done;) { @@ -208,14 +219,15 @@ function f5() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; }); } //// [file6.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { @@ -224,7 +236,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -232,6 +244,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar // https://github.com/Microsoft/TypeScript/issues/21363 function f6() { return __asyncGenerator(this, arguments, function* f6_1() { + var e_1, _a; let y; try { outer: for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), !y_1_1.done;) { @@ -246,6 +259,5 @@ function f6() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; }); } diff --git a/tests/baselines/reference/emitter.forAwait.es2017.js b/tests/baselines/reference/emitter.forAwait.es2017.js index 9fcf6190990..63e833e81d2 100644 --- a/tests/baselines/reference/emitter.forAwait.es2017.js +++ b/tests/baselines/reference/emitter.forAwait.es2017.js @@ -44,10 +44,13 @@ async function* f6() { //// [file1.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; async function f1() { + var e_1, _a; let y; try { for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = await y_1.next(), !y_1_1.done;) { @@ -61,15 +64,17 @@ async function f1() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; } //// [file2.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; async function f2() { + var e_1, _a; let x, y; try { for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = await y_1.next(), !y_1_1.done;) { @@ -83,13 +88,14 @@ async function f2() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; } //// [file3.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { @@ -98,13 +104,14 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; function f3() { return __asyncGenerator(this, arguments, function* f3_1() { + var e_1, _a; let y; try { for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), !y_1_1.done;) { @@ -118,14 +125,15 @@ function f3() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; }); } //// [file4.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { @@ -134,13 +142,14 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; function f4() { return __asyncGenerator(this, arguments, function* f4_1() { + var e_1, _a; let x, y; try { for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), !y_1_1.done;) { @@ -154,17 +163,19 @@ function f4() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; }); } //// [file5.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; // https://github.com/Microsoft/TypeScript/issues/21363 async function f5() { + var e_1, _a; let y; try { outer: for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = await y_1.next(), !y_1_1.done;) { @@ -179,13 +190,14 @@ async function f5() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; } //// [file6.js] var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { @@ -194,7 +206,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -202,6 +214,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar // https://github.com/Microsoft/TypeScript/issues/21363 function f6() { return __asyncGenerator(this, arguments, function* f6_1() { + var e_1, _a; let y; try { outer: for (var y_1 = __asyncValues(y), y_1_1; y_1_1 = yield __await(y_1.next()), !y_1_1.done;) { @@ -216,6 +229,5 @@ function f6() { } finally { if (e_1) throw e_1.error; } } - var e_1, _a; }); } diff --git a/tests/baselines/reference/emitter.forAwait.es5.js b/tests/baselines/reference/emitter.forAwait.es5.js index 277bc2b4e6b..b40adeb443f 100644 --- a/tests/baselines/reference/emitter.forAwait.es5.js +++ b/tests/baselines/reference/emitter.forAwait.es5.js @@ -79,12 +79,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; function f1() { return __awaiter(this, void 0, void 0, function () { - var y, y_1, y_1_1, x, e_1_1, e_1, _a; + var e_1, _a, y, y_1, y_1_1, x, e_1_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -159,12 +161,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; function f2() { return __awaiter(this, void 0, void 0, function () { - var x, y, y_1, y_1_1, e_1_1, e_1, _a; + var e_1, _a, x, y, y_1, y_1_1, e_1_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -231,8 +235,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { @@ -241,14 +247,14 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; function f3() { return __asyncGenerator(this, arguments, function f3_1() { - var y, y_1, y_1_1, x, e_1_1, e_1, _a; + var e_1, _a, y, y_1, y_1_1, x, e_1_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -316,8 +322,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { @@ -326,14 +334,14 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; function f4() { return __asyncGenerator(this, arguments, function f4_1() { - var x, y, y_1, y_1_1, e_1_1, e_1, _a; + var e_1, _a, x, y, y_1, y_1_1, e_1_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -409,13 +417,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; // https://github.com/Microsoft/TypeScript/issues/21363 function f5() { return __awaiter(this, void 0, void 0, function () { - var y, y_1, y_1_1, x, e_1_1, e_1, _a; + var e_1, _a, y, y_1, y_1_1, x, e_1_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -482,8 +492,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; var __asyncValues = (this && this.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator]; - return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } }; var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { @@ -492,7 +504,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } @@ -500,7 +512,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar // https://github.com/Microsoft/TypeScript/issues/21363 function f6() { return __asyncGenerator(this, arguments, function f6_1() { - var y, y_1, y_1_1, x, e_1_1, e_1, _a; + var e_1, _a, y, y_1, y_1_1, x, e_1_1; return __generator(this, function (_b) { switch (_b.label) { case 0: diff --git a/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.js b/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.js index bcd57cff25c..c16a385691d 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.js +++ b/tests/baselines/reference/emptyAssignmentPatterns02_ES5iterable.js @@ -22,11 +22,11 @@ var __read = (this && this.__read) || function (o, n) { } return ar; }; +var _a; var a; var x, y, z, a1, a2, a3; (x = a.x, y = a.y, z = a.z); (_a = __read(a, 3), a1 = _a[0], a2 = _a[1], a3 = _a[2]); -var _a; //// [emptyAssignmentPatterns02_ES5iterable.d.ts] diff --git a/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.js b/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.js index 36c124be511..dfcd7a80f62 100644 --- a/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.js +++ b/tests/baselines/reference/emptyAssignmentPatterns04_ES5iterable.js @@ -22,11 +22,11 @@ var __read = (this && this.__read) || function (o, n) { } return ar; }; +var _a; var a; var x, y, z, a1, a2, a3; (x = a.x, y = a.y, z = a.z); (_a = __read(a, 3), a1 = _a[0], a2 = _a[1], a3 = _a[2]); -var _a; //// [emptyAssignmentPatterns04_ES5iterable.d.ts] diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.js b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.js index 09d4cb8972b..80b2b04b8f0 100644 --- a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.js +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5iterable.js @@ -104,78 +104,78 @@ var __values = (this && this.__values) || function (o) { } })(); (function () { + var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f; var ns = []; try { for (var ns_1 = __values(ns), ns_1_1 = ns_1.next(); !ns_1_1.done; ns_1_1 = ns_1.next()) { - var _a = ns_1_1.value; + var _g = ns_1_1.value; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (ns_1_1 && !ns_1_1.done && (_g = ns_1.return)) _g.call(ns_1); + if (ns_1_1 && !ns_1_1.done && (_a = ns_1.return)) _a.call(ns_1); } finally { if (e_1) throw e_1.error; } } try { for (var ns_2 = __values(ns), ns_2_1 = ns_2.next(); !ns_2_1.done; ns_2_1 = ns_2.next()) { - var _b = ns_2_1.value; + var _h = ns_2_1.value; } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { - if (ns_2_1 && !ns_2_1.done && (_h = ns_2.return)) _h.call(ns_2); + if (ns_2_1 && !ns_2_1.done && (_b = ns_2.return)) _b.call(ns_2); } finally { if (e_2) throw e_2.error; } } try { for (var ns_3 = __values(ns), ns_3_1 = ns_3.next(); !ns_3_1.done; ns_3_1 = ns_3.next()) { - var _c = ns_3_1.value; + var _j = ns_3_1.value; } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { - if (ns_3_1 && !ns_3_1.done && (_j = ns_3.return)) _j.call(ns_3); + if (ns_3_1 && !ns_3_1.done && (_c = ns_3.return)) _c.call(ns_3); } finally { if (e_3) throw e_3.error; } } try { for (var ns_4 = __values(ns), ns_4_1 = ns_4.next(); !ns_4_1.done; ns_4_1 = ns_4.next()) { - var _d = __read(ns_4_1.value, 0); + var _k = __read(ns_4_1.value, 0); } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { - if (ns_4_1 && !ns_4_1.done && (_k = ns_4.return)) _k.call(ns_4); + if (ns_4_1 && !ns_4_1.done && (_d = ns_4.return)) _d.call(ns_4); } finally { if (e_4) throw e_4.error; } } try { for (var ns_5 = __values(ns), ns_5_1 = ns_5.next(); !ns_5_1.done; ns_5_1 = ns_5.next()) { - var _e = __read(ns_5_1.value, 0); + var _l = __read(ns_5_1.value, 0); } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { - if (ns_5_1 && !ns_5_1.done && (_l = ns_5.return)) _l.call(ns_5); + if (ns_5_1 && !ns_5_1.done && (_e = ns_5.return)) _e.call(ns_5); } finally { if (e_5) throw e_5.error; } } try { for (var ns_6 = __values(ns), ns_6_1 = ns_6.next(); !ns_6_1.done; ns_6_1 = ns_6.next()) { - var _f = __read(ns_6_1.value, 0); + var _m = __read(ns_6_1.value, 0); } } catch (e_6_1) { e_6 = { error: e_6_1 }; } finally { try { - if (ns_6_1 && !ns_6_1.done && (_m = ns_6.return)) _m.call(ns_6); + if (ns_6_1 && !ns_6_1.done && (_f = ns_6.return)) _f.call(ns_6); } finally { if (e_6) throw e_6.error; } } - var e_1, _g, e_2, _h, e_3, _j, e_4, _k, e_5, _l, e_6, _m; })(); diff --git a/tests/baselines/reference/es5-asyncFunctionForOfStatements.js b/tests/baselines/reference/es5-asyncFunctionForOfStatements.js index 9cf1d0098b2..5fbeef0461a 100644 --- a/tests/baselines/reference/es5-asyncFunctionForOfStatements.js +++ b/tests/baselines/reference/es5-asyncFunctionForOfStatements.js @@ -315,7 +315,7 @@ function forOfStatement10() { } function forOfStatement11() { return __awaiter(this, void 0, void 0, function () { - var _i, y_8, _a, _b; + var _a, _i, y_8, _b; return __generator(this, function (_c) { switch (_c.label) { case 0: @@ -323,17 +323,17 @@ function forOfStatement11() { _c.label = 1; case 1: if (!(_i < y_8.length)) return [3 /*break*/, 6]; - _b = y_8[_i][0]; - if (!(_b === void 0)) return [3 /*break*/, 3]; + _a = y_8[_i][0]; + if (!(_a === void 0)) return [3 /*break*/, 3]; return [4 /*yield*/, a]; case 2: - _a = _c.sent(); + _b = _c.sent(); return [3 /*break*/, 4]; case 3: - _a = _b; + _b = _a; _c.label = 4; case 4: - x = _a; + x = _b; z; _c.label = 5; case 5: @@ -346,18 +346,18 @@ function forOfStatement11() { } function forOfStatement12() { return __awaiter(this, void 0, void 0, function () { - var _i, _a, _b; + var _a, _i, _b; return __generator(this, function (_c) { switch (_c.label) { case 0: _i = 0; return [4 /*yield*/, y]; case 1: - _a = _c.sent(); + _b = _c.sent(); _c.label = 2; case 2: - if (!(_i < _a.length)) return [3 /*break*/, 4]; - _b = _a[_i][0], x = _b === void 0 ? a : _b; + if (!(_i < _b.length)) return [3 /*break*/, 4]; + _a = _b[_i][0], x = _a === void 0 ? a : _a; z; _c.label = 3; case 3: @@ -370,7 +370,7 @@ function forOfStatement12() { } function forOfStatement13() { return __awaiter(this, void 0, void 0, function () { - var _i, y_9, _a; + var _a, _i, y_9; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -440,7 +440,7 @@ function forOfStatement15() { } function forOfStatement16() { return __awaiter(this, void 0, void 0, function () { - var _i, y_11, _a, _b; + var _a, _i, y_11, _b; return __generator(this, function (_c) { switch (_c.label) { case 0: @@ -448,17 +448,17 @@ function forOfStatement16() { _c.label = 1; case 1: if (!(_i < y_11.length)) return [3 /*break*/, 6]; - _b = y_11[_i].x; - if (!(_b === void 0)) return [3 /*break*/, 3]; + _a = y_11[_i].x; + if (!(_a === void 0)) return [3 /*break*/, 3]; return [4 /*yield*/, a]; case 2: - _a = _c.sent(); + _b = _c.sent(); return [3 /*break*/, 4]; case 3: - _a = _b; + _b = _a; _c.label = 4; case 4: - x = _a; + x = _b; z; _c.label = 5; case 5: @@ -471,18 +471,18 @@ function forOfStatement16() { } function forOfStatement17() { return __awaiter(this, void 0, void 0, function () { - var _i, _a, _b; + var _a, _i, _b; return __generator(this, function (_c) { switch (_c.label) { case 0: _i = 0; return [4 /*yield*/, y]; case 1: - _a = _c.sent(); + _b = _c.sent(); _c.label = 2; case 2: - if (!(_i < _a.length)) return [3 /*break*/, 4]; - _b = _a[_i].x, x = _b === void 0 ? a : _b; + if (!(_i < _b.length)) return [3 /*break*/, 4]; + _a = _b[_i].x, x = _a === void 0 ? a : _a; z; _c.label = 3; case 3: @@ -495,7 +495,7 @@ function forOfStatement17() { } function forOfStatement18() { return __awaiter(this, void 0, void 0, function () { - var _i, y_12, _a; + var _a, _i, y_12; return __generator(this, function (_b) { switch (_b.label) { case 0: diff --git a/tests/baselines/reference/es5-asyncFunctionObjectLiterals.js b/tests/baselines/reference/es5-asyncFunctionObjectLiterals.js index 8bc90935d37..de1aab50b51 100644 --- a/tests/baselines/reference/es5-asyncFunctionObjectLiterals.js +++ b/tests/baselines/reference/es5-asyncFunctionObjectLiterals.js @@ -109,13 +109,13 @@ function objectLiteral3() { return __generator(this, function (_c) { switch (_c.label) { case 0: - _b = {}; - _a = a; + _a = {}; + _b = a; return [4 /*yield*/, y]; case 1: - x = (_b[_a] = _c.sent(), - _b.b = z, - _b); + x = (_a[_b] = _c.sent(), + _a.b = z, + _a); return [2 /*return*/]; } }); @@ -162,14 +162,14 @@ function objectLiteral6() { return __generator(this, function (_c) { switch (_c.label) { case 0: - _b = { + _a = { a: y }; - _a = b; + _b = b; return [4 /*yield*/, z]; case 1: - x = (_b[_a] = _c.sent(), - _b); + x = (_a[_b] = _c.sent(), + _a); return [2 /*return*/]; } }); diff --git a/tests/baselines/reference/es5-system.js b/tests/baselines/reference/es5-system.js index a46fc19455a..c84b5c9e631 100644 --- a/tests/baselines/reference/es5-system.js +++ b/tests/baselines/reference/es5-system.js @@ -15,9 +15,9 @@ export default class A //// [es5-system.js] System.register([], function (exports_1, context_1) { + var A; "use strict"; var __moduleName = context_1 && context_1.id; - var A; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/es5-system2.js b/tests/baselines/reference/es5-system2.js index 4d793326b9b..bb697216628 100644 --- a/tests/baselines/reference/es5-system2.js +++ b/tests/baselines/reference/es5-system2.js @@ -3,9 +3,9 @@ export var __esModule = 1; //// [es5-system2.js] System.register([], function (exports_1, context_1) { + var __esModule; "use strict"; var __moduleName = context_1 && context_1.id; - var __esModule; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/es5ExportEquals.types b/tests/baselines/reference/es5ExportEquals.types index 6c9e8930537..6f138b0e862 100644 --- a/tests/baselines/reference/es5ExportEquals.types +++ b/tests/baselines/reference/es5ExportEquals.types @@ -1,6 +1,6 @@ === tests/cases/compiler/es5ExportEquals.ts === export function f() { } ->f : typeof f +>f : typeof import("tests/cases/compiler/es5ExportEquals").f export = f; >f : () => void diff --git a/tests/baselines/reference/es6ExportEquals.types b/tests/baselines/reference/es6ExportEquals.types index 3ba761dc8e5..be19f33bac4 100644 --- a/tests/baselines/reference/es6ExportEquals.types +++ b/tests/baselines/reference/es6ExportEquals.types @@ -1,6 +1,6 @@ === tests/cases/compiler/es6ExportEquals.ts === export function f() { } ->f : typeof f +>f : typeof import("tests/cases/compiler/es6ExportEquals").f export = f; >f : () => void diff --git a/tests/baselines/reference/es6modulekindWithES5Target11.js b/tests/baselines/reference/es6modulekindWithES5Target11.js index 67cee76f741..c720e4740d5 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target11.js +++ b/tests/baselines/reference/es6modulekindWithES5Target11.js @@ -22,11 +22,11 @@ var C = /** @class */ (function () { C_1 = C; C.x = function () { return C_1.y; }; C.prototype.method = function () { }; + var C_1; C.y = 1; C = C_1 = __decorate([ foo ], C); return C; - var C_1; }()); export default C; diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target11.js b/tests/baselines/reference/esnextmodulekindWithES5Target11.js index 58b18c4e829..a32ac998065 100644 --- a/tests/baselines/reference/esnextmodulekindWithES5Target11.js +++ b/tests/baselines/reference/esnextmodulekindWithES5Target11.js @@ -22,11 +22,11 @@ var C = /** @class */ (function () { C_1 = C; C.x = function () { return C_1.y; }; C.prototype.method = function () { }; + var C_1; C.y = 1; C = C_1 = __decorate([ foo ], C); return C; - var C_1; }()); export default C; diff --git a/tests/baselines/reference/exportClassExtendingIntersection.js b/tests/baselines/reference/exportClassExtendingIntersection.js index 9b99e90d511..f94696a348c 100644 --- a/tests/baselines/reference/exportClassExtendingIntersection.js +++ b/tests/baselines/reference/exportClassExtendingIntersection.js @@ -114,9 +114,10 @@ export declare function MyMixin>>(base: T //// [FinalClass.d.ts] import { MyBaseClass } from './BaseClass'; import { MyMixin } from './MixinClass'; -declare const MyExtendedClass_base: typeof MyBaseClass & (new (...args: any[]) => MyMixin); +declare const MyExtendedClass_base: typeof MyBaseClass & import("./BaseClass").Constructor; export declare class MyExtendedClass extends MyExtendedClass_base { extendedClassProperty: number; } +export {}; //// [Main.d.ts] export {}; diff --git a/tests/baselines/reference/exportClassExtendingIntersection.types b/tests/baselines/reference/exportClassExtendingIntersection.types index 5840c53a056..6dc2a7fdcf4 100644 --- a/tests/baselines/reference/exportClassExtendingIntersection.types +++ b/tests/baselines/reference/exportClassExtendingIntersection.types @@ -52,12 +52,12 @@ import { MyBaseClass } from './BaseClass'; >MyBaseClass : typeof MyBaseClass import { MyMixin } from './MixinClass'; ->MyMixin : MyBaseClass>(base: T) => T & (new (...args: any[]) => MyMixin) +>MyMixin : >>(base: T) => T & import("tests/cases/compiler/BaseClass").Constructor export class MyExtendedClass extends MyMixin(MyBaseClass) { >MyExtendedClass : MyExtendedClass >MyMixin(MyBaseClass) : MyBaseClass & MyMixin ->MyMixin : MyBaseClass>(base: T) => T & (new (...args: any[]) => MyMixin) +>MyMixin : >>(base: T) => T & import("tests/cases/compiler/BaseClass").Constructor >MyBaseClass : typeof MyBaseClass extendedClassProperty: number; @@ -68,7 +68,7 @@ import { MyExtendedClass } from './FinalClass'; >MyExtendedClass : typeof MyExtendedClass import { MyMixin } from './MixinClass'; ->MyMixin : MyBaseClass>(base: T) => T & (new (...args: any[]) => MyMixin) +>MyMixin : >>(base: T) => T & import("tests/cases/compiler/BaseClass").Constructor const myExtendedClass = new MyExtendedClass('string'); >myExtendedClass : MyExtendedClass @@ -77,8 +77,8 @@ const myExtendedClass = new MyExtendedClass('string'); >'string' : "string" const AnotherMixedClass = MyMixin(MyExtendedClass); ->AnotherMixedClass : typeof MyExtendedClass & (new (...args: any[]) => MyMixin) ->MyMixin(MyExtendedClass) : typeof MyExtendedClass & (new (...args: any[]) => MyMixin) ->MyMixin : MyBaseClass>(base: T) => T & (new (...args: any[]) => MyMixin) +>AnotherMixedClass : typeof MyExtendedClass & import("tests/cases/compiler/BaseClass").Constructor +>MyMixin(MyExtendedClass) : typeof MyExtendedClass & import("tests/cases/compiler/BaseClass").Constructor +>MyMixin : >>(base: T) => T & import("tests/cases/compiler/BaseClass").Constructor >MyExtendedClass : typeof MyExtendedClass diff --git a/tests/baselines/reference/exportDefaultParenthesize.js b/tests/baselines/reference/exportDefaultParenthesize.js index 31fe9b6da3e..aa057a091bd 100644 --- a/tests/baselines/reference/exportDefaultParenthesize.js +++ b/tests/baselines/reference/exportDefaultParenthesize.js @@ -37,6 +37,7 @@ export default () => 42; //// [commalist.js] +var _a; export default (_a = {}, _a['foo' + ''] = 42, _a['foo' + ''] = 42, @@ -62,11 +63,10 @@ export default (_a = {}, _a['foo' + ''] = 42, _a['foo' + ''] = 42, _a); -var _a; //// [comma.js] +var _a; export default (_a = {}, _a['foo'] = 42, _a); -var _a; //// [functionexpression.js] export default (function () { return 42; }); diff --git a/tests/baselines/reference/exportNonInitializedVariablesSystem.js b/tests/baselines/reference/exportNonInitializedVariablesSystem.js index 7755cb4fc36..56d27bfbead 100644 --- a/tests/baselines/reference/exportNonInitializedVariablesSystem.js +++ b/tests/baselines/reference/exportNonInitializedVariablesSystem.js @@ -35,9 +35,9 @@ export let h1: D = new D; //// [exportNonInitializedVariablesSystem.js] System.register([], function (exports_1, context_1) { + var a, b, c, d, A, e, f, B, C, a1, b1, c1, d1, D, e1, f1, g1, h1; "use strict"; var __moduleName = context_1 && context_1.id; - var a, b, c, d, A, e, f, B, C, a1, b1, c1, d1, D, e1, f1, g1, h1; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/exportStarForValues10.js b/tests/baselines/reference/exportStarForValues10.js index e4314c4f7fd..249a633cd07 100644 --- a/tests/baselines/reference/exportStarForValues10.js +++ b/tests/baselines/reference/exportStarForValues10.js @@ -13,9 +13,9 @@ var x = 1; //// [file0.js] System.register([], function (exports_1, context_1) { + var v; "use strict"; var __moduleName = context_1 && context_1.id; - var v; return { setters: [], execute: function () { @@ -35,9 +35,9 @@ System.register([], function (exports_1, context_1) { }); //// [file2.js] System.register(["file0"], function (exports_1, context_1) { + var x; "use strict"; var __moduleName = context_1 && context_1.id; - var x; function exportStar_1(m) { var exports = {}; for (var n in m) { diff --git a/tests/baselines/reference/exportStarForValues6.js b/tests/baselines/reference/exportStarForValues6.js index 15c2324d205..8bf7e91c87a 100644 --- a/tests/baselines/reference/exportStarForValues6.js +++ b/tests/baselines/reference/exportStarForValues6.js @@ -19,9 +19,9 @@ System.register([], function (exports_1, context_1) { }); //// [file2.js] System.register([], function (exports_1, context_1) { + var x; "use strict"; var __moduleName = context_1 && context_1.id; - var x; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/exportStarForValuesInSystem.js b/tests/baselines/reference/exportStarForValuesInSystem.js index 8cd96011199..d5f9c5bac2c 100644 --- a/tests/baselines/reference/exportStarForValuesInSystem.js +++ b/tests/baselines/reference/exportStarForValuesInSystem.js @@ -19,9 +19,9 @@ System.register([], function (exports_1, context_1) { }); //// [file2.js] System.register([], function (exports_1, context_1) { + var x; "use strict"; var __moduleName = context_1 && context_1.id; - var x; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/fuzzy.errors.txt b/tests/baselines/reference/fuzzy.errors.txt index b32f225a33e..c3f05fd7f2f 100644 --- a/tests/baselines/reference/fuzzy.errors.txt +++ b/tests/baselines/reference/fuzzy.errors.txt @@ -4,7 +4,6 @@ tests/cases/compiler/fuzzy.ts(21,13): error TS2322: Type '{ anything: number; on Types of property 'oneI' are incompatible. Type 'this' is not assignable to type 'I'. Type 'C' is not assignable to type 'I'. - Property 'alsoWorks' is missing in type 'C'. 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; }'. @@ -39,7 +38,6 @@ tests/cases/compiler/fuzzy.ts(25,20): error TS2352: Type '{ oneI: this; }' canno !!! 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: Property 'alsoWorks' is missing in type 'C'. } worksToo():R { diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline index e21f677a7ea..d2b26ca48c8 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline @@ -1,6 +1,4 @@ -EmitSkipped: true -Diagnostics: - Exported variable 'foo' has or is using private name 'C'. +EmitSkipped: false FileName : /tests/cases/fourslash/inputFile.js var M; (function (M) { @@ -11,4 +9,10 @@ var M; }()); M.foo = new C(); })(M || (M = {})); +FileName : /tests/cases/fourslash/inputFile.d.ts +declare module M { + class C { + } + var foo: C; +} diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline index 5cc4df243d0..77131f89dd5 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline @@ -1,6 +1,4 @@ -EmitSkipped: true -Diagnostics: - Exported variable 'foo' has or is using private name 'C'. +EmitSkipped: false FileName : /tests/cases/fourslash/inputFile.js define(["require", "exports"], function (require, exports) { "use strict"; @@ -15,4 +13,11 @@ define(["require", "exports"], function (require, exports) { M.foo = new C(); })(M = exports.M || (exports.M = {})); }); +FileName : /tests/cases/fourslash/inputFile.d.ts +class C { +} +export declare module M { + var foo: C; +} +export {}; diff --git a/tests/baselines/reference/giant.types b/tests/baselines/reference/giant.types index b571ea79b81..b67b9c1efd1 100644 --- a/tests/baselines/reference/giant.types +++ b/tests/baselines/reference/giant.types @@ -870,7 +870,7 @@ export interface eI { >pa2 : any } export module eM { ->eM : typeof eM +>eM : typeof import("tests/cases/compiler/giant").eM var V; >V : any diff --git a/tests/baselines/reference/importCallExpression3ESNext.types b/tests/baselines/reference/importCallExpression3ESNext.types index 4d81b4ec331..416574f213e 100644 --- a/tests/baselines/reference/importCallExpression3ESNext.types +++ b/tests/baselines/reference/importCallExpression3ESNext.types @@ -13,12 +13,12 @@ async function foo() { class C extends (await import("./0")).B {} >C : C ->(await import("./0")).B : B +>(await import("./0")).B : import("tests/cases/conformance/dynamicImport/0").B >(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") >await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") >import("./0") : Promise >"./0" : "./0" ->B : typeof B +>B : typeof import("tests/cases/conformance/dynamicImport/0").B var c = new C(); >c : C diff --git a/tests/baselines/reference/importCallExpressionAsyncES3System.js b/tests/baselines/reference/importCallExpressionAsyncES3System.js index c55d8788c98..7f9814e7e96 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3System.js +++ b/tests/baselines/reference/importCallExpressionAsyncES3System.js @@ -30,7 +30,6 @@ export const l = async () => { //// [test.js] System.register([], function (exports_1, context_1) { - "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); } } @@ -66,6 +65,8 @@ System.register([], function (exports_1, context_1) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; + var _this, cl1, obj, cl2, l; + "use strict"; _this = this; var __moduleName = context_1 && context_1.id; function fn() { @@ -83,7 +84,6 @@ System.register([], function (exports_1, context_1) { }); } exports_1("fn", fn); - var _this, cl1, obj, cl2, l; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/importCallExpressionAsyncES5System.js b/tests/baselines/reference/importCallExpressionAsyncES5System.js index b9fad574550..2a3c3629f1b 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5System.js +++ b/tests/baselines/reference/importCallExpressionAsyncES5System.js @@ -30,7 +30,6 @@ export const l = async () => { //// [test.js] System.register([], function (exports_1, context_1) { - "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); } } @@ -66,6 +65,8 @@ System.register([], function (exports_1, context_1) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; + var _this, cl1, obj, cl2, l; + "use strict"; _this = this; var __moduleName = context_1 && context_1.id; function fn() { @@ -83,7 +84,6 @@ System.register([], function (exports_1, context_1) { }); } exports_1("fn", fn); - var _this, cl1, obj, cl2, l; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/importCallExpressionAsyncES6System.js b/tests/baselines/reference/importCallExpressionAsyncES6System.js index 32a9b9028e5..ed771dbb4c0 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6System.js +++ b/tests/baselines/reference/importCallExpressionAsyncES6System.js @@ -30,7 +30,6 @@ export const l = async () => { //// [test.js] System.register([], function (exports_1, context_1) { - "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); } } @@ -39,6 +38,8 @@ System.register([], function (exports_1, context_1) { step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; + var cl1, obj, cl2, l; + "use strict"; var __moduleName = context_1 && context_1.id; function fn() { return __awaiter(this, void 0, void 0, function* () { @@ -46,7 +47,6 @@ System.register([], function (exports_1, context_1) { }); } exports_1("fn", fn); - var cl1, obj, cl2, l; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/importCallExpressionDeclarationEmit2.errors.txt b/tests/baselines/reference/importCallExpressionDeclarationEmit2.errors.txt deleted file mode 100644 index 6c394c98bdf..00000000000 --- a/tests/baselines/reference/importCallExpressionDeclarationEmit2.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/conformance/dynamicImport/1.ts(1,5): error TS4023: Exported variable 'p1' has or is using name '"tests/cases/conformance/dynamicImport/0"' from external module "tests/cases/conformance/dynamicImport/0" but cannot be named. - - -==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== - export function foo() { return "foo"; } - -==== tests/cases/conformance/dynamicImport/1.ts (1 errors) ==== - var p1 = import("./0"); - ~~ -!!! error TS4023: Exported variable 'p1' has or is using name '"tests/cases/conformance/dynamicImport/0"' from external module "tests/cases/conformance/dynamicImport/0" but cannot be named. \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionDeclarationEmit2.js b/tests/baselines/reference/importCallExpressionDeclarationEmit2.js index 7659e94ee81..a83aa5b84c9 100644 --- a/tests/baselines/reference/importCallExpressionDeclarationEmit2.js +++ b/tests/baselines/reference/importCallExpressionDeclarationEmit2.js @@ -14,3 +14,5 @@ var p1 = import("./0"); //// [0.d.ts] export declare function foo(): string; +//// [1.d.ts] +declare var p1: Promise; diff --git a/tests/baselines/reference/importCallExpressionES5System.js b/tests/baselines/reference/importCallExpressionES5System.js index def99752bb1..69c005df3bd 100644 --- a/tests/baselines/reference/importCallExpressionES5System.js +++ b/tests/baselines/reference/importCallExpressionES5System.js @@ -42,12 +42,12 @@ System.register([], function (exports_1, context_1) { }); //// [1.js] System.register([], function (exports_1, context_1) { + var p1, p2, C, D; "use strict"; var __moduleName = context_1 && context_1.id; function foo() { var p2 = context_1.import("./0"); } - var p1, p2, C, D; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/importCallExpressionES6System.js b/tests/baselines/reference/importCallExpressionES6System.js index 0676e4cd559..abf8ff507ed 100644 --- a/tests/baselines/reference/importCallExpressionES6System.js +++ b/tests/baselines/reference/importCallExpressionES6System.js @@ -42,12 +42,12 @@ System.register([], function (exports_1, context_1) { }); //// [1.js] System.register([], function (exports_1, context_1) { + var p1, p2, C, D; "use strict"; var __moduleName = context_1 && context_1.id; function foo() { const p2 = context_1.import("./0"); } - var p1, p2, C, D; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt index d47980d1312..b2000f9319e 100644 --- a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt +++ b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. -tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. -tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. +tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. +tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. ==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== @@ -9,10 +9,10 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic import c ==== tests/cases/conformance/dynamicImport/1.ts (3 errors) ==== import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +!!! error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. var p1 = import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +!!! error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. p1.then(zero => { return zero.foo(); }) @@ -20,5 +20,5 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic import c function foo() { const p2 = import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +!!! error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionInAMD3.types b/tests/baselines/reference/importCallExpressionInAMD3.types index 4d81b4ec331..416574f213e 100644 --- a/tests/baselines/reference/importCallExpressionInAMD3.types +++ b/tests/baselines/reference/importCallExpressionInAMD3.types @@ -13,12 +13,12 @@ async function foo() { class C extends (await import("./0")).B {} >C : C ->(await import("./0")).B : B +>(await import("./0")).B : import("tests/cases/conformance/dynamicImport/0").B >(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") >await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") >import("./0") : Promise >"./0" : "./0" ->B : typeof B +>B : typeof import("tests/cases/conformance/dynamicImport/0").B var c = new C(); >c : C diff --git a/tests/baselines/reference/importCallExpressionInCJS4.types b/tests/baselines/reference/importCallExpressionInCJS4.types index 4d81b4ec331..416574f213e 100644 --- a/tests/baselines/reference/importCallExpressionInCJS4.types +++ b/tests/baselines/reference/importCallExpressionInCJS4.types @@ -13,12 +13,12 @@ async function foo() { class C extends (await import("./0")).B {} >C : C ->(await import("./0")).B : B +>(await import("./0")).B : import("tests/cases/conformance/dynamicImport/0").B >(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") >await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") >import("./0") : Promise >"./0" : "./0" ->B : typeof B +>B : typeof import("tests/cases/conformance/dynamicImport/0").B var c = new C(); >c : C diff --git a/tests/baselines/reference/importCallExpressionInSystem1.js b/tests/baselines/reference/importCallExpressionInSystem1.js index 74df68fc9a1..237ca312b88 100644 --- a/tests/baselines/reference/importCallExpressionInSystem1.js +++ b/tests/baselines/reference/importCallExpressionInSystem1.js @@ -30,12 +30,12 @@ System.register([], function (exports_1, context_1) { }); //// [1.js] System.register([], function (exports_1, context_1) { + var p1, p2; "use strict"; var __moduleName = context_1 && context_1.id; function foo() { const p2 = context_1.import("./0"); } - var p1, p2; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/importCallExpressionInSystem2.js b/tests/baselines/reference/importCallExpressionInSystem2.js index ea84e47e63c..b64632bc9db 100644 --- a/tests/baselines/reference/importCallExpressionInSystem2.js +++ b/tests/baselines/reference/importCallExpressionInSystem2.js @@ -18,9 +18,9 @@ foo(import("./0")); //// [0.js] System.register([], function (exports_1, context_1) { + var B; "use strict"; var __moduleName = context_1 && context_1.id; - var B; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/importCallExpressionInSystem3.js b/tests/baselines/reference/importCallExpressionInSystem3.js index 309be9114fe..89bee947662 100644 --- a/tests/baselines/reference/importCallExpressionInSystem3.js +++ b/tests/baselines/reference/importCallExpressionInSystem3.js @@ -15,9 +15,9 @@ foo(); //// [0.js] System.register([], function (exports_1, context_1) { + var B; "use strict"; var __moduleName = context_1 && context_1.id; - var B; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/importCallExpressionInSystem3.types b/tests/baselines/reference/importCallExpressionInSystem3.types index 4d81b4ec331..416574f213e 100644 --- a/tests/baselines/reference/importCallExpressionInSystem3.types +++ b/tests/baselines/reference/importCallExpressionInSystem3.types @@ -13,12 +13,12 @@ async function foo() { class C extends (await import("./0")).B {} >C : C ->(await import("./0")).B : B +>(await import("./0")).B : import("tests/cases/conformance/dynamicImport/0").B >(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") >await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") >import("./0") : Promise >"./0" : "./0" ->B : typeof B +>B : typeof import("tests/cases/conformance/dynamicImport/0").B var c = new C(); >c : C diff --git a/tests/baselines/reference/importCallExpressionInSystem4.js b/tests/baselines/reference/importCallExpressionInSystem4.js index b7bc1f51fe5..dd2f9faadc8 100644 --- a/tests/baselines/reference/importCallExpressionInSystem4.js +++ b/tests/baselines/reference/importCallExpressionInSystem4.js @@ -42,11 +42,11 @@ export class D { //// [0.js] System.register([], function (exports_1, context_1) { + var B; "use strict"; var __moduleName = context_1 && context_1.id; function foo() { return "foo"; } exports_1("foo", foo); - var B; return { setters: [], execute: function () { @@ -71,9 +71,9 @@ System.register([], function (exports_1, context_1) { }); //// [2.js] System.register([], function (exports_1, context_1) { + var C, D; "use strict"; var __moduleName = context_1 && context_1.id; - var C, D; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/importCallExpressionInUMD3.types b/tests/baselines/reference/importCallExpressionInUMD3.types index 4d81b4ec331..416574f213e 100644 --- a/tests/baselines/reference/importCallExpressionInUMD3.types +++ b/tests/baselines/reference/importCallExpressionInUMD3.types @@ -13,12 +13,12 @@ async function foo() { class C extends (await import("./0")).B {} >C : C ->(await import("./0")).B : B +>(await import("./0")).B : import("tests/cases/conformance/dynamicImport/0").B >(await import("./0")) : typeof import("tests/cases/conformance/dynamicImport/0") >await import("./0") : typeof import("tests/cases/conformance/dynamicImport/0") >import("./0") : Promise >"./0" : "./0" ->B : typeof B +>B : typeof import("tests/cases/conformance/dynamicImport/0").B var c = new C(); >c : C diff --git a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt index 1208dd0c709..ef1a96ee913 100644 --- a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt +++ b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. -tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. +tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo async function foo() { return await import((await import("./foo")).default); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +!!! error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. ~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +!!! error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt index 1208dd0c709..ef1a96ee913 100644 --- a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt +++ b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. -tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. +tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo async function foo() { return await import((await import("./foo")).default); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +!!! error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. ~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules. +!!! error TS1323: Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionNestedUMD.js b/tests/baselines/reference/importCallExpressionNestedUMD.js index 0b1d20af8a4..c61e35c3399 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD.js +++ b/tests/baselines/reference/importCallExpressionNestedUMD.js @@ -44,8 +44,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge var __syncRequire = typeof module === "object" && typeof module.exports === "object"; function foo() { return __awaiter(this, void 0, void 0, function* () { - return yield _a = (yield __syncRequire ? Promise.resolve().then(() => require("./foo")) : new Promise((resolve_1, reject_1) => { require(["./foo"], resolve_1, reject_1); })).default, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_2, reject_2) => { require([_a], resolve_2, reject_2); }); var _a; + return yield _a = (yield __syncRequire ? Promise.resolve().then(() => require("./foo")) : new Promise((resolve_1, reject_1) => { require(["./foo"], resolve_1, reject_1); })).default, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_2, reject_2) => { require([_a], resolve_2, reject_2); }); }); } }); diff --git a/tests/baselines/reference/importCallExpressionNestedUMD2.js b/tests/baselines/reference/importCallExpressionNestedUMD2.js index 86fd0bfa8f1..aba25f20d31 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD2.js +++ b/tests/baselines/reference/importCallExpressionNestedUMD2.js @@ -72,12 +72,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function foo() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + var _b; switch (_a.label) { case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require("./foo"); }) : new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); })]; case 1: return [4 /*yield*/, (_b = (_a.sent()).default, __syncRequire ? Promise.resolve().then(function () { return require(_b); }) : new Promise(function (resolve_2, reject_2) { require([_b], resolve_2, reject_2); }))]; case 2: return [2 /*return*/, _a.sent()]; } - var _b; }); }); } diff --git a/tests/baselines/reference/importHelpersSystem.js b/tests/baselines/reference/importHelpersSystem.js index 9392833f6f4..6e29369b842 100644 --- a/tests/baselines/reference/importHelpersSystem.js +++ b/tests/baselines/reference/importHelpersSystem.js @@ -19,9 +19,9 @@ export declare function __awaiter(thisArg: any, _arguments: any, P: Function, ge //// [a.js] System.register([], function (exports_1, context_1) { + var A; "use strict"; var __moduleName = context_1 && context_1.id; - var A; return { setters: [], execute: function () { @@ -36,9 +36,9 @@ System.register([], function (exports_1, context_1) { }); //// [b.js] System.register(["tslib", "./a"], function (exports_1, context_1) { + var tslib_1, a_1, B; "use strict"; var __moduleName = context_1 && context_1.id; - var tslib_1, a_1, B; var exportedNames_1 = { "B": true }; diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js index a1316dbdd46..bb453e398b2 100644 --- a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.js @@ -21,6 +21,4 @@ exports.thing = umd_1.makeThing(); //// [index.d.ts] -export declare const thing: { - a: number; -}; +export declare const thing: import("./node_modules/umd").Thing; diff --git a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types index c12cd511cb9..c0db43ab660 100644 --- a/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types +++ b/tests/baselines/reference/importShouldNotBeElidedInDeclarationEmit.types @@ -15,10 +15,10 @@ export declare function makeThing(): Thing; === tests/cases/compiler/index.ts === import { makeThing } from "umd"; ->makeThing : () => { a: number; } +>makeThing : () => import("tests/cases/compiler/node_modules/umd").Thing export const thing = makeThing(); ->thing : { a: number; } ->makeThing() : { a: number; } ->makeThing : () => { a: number; } +>thing : import("tests/cases/compiler/node_modules/umd").Thing +>makeThing() : import("tests/cases/compiler/node_modules/umd").Thing +>makeThing : () => import("tests/cases/compiler/node_modules/umd").Thing diff --git a/tests/baselines/reference/indexedAccessTypeConstraints.types b/tests/baselines/reference/indexedAccessTypeConstraints.types index dad5fd7d617..f2002aff900 100644 --- a/tests/baselines/reference/indexedAccessTypeConstraints.types +++ b/tests/baselines/reference/indexedAccessTypeConstraints.types @@ -11,7 +11,7 @@ interface IData { } type Data = { ->Data : { get: (prop: K) => T[K]; } +>Data : Data >T : T get: (prop: K) => T[K]; @@ -30,19 +30,19 @@ class Parent { >M : M constructor(private data: Data) {} ->data : { get: (prop: K) => M[K]; } ->Data : { get: (prop: K) => T[K]; } +>data : Data +>Data : Data >M : M getData(): Data { ->getData : () => { get: (prop: K) => M[K]; } ->Data : { get: (prop: K) => T[K]; } +>getData : () => Data +>Data : Data >M : M return this.data; ->this.data : { get: (prop: K) => M[K]; } +>this.data : Data >this : this ->data : { get: (prop: K) => M[K]; } +>data : Data } } @@ -60,10 +60,10 @@ export class Foo extends Parent> { return this.getData().get('content'); >this.getData().get('content') : C >this.getData().get : (prop: K) => IData[K] ->this.getData() : { get: (prop: K) => IData[K]; } ->this.getData : () => { get: (prop: K) => IData[K]; } +>this.getData() : Data> +>this.getData : () => Data> >this : this ->getData : () => { get: (prop: K) => IData[K]; } +>getData : () => Data> >get : (prop: K) => IData[K] >'content' : "content" } @@ -85,10 +85,10 @@ export class Bar> extends Parent { return this.getData().get('content'); >this.getData().get('content') : T["content"] >this.getData().get : (prop: K) => T[K] ->this.getData() : { get: (prop: K) => T[K]; } ->this.getData : () => { get: (prop: K) => T[K]; } +>this.getData() : Data +>this.getData : () => Data >this : this ->getData : () => { get: (prop: K) => T[K]; } +>getData : () => Data >get : (prop: K) => T[K] >'content' : "content" } diff --git a/tests/baselines/reference/inferredNonidentifierTypesGetQuotes.js b/tests/baselines/reference/inferredNonidentifierTypesGetQuotes.js index e9ce8e56d1f..bcfcd9dc18d 100644 --- a/tests/baselines/reference/inferredNonidentifierTypesGetQuotes.js +++ b/tests/baselines/reference/inferredNonidentifierTypesGetQuotes.js @@ -4,9 +4,9 @@ var x = [{ "a-b": "string" }, {}]; var y = [{ ["a-b"]: "string" }, {}]; //// [inferredNonidentifierTypesGetQuotes.js] +var _a; var x = [{ "a-b": "string" }, {}]; var y = [(_a = {}, _a["a-b"] = "string", _a), {}]; -var _a; //// [inferredNonidentifierTypesGetQuotes.d.ts] diff --git a/tests/baselines/reference/intersectionsOfLargeUnions.errors.txt b/tests/baselines/reference/intersectionsOfLargeUnions.errors.txt new file mode 100644 index 00000000000..b5911f646c7 --- /dev/null +++ b/tests/baselines/reference/intersectionsOfLargeUnions.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/intersectionsOfLargeUnions.ts(21,15): error TS2536: Type 'T' cannot be used to index type 'HTMLElementTagNameMap'. +tests/cases/compiler/intersectionsOfLargeUnions.ts(21,15): error TS2536: Type 'P' cannot be used to index type 'HTMLElementTagNameMap[T]'. + + +==== tests/cases/compiler/intersectionsOfLargeUnions.ts (2 errors) ==== + // Repro from #23977 + + export function assertIsElement(node: Node | null): node is Element { + let nodeType = node === null ? null : node.nodeType; + return nodeType === 1; + } + + export function assertNodeTagName< + T extends keyof ElementTagNameMap, + U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U { + if (assertIsElement(node)) { + const nodeTagName = node.tagName.toLowerCase(); + return nodeTagName === tagName; + } + return false; + } + + export function assertNodeProperty< + T extends keyof ElementTagNameMap, + P extends keyof ElementTagNameMap[T], + V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) { + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2536: Type 'T' cannot be used to index type 'HTMLElementTagNameMap'. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2536: Type 'P' cannot be used to index type 'HTMLElementTagNameMap[T]'. + if (assertNodeTagName(node, tagName)) { + node[prop]; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/intersectionsOfLargeUnions.js b/tests/baselines/reference/intersectionsOfLargeUnions.js new file mode 100644 index 00000000000..bd3b98daf01 --- /dev/null +++ b/tests/baselines/reference/intersectionsOfLargeUnions.js @@ -0,0 +1,51 @@ +//// [intersectionsOfLargeUnions.ts] +// Repro from #23977 + +export function assertIsElement(node: Node | null): node is Element { + let nodeType = node === null ? null : node.nodeType; + return nodeType === 1; +} + +export function assertNodeTagName< + T extends keyof ElementTagNameMap, + U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U { + if (assertIsElement(node)) { + const nodeTagName = node.tagName.toLowerCase(); + return nodeTagName === tagName; + } + return false; +} + +export function assertNodeProperty< + T extends keyof ElementTagNameMap, + P extends keyof ElementTagNameMap[T], + V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) { + if (assertNodeTagName(node, tagName)) { + node[prop]; + } +} + + +//// [intersectionsOfLargeUnions.js] +"use strict"; +// Repro from #23977 +exports.__esModule = true; +function assertIsElement(node) { + var nodeType = node === null ? null : node.nodeType; + return nodeType === 1; +} +exports.assertIsElement = assertIsElement; +function assertNodeTagName(node, tagName) { + if (assertIsElement(node)) { + var nodeTagName = node.tagName.toLowerCase(); + return nodeTagName === tagName; + } + return false; +} +exports.assertNodeTagName = assertNodeTagName; +function assertNodeProperty(node, tagName, prop, value) { + if (assertNodeTagName(node, tagName)) { + node[prop]; + } +} +exports.assertNodeProperty = assertNodeProperty; diff --git a/tests/baselines/reference/intersectionsOfLargeUnions.symbols b/tests/baselines/reference/intersectionsOfLargeUnions.symbols new file mode 100644 index 00000000000..02bcce61609 --- /dev/null +++ b/tests/baselines/reference/intersectionsOfLargeUnions.symbols @@ -0,0 +1,95 @@ +=== tests/cases/compiler/intersectionsOfLargeUnions.ts === +// Repro from #23977 + +export function assertIsElement(node: Node | null): node is Element { +>assertIsElement : Symbol(assertIsElement, Decl(intersectionsOfLargeUnions.ts, 0, 0)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32)) +>Node : Symbol(Node, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32)) +>Element : Symbol(Element, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + let nodeType = node === null ? null : node.nodeType; +>nodeType : Symbol(nodeType, Decl(intersectionsOfLargeUnions.ts, 3, 7)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32)) +>node.nodeType : Symbol(Node.nodeType, Decl(lib.d.ts, --, --)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32)) +>nodeType : Symbol(Node.nodeType, Decl(lib.d.ts, --, --)) + + return nodeType === 1; +>nodeType : Symbol(nodeType, Decl(intersectionsOfLargeUnions.ts, 3, 7)) +} + +export function assertNodeTagName< +>assertNodeTagName : Symbol(assertNodeTagName, Decl(intersectionsOfLargeUnions.ts, 5, 1)) + + T extends keyof ElementTagNameMap, +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 7, 34)) +>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --)) + + U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U { +>U : Symbol(U, Decl(intersectionsOfLargeUnions.ts, 8, 38)) +>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 7, 34)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36)) +>Node : Symbol(Node, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 9, 54)) +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 7, 34)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36)) +>U : Symbol(U, Decl(intersectionsOfLargeUnions.ts, 8, 38)) + + if (assertIsElement(node)) { +>assertIsElement : Symbol(assertIsElement, Decl(intersectionsOfLargeUnions.ts, 0, 0)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36)) + + const nodeTagName = node.tagName.toLowerCase(); +>nodeTagName : Symbol(nodeTagName, Decl(intersectionsOfLargeUnions.ts, 11, 13)) +>node.tagName.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) +>node.tagName : Symbol(Element.tagName, Decl(lib.d.ts, --, --)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36)) +>tagName : Symbol(Element.tagName, Decl(lib.d.ts, --, --)) +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) + + return nodeTagName === tagName; +>nodeTagName : Symbol(nodeTagName, Decl(intersectionsOfLargeUnions.ts, 11, 13)) +>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 9, 54)) + } + return false; +} + +export function assertNodeProperty< +>assertNodeProperty : Symbol(assertNodeProperty, Decl(intersectionsOfLargeUnions.ts, 15, 1)) + + T extends keyof ElementTagNameMap, +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35)) +>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --)) + + P extends keyof ElementTagNameMap[T], +>P : Symbol(P, Decl(intersectionsOfLargeUnions.ts, 18, 38)) +>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35)) + + V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) { +>V : Symbol(V, Decl(intersectionsOfLargeUnions.ts, 19, 41)) +>HTMLElementTagNameMap : Symbol(HTMLElementTagNameMap, Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35)) +>P : Symbol(P, Decl(intersectionsOfLargeUnions.ts, 18, 38)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 20, 43)) +>Node : Symbol(Node, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 20, 61)) +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35)) +>prop : Symbol(prop, Decl(intersectionsOfLargeUnions.ts, 20, 73)) +>P : Symbol(P, Decl(intersectionsOfLargeUnions.ts, 18, 38)) +>value : Symbol(value, Decl(intersectionsOfLargeUnions.ts, 20, 82)) +>V : Symbol(V, Decl(intersectionsOfLargeUnions.ts, 19, 41)) + + if (assertNodeTagName(node, tagName)) { +>assertNodeTagName : Symbol(assertNodeTagName, Decl(intersectionsOfLargeUnions.ts, 5, 1)) +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 20, 43)) +>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 20, 61)) + + node[prop]; +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 20, 43)) +>prop : Symbol(prop, Decl(intersectionsOfLargeUnions.ts, 20, 73)) + } +} + diff --git a/tests/baselines/reference/intersectionsOfLargeUnions.types b/tests/baselines/reference/intersectionsOfLargeUnions.types new file mode 100644 index 00000000000..4deef4a4ecf --- /dev/null +++ b/tests/baselines/reference/intersectionsOfLargeUnions.types @@ -0,0 +1,110 @@ +=== tests/cases/compiler/intersectionsOfLargeUnions.ts === +// Repro from #23977 + +export function assertIsElement(node: Node | null): node is Element { +>assertIsElement : (node: Node | null) => node is Element +>node : Node | null +>Node : Node +>null : null +>node : any +>Element : Element + + let nodeType = node === null ? null : node.nodeType; +>nodeType : number | null +>node === null ? null : node.nodeType : number | null +>node === null : boolean +>node : Node | null +>null : null +>null : null +>node.nodeType : number +>node : Node +>nodeType : number + + return nodeType === 1; +>nodeType === 1 : boolean +>nodeType : number | null +>1 : 1 +} + +export function assertNodeTagName< +>assertNodeTagName : (node: Node | null, tagName: T) => node is U + + T extends keyof ElementTagNameMap, +>T : T +>ElementTagNameMap : ElementTagNameMap + + U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U { +>U : U +>ElementTagNameMap : ElementTagNameMap +>T : T +>node : Node | null +>Node : Node +>null : null +>tagName : T +>T : T +>node : any +>U : U + + if (assertIsElement(node)) { +>assertIsElement(node) : boolean +>assertIsElement : (node: Node | null) => node is Element +>node : Node | null + + const nodeTagName = node.tagName.toLowerCase(); +>nodeTagName : string +>node.tagName.toLowerCase() : string +>node.tagName.toLowerCase : () => string +>node.tagName : string +>node : Element +>tagName : string +>toLowerCase : () => string + + return nodeTagName === tagName; +>nodeTagName === tagName : boolean +>nodeTagName : string +>tagName : T + } + return false; +>false : false +} + +export function assertNodeProperty< +>assertNodeProperty : (node: Node | null, tagName: T, prop: P, value: V) => void + + T extends keyof ElementTagNameMap, +>T : T +>ElementTagNameMap : ElementTagNameMap + + P extends keyof ElementTagNameMap[T], +>P : P +>ElementTagNameMap : ElementTagNameMap +>T : T + + V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) { +>V : V +>HTMLElementTagNameMap : HTMLElementTagNameMap +>T : T +>P : P +>node : Node | null +>Node : Node +>null : null +>tagName : T +>T : T +>prop : P +>P : P +>value : V +>V : V + + if (assertNodeTagName(node, tagName)) { +>assertNodeTagName(node, tagName) : boolean +>assertNodeTagName : (node: Node | null, tagName: T) => node is U +>node : Node | null +>tagName : T + + node[prop]; +>node[prop] : ElementTagNameMap[T][P] +>node : ElementTagNameMap[T] +>prop : P + } +} + diff --git a/tests/baselines/reference/invalidNewTarget.es5.js b/tests/baselines/reference/invalidNewTarget.es5.js index 54bc5ea2d64..0aaee863af1 100644 --- a/tests/baselines/reference/invalidNewTarget.es5.js +++ b/tests/baselines/reference/invalidNewTarget.es5.js @@ -25,6 +25,7 @@ const O = { }; //// [invalidNewTarget.es5.js] +var _a; var a = _newTarget; var b = function () { return _newTarget; }; var C = /** @class */ (function () { @@ -74,4 +75,3 @@ var O = (_a = {}, }), _a.n = _newTarget, _a); -var _a; diff --git a/tests/baselines/reference/invalidSyntaxNamespaceImportWithSystem.js b/tests/baselines/reference/invalidSyntaxNamespaceImportWithSystem.js index 8617127b40d..4a3c6fbcf06 100644 --- a/tests/baselines/reference/invalidSyntaxNamespaceImportWithSystem.js +++ b/tests/baselines/reference/invalidSyntaxNamespaceImportWithSystem.js @@ -8,9 +8,9 @@ import * from Zero from "./0" //// [0.js] System.register([], function (exports_1, context_1) { + var C; "use strict"; var __moduleName = context_1 && context_1.id; - var C; return { setters: [], execute: function () { @@ -25,9 +25,9 @@ System.register([], function (exports_1, context_1) { }); //// [1.js] System.register([], function (exports_1, context_1) { + var from; "use strict"; var __moduleName = context_1 && context_1.id; - var from; return { setters: [], execute: function () { diff --git a/tests/baselines/reference/jsContainerMergeJsContainer.symbols b/tests/baselines/reference/jsContainerMergeJsContainer.symbols new file mode 100644 index 00000000000..1f4728d50de --- /dev/null +++ b/tests/baselines/reference/jsContainerMergeJsContainer.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/salsa/a.js === +// #24131 +const a = {}; +>a : Symbol(a, Decl(a.js, 1, 5), Decl(a.js, 1, 13), Decl(b.js, 0, 0)) + +a.d = function() {}; +>a.d : Symbol(d, Decl(a.js, 1, 13), Decl(b.js, 0, 2)) +>a : Symbol(a, Decl(a.js, 1, 5), Decl(a.js, 1, 13), Decl(b.js, 0, 0)) +>d : Symbol(d, Decl(a.js, 1, 13), Decl(b.js, 0, 2)) + +=== tests/cases/conformance/salsa/b.js === +a.d.prototype = {}; +>a.d.prototype : Symbol(d.prototype, Decl(b.js, 0, 0)) +>a.d : Symbol(d, Decl(a.js, 1, 13), Decl(b.js, 0, 2)) +>a : Symbol(a, Decl(a.js, 1, 5), Decl(a.js, 1, 13), Decl(b.js, 0, 0)) +>d : Symbol(d, Decl(a.js, 1, 13), Decl(b.js, 0, 2)) +>prototype : Symbol(d.prototype, Decl(b.js, 0, 0)) + diff --git a/tests/baselines/reference/jsContainerMergeJsContainer.types b/tests/baselines/reference/jsContainerMergeJsContainer.types new file mode 100644 index 00000000000..fa5c74f5b05 --- /dev/null +++ b/tests/baselines/reference/jsContainerMergeJsContainer.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/salsa/a.js === +// #24131 +const a = {}; +>a : { [x: string]: any; d: typeof d; } +>{} : { [x: string]: any; d: typeof d; } + +a.d = function() {}; +>a.d = function() {} : typeof d +>a.d : typeof d +>a : { [x: string]: any; d: typeof d; } +>d : typeof d +>function() {} : typeof d + +=== tests/cases/conformance/salsa/b.js === +a.d.prototype = {}; +>a.d.prototype = {} : { [x: string]: any; } +>a.d.prototype : { [x: string]: any; } +>a.d : typeof d +>a : { [x: string]: any; d: typeof d; } +>d : typeof d +>prototype : { [x: string]: any; } +>{} : { [x: string]: any; } + diff --git a/tests/baselines/reference/jsDocTypedef1.js b/tests/baselines/reference/jsDocTypedef1.js index e1b34f14c2b..bc00dcafb5d 100644 --- a/tests/baselines/reference/jsDocTypedef1.js +++ b/tests/baselines/reference/jsDocTypedef1.js @@ -41,140 +41,8 @@ "kind": "space" }, { - "text": "{", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "x", - "kind": "propertyName" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "y", - "kind": "propertyName" - }, - { - "text": "?", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "z", - "kind": "propertyName" - }, - { - "text": "?", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "w", - "kind": "propertyName" - }, - { - "text": "?", - "kind": "punctuation" - }, - { - "text": ":", - "kind": "punctuation" - }, - { - "text": " ", - "kind": "space" - }, - { - "text": "string", - "kind": "keyword" - }, - { - "text": ";", - "kind": "punctuation" - }, - { - "text": "\n", - "kind": "lineBreak" - }, - { - "text": "}", - "kind": "punctuation" + "text": "Opts", + "kind": "aliasName" } ], "documentation": [], diff --git a/tests/baselines/reference/jsdocTemplateClass.errors.txt b/tests/baselines/reference/jsdocTemplateClass.errors.txt index 4598e9f320f..402992c34bd 100644 --- a/tests/baselines/reference/jsdocTemplateClass.errors.txt +++ b/tests/baselines/reference/jsdocTemplateClass.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsdoc/templateTagOnClasses.js(24,1): error TS2322: Type 'boolean' is not assignable to type 'number'. +tests/cases/conformance/jsdoc/templateTagOnClasses.js(25,1): error TS2322: Type 'boolean' is not assignable to type 'number'. ==== tests/cases/conformance/jsdoc/templateTagOnClasses.js (1 errors) ==== @@ -6,6 +6,7 @@ tests/cases/conformance/jsdoc/templateTagOnClasses.js(24,1): error TS2322: Type * @template {T} * @typedef {(t: T) => T} Id */ + /** @template T */ class Foo { /** @typedef {(t: T) => T} Id2 */ /** @param {T} x */ @@ -15,7 +16,7 @@ tests/cases/conformance/jsdoc/templateTagOnClasses.js(24,1): error TS2322: Type /** * * @param {T} x - * @param {Id} y + * @param {Id} y * @param {Id2} alpha * @return {T} */ diff --git a/tests/baselines/reference/jsdocTemplateClass.symbols b/tests/baselines/reference/jsdocTemplateClass.symbols index d80b73bc4ac..b82cd8038e5 100644 --- a/tests/baselines/reference/jsdocTemplateClass.symbols +++ b/tests/baselines/reference/jsdocTemplateClass.symbols @@ -3,52 +3,53 @@ * @template {T} * @typedef {(t: T) => T} Id */ +/** @template T */ class Foo { >Foo : Symbol(Foo, Decl(templateTagOnClasses.js, 0, 0)) /** @typedef {(t: T) => T} Id2 */ /** @param {T} x */ constructor (x) { ->x : Symbol(x, Decl(templateTagOnClasses.js, 7, 17)) +>x : Symbol(x, Decl(templateTagOnClasses.js, 8, 17)) this.a = x ->this.a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 7, 21)) +>this.a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 8, 21)) >this : Symbol(Foo, Decl(templateTagOnClasses.js, 0, 0)) ->a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 7, 21)) ->x : Symbol(x, Decl(templateTagOnClasses.js, 7, 17)) +>a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 8, 21)) +>x : Symbol(x, Decl(templateTagOnClasses.js, 8, 17)) } /** * * @param {T} x - * @param {Id} y + * @param {Id} y * @param {Id2} alpha * @return {T} */ foo(x, y, alpha) { ->foo : Symbol(Foo.foo, Decl(templateTagOnClasses.js, 9, 5)) ->x : Symbol(x, Decl(templateTagOnClasses.js, 17, 8)) ->y : Symbol(y, Decl(templateTagOnClasses.js, 17, 10)) ->alpha : Symbol(alpha, Decl(templateTagOnClasses.js, 17, 13)) +>foo : Symbol(Foo.foo, Decl(templateTagOnClasses.js, 10, 5)) +>x : Symbol(x, Decl(templateTagOnClasses.js, 18, 8)) +>y : Symbol(y, Decl(templateTagOnClasses.js, 18, 10)) +>alpha : Symbol(alpha, Decl(templateTagOnClasses.js, 18, 13)) return alpha(y(x)) ->alpha : Symbol(alpha, Decl(templateTagOnClasses.js, 17, 13)) ->y : Symbol(y, Decl(templateTagOnClasses.js, 17, 10)) ->x : Symbol(x, Decl(templateTagOnClasses.js, 17, 8)) +>alpha : Symbol(alpha, Decl(templateTagOnClasses.js, 18, 13)) +>y : Symbol(y, Decl(templateTagOnClasses.js, 18, 10)) +>x : Symbol(x, Decl(templateTagOnClasses.js, 18, 8)) } } var f = new Foo(1) ->f : Symbol(f, Decl(templateTagOnClasses.js, 21, 3)) +>f : Symbol(f, Decl(templateTagOnClasses.js, 22, 3)) >Foo : Symbol(Foo, Decl(templateTagOnClasses.js, 0, 0)) var g = new Foo(false) ->g : Symbol(g, Decl(templateTagOnClasses.js, 22, 3)) +>g : Symbol(g, Decl(templateTagOnClasses.js, 23, 3)) >Foo : Symbol(Foo, Decl(templateTagOnClasses.js, 0, 0)) f.a = g.a ->f.a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 7, 21)) ->f : Symbol(f, Decl(templateTagOnClasses.js, 21, 3)) ->a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 7, 21)) ->g.a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 7, 21)) ->g : Symbol(g, Decl(templateTagOnClasses.js, 22, 3)) ->a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 7, 21)) +>f.a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 8, 21)) +>f : Symbol(f, Decl(templateTagOnClasses.js, 22, 3)) +>a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 8, 21)) +>g.a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 8, 21)) +>g : Symbol(g, Decl(templateTagOnClasses.js, 23, 3)) +>a : Symbol(Foo.a, Decl(templateTagOnClasses.js, 8, 21)) diff --git a/tests/baselines/reference/jsdocTemplateClass.types b/tests/baselines/reference/jsdocTemplateClass.types index aa6a685e34f..9c028a96ff1 100644 --- a/tests/baselines/reference/jsdocTemplateClass.types +++ b/tests/baselines/reference/jsdocTemplateClass.types @@ -3,6 +3,7 @@ * @template {T} * @typedef {(t: T) => T} Id */ +/** @template T */ class Foo { >Foo : Foo @@ -21,7 +22,7 @@ class Foo { /** * * @param {T} x - * @param {Id} y + * @param {Id} y * @param {Id2} alpha * @return {T} */ diff --git a/tests/baselines/reference/jsdocTemplateConstructorFunction.errors.txt b/tests/baselines/reference/jsdocTemplateConstructorFunction.errors.txt index 225d277c4ff..9e735b780a0 100644 --- a/tests/baselines/reference/jsdocTemplateConstructorFunction.errors.txt +++ b/tests/baselines/reference/jsdocTemplateConstructorFunction.errors.txt @@ -1,11 +1,14 @@ -tests/cases/conformance/jsdoc/templateTagOnConstructorFunctions.js(21,1): error TS2322: Type 'false' is not assignable to type 'number'. +tests/cases/conformance/jsdoc/templateTagOnConstructorFunctions.js(24,1): error TS2322: Type 'false' is not assignable to type 'number'. ==== tests/cases/conformance/jsdoc/templateTagOnConstructorFunctions.js (1 errors) ==== /** - * @template {T} - * @typedef {(t: T) => T} Id + * @template {U} + * @typedef {(u: U) => U} Id + */ + /** * @param {T} t + * @template {T} */ function Zet(t) { /** @type {T} */ @@ -14,7 +17,7 @@ tests/cases/conformance/jsdoc/templateTagOnConstructorFunctions.js(21,1): error } /** * @param {T} v - * @param {Id} id + * @param {Id} id */ Zet.prototype.add = function(v, id) { this.u = v || this.t diff --git a/tests/baselines/reference/jsdocTemplateConstructorFunction.symbols b/tests/baselines/reference/jsdocTemplateConstructorFunction.symbols index 8cf2ee99e57..b640d3c1e21 100644 --- a/tests/baselines/reference/jsdocTemplateConstructorFunction.symbols +++ b/tests/baselines/reference/jsdocTemplateConstructorFunction.symbols @@ -1,57 +1,60 @@ === tests/cases/conformance/jsdoc/templateTagOnConstructorFunctions.js === /** - * @template {T} - * @typedef {(t: T) => T} Id + * @template {U} + * @typedef {(u: U) => U} Id + */ +/** * @param {T} t + * @template {T} */ function Zet(t) { >Zet : Symbol(Zet, Decl(templateTagOnConstructorFunctions.js, 0, 0)) ->t : Symbol(t, Decl(templateTagOnConstructorFunctions.js, 5, 13)) +>t : Symbol(t, Decl(templateTagOnConstructorFunctions.js, 8, 13)) /** @type {T} */ this.u this.t = t ->t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 7, 10)) ->t : Symbol(t, Decl(templateTagOnConstructorFunctions.js, 5, 13)) +>t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 10, 10)) +>t : Symbol(t, Decl(templateTagOnConstructorFunctions.js, 8, 13)) } /** * @param {T} v - * @param {Id} id + * @param {Id} id */ Zet.prototype.add = function(v, id) { ->Zet.prototype : Symbol(Zet.add, Decl(templateTagOnConstructorFunctions.js, 9, 1)) +>Zet.prototype : Symbol(Zet.add, Decl(templateTagOnConstructorFunctions.js, 12, 1)) >Zet : Symbol(Zet, Decl(templateTagOnConstructorFunctions.js, 0, 0)) >prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --)) ->add : Symbol(Zet.add, Decl(templateTagOnConstructorFunctions.js, 9, 1)) ->v : Symbol(v, Decl(templateTagOnConstructorFunctions.js, 14, 29)) ->id : Symbol(id, Decl(templateTagOnConstructorFunctions.js, 14, 31)) +>add : Symbol(Zet.add, Decl(templateTagOnConstructorFunctions.js, 12, 1)) +>v : Symbol(v, Decl(templateTagOnConstructorFunctions.js, 17, 29)) +>id : Symbol(id, Decl(templateTagOnConstructorFunctions.js, 17, 31)) this.u = v || this.t ->this.u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 5, 17), Decl(templateTagOnConstructorFunctions.js, 14, 37)) +>this.u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37)) >this : Symbol(Zet, Decl(templateTagOnConstructorFunctions.js, 0, 0)) ->u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 5, 17), Decl(templateTagOnConstructorFunctions.js, 14, 37)) ->v : Symbol(v, Decl(templateTagOnConstructorFunctions.js, 14, 29)) ->this.t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 7, 10)) +>u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37)) +>v : Symbol(v, Decl(templateTagOnConstructorFunctions.js, 17, 29)) +>this.t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 10, 10)) >this : Symbol(Zet, Decl(templateTagOnConstructorFunctions.js, 0, 0)) ->t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 7, 10)) +>t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 10, 10)) return id(this.u) ->id : Symbol(id, Decl(templateTagOnConstructorFunctions.js, 14, 31)) ->this.u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 5, 17), Decl(templateTagOnConstructorFunctions.js, 14, 37)) +>id : Symbol(id, Decl(templateTagOnConstructorFunctions.js, 17, 31)) +>this.u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37)) >this : Symbol(Zet, Decl(templateTagOnConstructorFunctions.js, 0, 0)) ->u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 5, 17), Decl(templateTagOnConstructorFunctions.js, 14, 37)) +>u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37)) } var z = new Zet(1) ->z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 18, 3)) +>z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 21, 3)) >Zet : Symbol(Zet, Decl(templateTagOnConstructorFunctions.js, 0, 0)) z.t = 2 ->z.t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 7, 10)) ->z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 18, 3)) ->t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 7, 10)) +>z.t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 10, 10)) +>z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 21, 3)) +>t : Symbol(Zet.t, Decl(templateTagOnConstructorFunctions.js, 10, 10)) z.u = false ->z.u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 5, 17), Decl(templateTagOnConstructorFunctions.js, 14, 37)) ->z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 18, 3)) ->u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 5, 17), Decl(templateTagOnConstructorFunctions.js, 14, 37)) +>z.u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37)) +>z : Symbol(z, Decl(templateTagOnConstructorFunctions.js, 21, 3)) +>u : Symbol(Zet.u, Decl(templateTagOnConstructorFunctions.js, 8, 17), Decl(templateTagOnConstructorFunctions.js, 17, 37)) diff --git a/tests/baselines/reference/jsdocTemplateConstructorFunction.types b/tests/baselines/reference/jsdocTemplateConstructorFunction.types index f838534aa33..121cf846a0e 100644 --- a/tests/baselines/reference/jsdocTemplateConstructorFunction.types +++ b/tests/baselines/reference/jsdocTemplateConstructorFunction.types @@ -1,8 +1,11 @@ === tests/cases/conformance/jsdoc/templateTagOnConstructorFunctions.js === /** - * @template {T} - * @typedef {(t: T) => T} Id + * @template {U} + * @typedef {(u: U) => U} Id + */ +/** * @param {T} t + * @template {T} */ function Zet(t) { >Zet : typeof Zet @@ -23,18 +26,18 @@ function Zet(t) { } /** * @param {T} v - * @param {Id} id + * @param {Id} id */ Zet.prototype.add = function(v, id) { ->Zet.prototype.add = function(v, id) { this.u = v || this.t return id(this.u)} : (v: T, id: (t: T) => T) => T +>Zet.prototype.add = function(v, id) { this.u = v || this.t return id(this.u)} : (v: T, id: (u: T) => T) => T >Zet.prototype.add : any >Zet.prototype : any >Zet : typeof Zet >prototype : any >add : any ->function(v, id) { this.u = v || this.t return id(this.u)} : (v: T, id: (t: T) => T) => T +>function(v, id) { this.u = v || this.t return id(this.u)} : (v: T, id: (u: T) => T) => T >v : T ->id : (t: T) => T +>id : (u: T) => T this.u = v || this.t >this.u = v || this.t : T @@ -49,7 +52,7 @@ Zet.prototype.add = function(v, id) { return id(this.u) >id(this.u) : T ->id : (t: T) => T +>id : (u: T) => T >this.u : T >this : Zet >u : T diff --git a/tests/baselines/reference/jsdocTemplateConstructorFunction2.errors.txt b/tests/baselines/reference/jsdocTemplateConstructorFunction2.errors.txt index 6a8e45566ec..cdcc9a056eb 100644 --- a/tests/baselines/reference/jsdocTemplateConstructorFunction2.errors.txt +++ b/tests/baselines/reference/jsdocTemplateConstructorFunction2.errors.txt @@ -4,8 +4,8 @@ tests/cases/conformance/jsdoc/templateTagWithNestedTypeLiteral.js(26,15): error ==== tests/cases/conformance/jsdoc/templateTagWithNestedTypeLiteral.js (2 errors) ==== /** - * @template {T} * @param {T} t + * @template {T} */ function Zet(t) { /** @type {T} */ diff --git a/tests/baselines/reference/jsdocTemplateConstructorFunction2.symbols b/tests/baselines/reference/jsdocTemplateConstructorFunction2.symbols index c65570f84c4..32573a37398 100644 --- a/tests/baselines/reference/jsdocTemplateConstructorFunction2.symbols +++ b/tests/baselines/reference/jsdocTemplateConstructorFunction2.symbols @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/templateTagWithNestedTypeLiteral.js === /** - * @template {T} * @param {T} t + * @template {T} */ function Zet(t) { >Zet : Symbol(Zet, Decl(templateTagWithNestedTypeLiteral.js, 0, 0)) diff --git a/tests/baselines/reference/jsdocTemplateConstructorFunction2.types b/tests/baselines/reference/jsdocTemplateConstructorFunction2.types index 5737f8caaf9..14407a5a0c9 100644 --- a/tests/baselines/reference/jsdocTemplateConstructorFunction2.types +++ b/tests/baselines/reference/jsdocTemplateConstructorFunction2.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/templateTagWithNestedTypeLiteral.js === /** - * @template {T} * @param {T} t + * @template {T} */ function Zet(t) { >Zet : typeof Zet @@ -79,7 +79,7 @@ z.u = false */ /** @type {A} */ const options = { value: null }; ->options : { value: any; } +>options : A >{ value: null } : { value: null; } >value : null >null : null diff --git a/tests/baselines/reference/jsdocTemplateTag2.symbols b/tests/baselines/reference/jsdocTemplateTag2.symbols new file mode 100644 index 00000000000..407943934ff --- /dev/null +++ b/tests/baselines/reference/jsdocTemplateTag2.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/jsdoc/github17339.js === +var obj = { +>obj : Symbol(obj, Decl(github17339.js, 0, 3)) + + /** + * @template T + * @param {T} a + * @returns {T} + */ + x: function (a) { +>x : Symbol(x, Decl(github17339.js, 0, 11)) +>a : Symbol(a, Decl(github17339.js, 6, 14)) + + return a; +>a : Symbol(a, Decl(github17339.js, 6, 14)) + + }, +}; + diff --git a/tests/baselines/reference/jsdocTemplateTag2.types b/tests/baselines/reference/jsdocTemplateTag2.types new file mode 100644 index 00000000000..d35724fb9b6 --- /dev/null +++ b/tests/baselines/reference/jsdocTemplateTag2.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/jsdoc/github17339.js === +var obj = { +>obj : { [x: string]: any; x: (a: T) => T; } +>{ /** * @template T * @param {T} a * @returns {T} */ x: function (a) { return a; },} : { [x: string]: any; x: (a: T) => T; } + + /** + * @template T + * @param {T} a + * @returns {T} + */ + x: function (a) { +>x : (a: T) => T +>function (a) { return a; } : (a: T) => T +>a : T + + return a; +>a : T + + }, +}; + diff --git a/tests/baselines/reference/jsdocTypedefMissingType.types b/tests/baselines/reference/jsdocTypedefMissingType.types index 18cd68abfcb..b161c6ca489 100644 --- a/tests/baselines/reference/jsdocTypedefMissingType.types +++ b/tests/baselines/reference/jsdocTypedefMissingType.types @@ -14,7 +14,7 @@ const t = 0; /** @type Person */ const person = { name: "" }; ->person : { name: string; } +>person : Person >{ name: "" } : { name: string; } >name : string >"" : "" diff --git a/tests/baselines/reference/jsdocTypedef_propertyWithNoType.types b/tests/baselines/reference/jsdocTypedef_propertyWithNoType.types index 7d7326fc80c..553c1b544ae 100644 --- a/tests/baselines/reference/jsdocTypedef_propertyWithNoType.types +++ b/tests/baselines/reference/jsdocTypedef_propertyWithNoType.types @@ -6,7 +6,7 @@ /** @type {Foo} */ const x = { foo: 0 }; ->x : { foo: any; } +>x : Foo >{ foo: 0 } : { foo: number; } >foo : number >0 : 0 diff --git a/tests/baselines/reference/jsxNestedWithinTernaryParsesCorrectly.js b/tests/baselines/reference/jsxNestedWithinTernaryParsesCorrectly.js new file mode 100644 index 00000000000..f431e1224cc --- /dev/null +++ b/tests/baselines/reference/jsxNestedWithinTernaryParsesCorrectly.js @@ -0,0 +1,25 @@ +//// [jsxNestedWithinTernaryParsesCorrectly.tsx] +const emptyMessage = null as any; +const a = ( +
+ {0 ? ( + emptyMessage // must be identifier? + ) : ( + // must be exactly two expression holes + + {0}{0} + + )} +
+); + +//// [jsxNestedWithinTernaryParsesCorrectly.jsx] +var emptyMessage = null; +var a = (
+ {0 ? (emptyMessage // must be identifier? +) : ( +// must be exactly two expression holes + + {0}{0} + )} +
); diff --git a/tests/baselines/reference/jsxNestedWithinTernaryParsesCorrectly.symbols b/tests/baselines/reference/jsxNestedWithinTernaryParsesCorrectly.symbols new file mode 100644 index 00000000000..73ee27251ae --- /dev/null +++ b/tests/baselines/reference/jsxNestedWithinTernaryParsesCorrectly.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/jsxNestedWithinTernaryParsesCorrectly.tsx === +const emptyMessage = null as any; +>emptyMessage : Symbol(emptyMessage, Decl(jsxNestedWithinTernaryParsesCorrectly.tsx, 0, 5)) + +const a = ( +>a : Symbol(a, Decl(jsxNestedWithinTernaryParsesCorrectly.tsx, 1, 5)) + +
+ {0 ? ( + emptyMessage // must be identifier? +>emptyMessage : Symbol(emptyMessage, Decl(jsxNestedWithinTernaryParsesCorrectly.tsx, 0, 5)) + + ) : ( + // must be exactly two expression holes + + {0}{0} + + )} +
+); diff --git a/tests/baselines/reference/jsxNestedWithinTernaryParsesCorrectly.types b/tests/baselines/reference/jsxNestedWithinTernaryParsesCorrectly.types new file mode 100644 index 00000000000..0daa04fc39f --- /dev/null +++ b/tests/baselines/reference/jsxNestedWithinTernaryParsesCorrectly.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/jsxNestedWithinTernaryParsesCorrectly.tsx === +const emptyMessage = null as any; +>emptyMessage : any +>null as any : any +>null : null + +const a = ( +>a : any +>(
{0 ? ( emptyMessage // must be identifier? ) : ( // must be exactly two expression holes {0}{0} )}
) : any + +
+>
{0 ? ( emptyMessage // must be identifier? ) : ( // must be exactly two expression holes {0}{0} )}
: any +>div : any + + {0 ? ( +>0 ? ( emptyMessage // must be identifier? ) : ( // must be exactly two expression holes {0}{0} ) : any +>0 : 0 +>( emptyMessage // must be identifier? ) : any + + emptyMessage // must be identifier? +>emptyMessage : any + + ) : ( +>( // must be exactly two expression holes {0}{0} ) : any + + // must be exactly two expression holes + +> {0}{0} : any +>span : any + + {0}{0} +>0 : 0 +>0 : 0 + + +>span : any + + )} +
+>div : any + +); diff --git a/tests/baselines/reference/jsxSpreadFirstUnionNoErrors.types b/tests/baselines/reference/jsxSpreadFirstUnionNoErrors.types index d96c88d1c41..0e97c588a64 100644 --- a/tests/baselines/reference/jsxSpreadFirstUnionNoErrors.types +++ b/tests/baselines/reference/jsxSpreadFirstUnionNoErrors.types @@ -3,7 +3,7 @@ import React from "react"; >React : typeof React type InfoProps = ->InfoProps : { status: "hidden"; } | { status: "visible"; content: string; } +>InfoProps : InfoProps | { status: "hidden" } >status : "hidden" @@ -13,16 +13,16 @@ type InfoProps = >content : string const Info = (props: InfoProps) => ->Info : (props: { status: "hidden"; } | { status: "visible"; content: string; }) => JSX.Element ->(props: InfoProps) =>props.status === "hidden" ?