mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' of https://github.com/Microsoft/TypeScript into 11116
This commit is contained in:
@@ -41,7 +41,9 @@ tests/cases/**/*.js.map
|
||||
scripts/debug.bat
|
||||
scripts/run.bat
|
||||
scripts/word2md.js
|
||||
scripts/buildProtocol.js
|
||||
scripts/ior.js
|
||||
scripts/buildProtocol.js
|
||||
scripts/*.js.map
|
||||
scripts/typings/
|
||||
coverage/
|
||||
|
||||
@@ -1,32 +1,38 @@
|
||||
|
||||
Alexander <alexander@kuvaev.me># Alexander Kuvaev
|
||||
AbubakerB <abubaker_bashir@hotmail.com> # Abubaker Bashir
|
||||
Alexander <alexander@kuvaev.me># Alexander Kuvaev
|
||||
Adam Freidin <adam.freidin@gmail.com> Adam Freidin <afreidin@adobe.com>
|
||||
Adi Dahiya <adahiya@palantir.com> Adi Dahiya <adi.dahiya14@gmail.com>
|
||||
Ahmad Farid <ahfarid@microsoft.com> ahmad-farid <ahfarid@microsoft.com>
|
||||
Alexander Rusakov <a_s_rusakov@mail.ru>
|
||||
Alex Eagle <alexeagle@google.com>
|
||||
Anatoly Ressin <anatoly.ressin@icloud.com>
|
||||
Anders Hejlsberg <andersh@microsoft.com> unknown <andersh@AndersX1.NOE.Nokia.com> unknown <andersh@andersh-yoga.redmond.corp.microsoft.com>
|
||||
Andrej Baran <andrej.baran@gmail.com>
|
||||
Andrew Z Allen <me@andrewzallen.com>
|
||||
Andy Hanson <anhans@microsoft.com> Andy <anhans@microsoft.com>
|
||||
Anil Anar <anilanar@hotmail.com>
|
||||
Anton Tolmachev <myste@mail.ru>
|
||||
Arnavion <arnavion@gmail.com> # Arnav Singh
|
||||
Arthur Ozga <aozgaa@umich.edu> Arthur Ozga <t-arthoz@microsoft.com>
|
||||
Arthur Ozga <aozgaa@umich.edu> Arthur Ozga <t-arthoz@microsoft.com> Arthur Ozga <aozgaa-ms@outlook.com> Arthur Ozga <aozgaa@users.noreply.github.com> Arthur Ozga <arozga@microsoft.com>
|
||||
Asad Saeeduddin <masaeedu@gmail.com>
|
||||
Schmavery <avery.schmavery@gmail.com> # Avery Morin
|
||||
Basarat Ali Syed <basaratali@gmail.com> Basarat Syed <basaratali@gmail.com> basarat <basaratali@gmail.com>
|
||||
Bill Ticehurst <billti@hotmail.com> Bill Ticehurst <billti@microsoft.com>
|
||||
Ben Duffield <jebavarde@gmail.com>
|
||||
Ben Mosher <me@benmosher.com>
|
||||
Blake Embrey <hello@blakeembrey.com>
|
||||
Bowden Kelly <wilkelly@microsoft.com>
|
||||
Brett Mayen <bmayen@midnightsnacks.net>
|
||||
Bryan Forbes <bryan@reigndropsfall.net>
|
||||
Caitlin Potter <caitpotter88@gmail.com>
|
||||
ChrisBubernak <chris.bubernak@gmail.com> unknown <chrbub@chrbub1.redmond.corp.microsoft.com> # Chris Bubernak
|
||||
Christophe Vidal <kriss@krizalys.com>
|
||||
Chuck Jazdzewski <chuckj@google.com>
|
||||
Colby Russell <mr@colbyrussell.com>
|
||||
Colin Snover <github.com@zetafleet.com>
|
||||
Cyrus Najmabadi <cyrusn@microsoft.com> CyrusNajmabadi <cyrusn@microsoft.com> unknown <cyrusn@cylap.ntdev.corp.microsoft.com>
|
||||
Dafrok <o.o@mug.dog> # Dafrok Zhang
|
||||
Dan Corder <dev@dancorder.com>
|
||||
Dan Quirk <danquirk@microsoft.com> Dan Quirk <danquirk@users.noreply.github.com> nknown <danquirk@DANQUIRK1.redmond.corp.microsoft.com>
|
||||
Daniel Rosenwasser <drosen@microsoft.com> Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> Daniel Rosenwasser <DanielRosenwasser@gmail.com> Daniel Rosenwasser <Daniel.Rosenwasser@microsoft.com> Daniel Rosenwasser <DanielRosenwasser@microsoft.com>
|
||||
@@ -36,17 +42,22 @@ Denis Nedelyaev <denvned@gmail.com>
|
||||
Dick van den Brink <d_vandenbrink@outlook.com> unknown <d_vandenbrink@outlook.com> unknown <d_vandenbrink@live.com>
|
||||
Dirk Baeumer <dirkb@microsoft.com> Dirk Bäumer <dirkb@microsoft.com> # Dirk Bäumer
|
||||
Dirk Holtwick <dirk.holtwick@gmail.com>
|
||||
Dom Chen <domchen@users.noreply.github.com>
|
||||
Doug Ilijev <dilijev@users.noreply.github.com>
|
||||
Erik Edrosa <erik.edrosa@gmail.com>
|
||||
erictsangx <erictsangx@gmail.com> # Eric Tsang
|
||||
Ethan Rubio <ethanrubio@users.noreply.github.com>
|
||||
Evan Martin <martine@danga.com>
|
||||
Evan Sebastian <evanlhoini@gmail.com>
|
||||
Eyas <eyas.sharaiha@gmail.com> # Eyas Sharaiha
|
||||
Fabian Cook <faybecook@gmail.com>
|
||||
falsandtru <falsandtru@users.noreply.github.com> # @falsandtru
|
||||
Frank Wallis <fwallis@outlook.com>
|
||||
František Žiačik <fziacik@gratex.com> František Žiačik <ziacik@gmail.com>
|
||||
František Žiacik <fziacik@gratex.com> František Žiacik <ziacik@gmail.com>
|
||||
Gabe Moothart <gmoothart@gmail.com>
|
||||
Gabriel Isenberg <gisenberg@gmail.com>
|
||||
Gilad Peleg <giladp007@gmail.com>
|
||||
Godfrey Chan <godfreykfc@gmail.com>
|
||||
Graeme Wicksted <graeme.wicksted@gmail.com>
|
||||
Guillaume Salles <guillaume.salles@me.com>
|
||||
Guy Bedford <guybedford@gmail.com> guybedford <guybedford@gmail.com>
|
||||
@@ -55,6 +66,7 @@ Iain Monro <iain.monro@softwire.com>
|
||||
Ingvar Stepanyan <me@rreverser.com>
|
||||
impinball <impinball@gmail.com> # Isiah Meadows
|
||||
Ivo Gabe de Wolff <ivogabe@ivogabe.nl>
|
||||
Jakub Młokosiewicz <hckr@users.noreply.github.com>
|
||||
James Whitney <james@whitney.io>
|
||||
Jason Freeman <jfreeman@microsoft.com> Jason Freeman <JsonFreeman@users.noreply.github.com>
|
||||
Jason Killian <jkillian@palantir.com>
|
||||
@@ -69,11 +81,14 @@ Jonathan Park <jpark@daptiv.com>
|
||||
Jonathan Turner <jont@microsoft.com> Jonathan Turner <probata@hotmail.com>
|
||||
Jonathan Toland <toland@dnalot.com>
|
||||
Jesse Schalken <me@jesseschalken.com>
|
||||
Josh Abernathy <joshaber@gmail.com> joshaber <joshaber@gmail.com>
|
||||
Josh Kalderimis <josh.kalderimis@gmail.com>
|
||||
Josh Soref <jsoref@users.noreply.github.com>
|
||||
Juan Luis Boya García <ntrrgc@gmail.com>
|
||||
Julian Williams <julianjw92@gmail.com>
|
||||
Herrington Darkholme <nonamesheep1@gmail.com>
|
||||
Justin Bay <justin.bay@outlook.com>
|
||||
Justin Johansson <thebabellion@gmail.com>
|
||||
Herrington Darkholme <nonamesheep1@gmail.com> (´·?·`) <HerringtonDarkholme@users.noreply.github.com> # Herrington Darkholme
|
||||
Kagami Sascha Rosylight <saschanaz@outlook.com> SaschaNaz <saschanaz@outlook.com>
|
||||
Kanchalai Tanglertsampan <yuisu@microsoft.com> Yui <yuit@users.noreply.github.com>
|
||||
Kanchalai Tanglertsampan <yuisu@microsoft.com> Yui T <yuisu@microsoft.com>
|
||||
@@ -82,23 +97,29 @@ Kanchalai Tanglertsampan <yuisu@microsoft.com> Yui <yuisu@microsoft.com>
|
||||
Kanchalai Tanglertsampan <yuisu@microsoft.com> yui T <yuisu@microsoft.com>
|
||||
Keith Mashinter <kmashint@yahoo.com> kmashint <kmashint@yahoo.com>
|
||||
Ken Howard <ken@simplicatedweb.com>
|
||||
Kevin Lang <klang2012@gmail.com>
|
||||
kimamula <kenji.imamula@gmail.com> # Kenji Imamula
|
||||
Kyle Kelley <rgbkrk@gmail.com>
|
||||
Lorant Pinter <lorant.pinter@prezi.com>
|
||||
Lucien Greathouse <me@lpghatguy.com>
|
||||
Lukas Elmer <lukas.elmer@gmail.com> Lukas Elmer <lukas.elmer@renuo.ch>
|
||||
Martin Vseticka <vseticka.martin@gmail.com> Martin Všeticka <vseticka.martin@gmail.com> MartyIX <vseticka.martin@gmail.com>
|
||||
gcnew <gcnew@abv.bg> # Marin Marinov
|
||||
vvakame <vvakame+dev@gmail.com> # Masahiro Wakame
|
||||
Matt McCutchen <rmccutch@mit.edu>
|
||||
Max Deepfield <maxdeepfield@absolutefreakout.com>
|
||||
Micah Zoltu <micah@zoltu.net>
|
||||
Michael <maykelchiche@gmail.com>
|
||||
Mohamed Hegazy <mhegazy@microsoft.com>
|
||||
Nathan Shively-Sanders <nathansa@microsoft.com>
|
||||
Nathan Yee <ny.nathan.yee@gmail.com>
|
||||
Nima Zahedi <nima.zahedee@gmail.com>
|
||||
Noah Chen <nchen@palantir.com>
|
||||
Noj Vek <nojvek@gmail.com>
|
||||
mihailik <mihailik@gmail.com> # Oleg Mihailik
|
||||
Oleksandr Chekhovskyi <oleksandr.chekhovskyi@hansoft.com>
|
||||
Paul van Brenk <paul.van.brenk@microsoft.com> Paul van Brenk <paul.van.brenk@outlook.com> unknown <paul.van.brenk@microsoft.com> unknown <paul.van.brenk@microsoft.com> unknown <pvanbren@pvbvsproai.redmond.corp.microsoft.com>
|
||||
Omer Sheikh <ojsheikh@gmail.com>
|
||||
Oskar Segersva¨rd <oskar.segersvard@widespace.com>
|
||||
pcan <piero.cangianiello@gmail.com> # Piero Cangianiello
|
||||
pcbro <2bux89+dk3zspjmuh16o@sharklasers.com> # @pcbro
|
||||
@@ -109,21 +130,26 @@ progre <djyayutto@gmail.com> # @progre
|
||||
Prayag Verma <prayag.verma@gmail.com>
|
||||
Punya Biswal <pbiswal@palantir.com>
|
||||
Rado Kirov <radokirov@google.com>
|
||||
Ron Buckton <rbuckton@microsoft.com> Ron Buckton <ron.buckton@microsoft.com>
|
||||
Ron Buckton <rbuckton@microsoft.com> Ron Buckton <ron.buckton@microsoft.com> rbuckton <rbuckton@chronicles.org>
|
||||
Rostislav Galimsky <rostgal@gmail.com>
|
||||
Richard Knoll <riknoll@users.noreply.github.com> Richard Knoll <riknoll@microsoft.com>
|
||||
Rowan Wyborn <rwyborn@internode.on.net>
|
||||
Ryan Cavanaugh <RyanCavanaugh@users.noreply.github.com> Ryan Cavanaugh <ryan.cavanaugh@microsoft.com> Ryan Cavanaugh <ryanca@microsoft.com>
|
||||
Ryohei Ikegami <iofg2100@gmail.com>
|
||||
Sarangan Rajamanickam <sarajama@microsoft.com>
|
||||
Sébastien Arod <sebastien.arod@gmail.com>
|
||||
Sergey Shandar <sergey-shandar@users.noreply.github.com>
|
||||
Sheetal Nandi <shkamat@microsoft.com>
|
||||
Shengping Zhong <zhongsp@users.noreply.github.com>
|
||||
shyyko.serhiy@gmail.com <shyyko.serhiy@gmail.com> # Shyyko Serhiy
|
||||
Sam El-Husseini <samelh@microsoft.com>
|
||||
Simon Hürlimann <simon.huerlimann@cyt.ch>
|
||||
Slawomir Sadziak <slsadzia@microsoft.com>
|
||||
Solal Pirelli <solal.pirelli@gmail.com>
|
||||
Stan Thomas <stmsdn@norvil.net>
|
||||
Stanislav Sysoev <d4rkr00t@gmail.com>
|
||||
Steve Lucco <steveluc@users.noreply.github.com> steveluc <steveluc@microsoft.com>
|
||||
Sudheesh Singanamalla <sudheesh1995@outlook.com>
|
||||
Tarik <tarik@pushmote.com> # Tarik Ozket
|
||||
Tetsuharu OHZEKI <saneyuki.snyk@gmail.com> # Tetsuharu Ohzeki
|
||||
Tien Nguyen <tihoanh@microsoft.com> tien <hoanhtien@users.noreply.github.com> unknown <tihoanh@microsoft.com> #Tien Hoanhtien
|
||||
@@ -133,6 +159,7 @@ Tingan Ho <tingan87@gmail.com>
|
||||
togru <v3nomzxgt8@gmail.com> # togru
|
||||
Tomas Grubliauskas <tgrubliauskas@gmail.com>
|
||||
ToddThomson <achilles@telus.net> # Todd Thomson
|
||||
Torben Fitschen <torben.fitschen@mayflower.de>
|
||||
TruongSinh Tran-Nguyen <i@truongsinh.pro>
|
||||
vilicvane <i@vilic.info> # Vilic Vane
|
||||
Vladimir Matveev <vladima@microsoft.com> vladima <vladima@microsoft.com> v2m <desco.by@gmail.com>
|
||||
@@ -140,7 +167,50 @@ Wesley Wigham <t-weswig@microsoft.com> Wesley Wigham <wwigham@gmail.com>
|
||||
York Yao <plantain-00@users.noreply.github.com> york yao <yaoao12306@outlook.com> yaoyao <yaoyao12306@163.com>
|
||||
Yuichi Nukiyama <oscar.wilde84@hotmail.co.jp> YuichiNukiyama <oscar.wilde84@hotmail.co.jp>
|
||||
Zev Spitz <shivisi@etrog.net.il>
|
||||
Zhengbo Li <zhengbli@microsoft.com> zhengbli <zhengbli@microsoft.com> Zhengbo Li <Zhengbo Li> Zhengbo Li <zhengbli@mirosoft.com> tinza123 <li.zhengbo@outlook.com> unknown <zhengbli@zhengblit430.redmond.corp.microsoft.com> Zhengbo Li <Zhengbo Li>
|
||||
Zhengbo Li <zhengbli@microsoft.com> zhengbli <zhengbli@microsoft.com> Zhengbo Li <Zhengbo Li> Zhengbo Li <zhengbli@mirosoft.com> tinza123 <li.zhengbo@outlook.com> unknown <zhengbli@zhengblit430.redmond.corp.microsoft.com> Zhengbo Li <Zhengbo Li> zhengbli <zhengli@microsoft.com>
|
||||
zhongsp <patrick.zhongsp@gmail.com> # Patrick Zhong
|
||||
T18970237136 <T18970237136@users.noreply.github.com> # @T18970237136
|
||||
JBerger <JBerger@melco.com>
|
||||
JBerger <JBerger@melco.com>
|
||||
bootstraponline <code@bootstraponline.com> # @bootstraponline
|
||||
yortus <yortus@gmail.com> # @yortus
|
||||
András Parditka <andraaspar@gmail.com>
|
||||
Anton Khlynovskiy <subzey@gmail.com>
|
||||
Charly POLY <cpoly55@gmail.com>
|
||||
Cotton Hou <himcotton@gmail.com>
|
||||
Ethan Resnick <ethan.resnick@gmail.com>
|
||||
Marius Schulz <marius.schulz@me.com>
|
||||
Mattias Buelens <mattias.buelens@gmail.com>
|
||||
Myles Megyesi <mylesmegyesi@users.noreply.github.com>
|
||||
Tim Lancina <tim@ionic.io>
|
||||
Aaron Holmes <aaron@aaronholmes.net> Aaron Holmes <aholmes@bltomato.com>
|
||||
Akshar Patel <akshar.patel.47@gmail.com>
|
||||
Ali Sabzevari <alisabzevari@gmail.com>
|
||||
Aliaksandr Radzivanovich <aradzivanovich@gmail.com>
|
||||
BuildTools <FranklinWhale@users.noreply.github.com> # Franklin Tse
|
||||
ChogyDan <danielhollocher@gmail.com> # Daniel Hollocher
|
||||
Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> Daniel Rosenwasser <drosen@microsoft.com>
|
||||
David Kmenta <david.kmenta@lmc.eu>
|
||||
E020873 <nicolas.henry-partner@arcelormittal.com> # Nicolas Henry
|
||||
Elisée Maurer <elisee@sparklinlabs.com>
|
||||
Emilio García-Pumarino <emili.tfe@gmail.com> dashaus <emili.tfe@gmail.com>
|
||||
Guilherme Oenning <me@goenning.net>
|
||||
Herrington Darkholme <nonamesheep1@gmail.com>
|
||||
Ivo Gabe de Wolff <ivogabe@ivogabe.nl>
|
||||
Joey Wilson <joey.wilson.a@gmail.com>
|
||||
Jonathon Smith <failing@crashdive.co.uk>
|
||||
Juan Luis Boya García <ntrrgc@gmail.com>
|
||||
Kagami Sascha Rosylight <saschanaz@outlook.com>
|
||||
Lucien Greathouse <me@lpghatguy.com>
|
||||
Martin Vseticka <vseticka.martin@gmail.com>
|
||||
Mattias Buelens <mattias.buelens@opentelly.com>
|
||||
Michael Bromley <michael@michaelbromley.co.uk>
|
||||
Paul Jolly <paul@myitcv.org.uk>
|
||||
Perry Jiang <jiangperry@gmail.com>
|
||||
Peter Burns <rictic@google.com>
|
||||
Robert Coie <rac@intrigue.com>
|
||||
Thomas Loubiou <t.loubiou@systonic.fr>
|
||||
Tim Perry <tim.perry@softwire.com>
|
||||
Vidar Tonaas Fauske <vidartf@gmail.com>
|
||||
Viktor Zozulyak <zozulyakviktor@gmail.com>
|
||||
rix <rix@rixs-MacBook-Pro.local> # Richard Sentino
|
||||
rohitverma007 <rohitverma@live.ca> # Rohit Verma
|
||||
@@ -1,8 +1,11 @@
|
||||
built
|
||||
doc
|
||||
Gulpfile.ts
|
||||
internal
|
||||
issue_template.md
|
||||
jenkins.sh
|
||||
lib/README.md
|
||||
netci.groovy
|
||||
pull_request_template.md
|
||||
scripts
|
||||
src
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ language: node_js
|
||||
|
||||
node_js:
|
||||
- 'stable'
|
||||
- '6'
|
||||
- '4'
|
||||
|
||||
sudo: false
|
||||
@@ -15,7 +16,7 @@ matrix:
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- release-2.0
|
||||
- release-2.1
|
||||
|
||||
install:
|
||||
- npm uninstall typescript
|
||||
|
||||
+64
-1
@@ -1,14 +1,23 @@
|
||||
TypeScript is authored by:
|
||||
* Aaron Holmes
|
||||
* Abubaker Bashir
|
||||
* Adam Freidin
|
||||
* Adi Dahiya
|
||||
* Ahmad Farid
|
||||
* Akshar Patel
|
||||
* Alex Eagle
|
||||
* Alexander Kuvaev
|
||||
* Alexander Rusakov
|
||||
* Ali Sabzevari
|
||||
* Aliaksandr Radzivanovich
|
||||
* Anatoly Ressin
|
||||
* Anders Hejlsberg
|
||||
* Andrej Baran
|
||||
* Andrew Z Allen
|
||||
* András Parditka
|
||||
* Andy Hanson
|
||||
* Anil Anar
|
||||
* Anton Khlynovskiy
|
||||
* Anton Tolmachev
|
||||
* Arnav Singh
|
||||
* Arthur Ozga
|
||||
@@ -16,38 +25,56 @@ TypeScript is authored by:
|
||||
* Avery Morin
|
||||
* Basarat Ali Syed
|
||||
* Ben Duffield
|
||||
* Ben Mosher
|
||||
* Bill Ticehurst
|
||||
* Blake Embrey
|
||||
* @bootstraponline
|
||||
* Bowden Kelly
|
||||
* Brett Mayen
|
||||
* Bryan Forbes
|
||||
* Caitlin Potter
|
||||
* Charly POLY
|
||||
* Chris Bubernak
|
||||
* Christophe Vidal
|
||||
* Chuck Jazdzewski
|
||||
* Colby Russell
|
||||
* Colin Snover
|
||||
* Cotton Hou
|
||||
* Cyrus Najmabadi
|
||||
* Dafrok Zhang
|
||||
* Dan Corder
|
||||
* Dan Quirk
|
||||
* Daniel Hollocher
|
||||
* Daniel Rosenwasser
|
||||
* David Kmenta
|
||||
* David Li
|
||||
* David Souther
|
||||
* Denis Nedelyaev
|
||||
* Dick van den Brink
|
||||
* Dirk Bäumer
|
||||
* Dirk Holtwick
|
||||
* Dom Chen
|
||||
* Doug Ilijev
|
||||
* Elisée Maurer
|
||||
* Emilio García-Pumarino
|
||||
* Eric Tsang
|
||||
* Erik Edrosa
|
||||
* Ethan Resnick
|
||||
* Ethan Rubio
|
||||
* Evan Martin
|
||||
* Evan Sebastian
|
||||
* Eyas Sharaiha
|
||||
* Fabian Cook
|
||||
* @falsandtru
|
||||
* Frank Wallis
|
||||
* František Žiačik
|
||||
* Franklin Tse
|
||||
* František Žiacik
|
||||
* Gabe Moothart
|
||||
* Gabriel Isenberg
|
||||
* Gilad Peleg
|
||||
* Godfrey Chan
|
||||
* Graeme Wicksted
|
||||
* Guilherme Oenning
|
||||
* Guillaume Salles
|
||||
* Guy Bedford
|
||||
* Harald Niesche
|
||||
@@ -56,6 +83,7 @@ TypeScript is authored by:
|
||||
* Ingvar Stepanyan
|
||||
* Isiah Meadows
|
||||
* Ivo Gabe de Wolff
|
||||
* Jakub Młokosiewicz
|
||||
* James Whitney
|
||||
* Jason Freeman
|
||||
* Jason Killian
|
||||
@@ -65,41 +93,61 @@ TypeScript is authored by:
|
||||
* Jeffrey Morlan
|
||||
* Jesse Schalken
|
||||
* Jiri Tobisek
|
||||
* Joey Wilson
|
||||
* Johannes Rieken
|
||||
* John Vilk
|
||||
* Jonathan Bond-Caron
|
||||
* Jonathan Park
|
||||
* Jonathan Toland
|
||||
* Jonathan Turner
|
||||
* Jonathon Smith
|
||||
* Josh Abernathy
|
||||
* Josh Kalderimis
|
||||
* Josh Soref
|
||||
* Juan Luis Boya García
|
||||
* Julian Williams
|
||||
* Justin Bay
|
||||
* Justin Johansson
|
||||
* Kagami Sascha Rosylight
|
||||
* Kanchalai Tanglertsampan
|
||||
* Keith Mashinter
|
||||
* Ken Howard
|
||||
* Kenji Imamula
|
||||
* Kevin Lang
|
||||
* Kyle Kelley
|
||||
* Lorant Pinter
|
||||
* Lucien Greathouse
|
||||
* Lukas Elmer
|
||||
* Marin Marinov
|
||||
* Marius Schulz
|
||||
* Martin Vseticka
|
||||
* Masahiro Wakame
|
||||
* Matt McCutchen
|
||||
* Mattias Buelens
|
||||
* Mattias Buelens
|
||||
* Max Deepfield
|
||||
* Micah Zoltu
|
||||
* Michael
|
||||
* Michael Bromley
|
||||
* Mohamed Hegazy
|
||||
* Myles Megyesi
|
||||
* Nathan Shively-Sanders
|
||||
* Nathan Yee
|
||||
* Nicolas Henry
|
||||
* Nima Zahedi
|
||||
* Noah Chen
|
||||
* Noj Vek
|
||||
* Oleg Mihailik
|
||||
* Oleksandr Chekhovskyi
|
||||
* Omer Sheikh
|
||||
* Oskar Segersva¨rd
|
||||
* Patrick Zhong
|
||||
* Paul Jolly
|
||||
* Paul van Brenk
|
||||
* @pcbro
|
||||
* Pedro Maltez
|
||||
* Perry Jiang
|
||||
* Peter Burns
|
||||
* Philip Bulley
|
||||
* Piero Cangianiello
|
||||
* @piloopin
|
||||
@@ -108,34 +156,49 @@ TypeScript is authored by:
|
||||
* Punya Biswal
|
||||
* Rado Kirov
|
||||
* Richard Knoll
|
||||
* Richard Sentino
|
||||
* Robert Coie
|
||||
* Rohit Verma
|
||||
* Ron Buckton
|
||||
* Rostislav Galimsky
|
||||
* Rowan Wyborn
|
||||
* Ryan Cavanaugh
|
||||
* Ryohei Ikegami
|
||||
* Sam El-Husseini
|
||||
* Sarangan Rajamanickam
|
||||
* Sergey Shandar
|
||||
* Sheetal Nandi
|
||||
* Shengping Zhong
|
||||
* Shyyko Serhiy
|
||||
* Simon Hürlimann
|
||||
* Slawomir Sadziak
|
||||
* Solal Pirelli
|
||||
* Stan Thomas
|
||||
* Stanislav Sysoev
|
||||
* Steve Lucco
|
||||
* Sudheesh Singanamalla
|
||||
* Sébastien Arod
|
||||
* @T18970237136
|
||||
* Tarik Ozket
|
||||
* Tetsuharu Ohzeki
|
||||
* Thomas Loubiou
|
||||
* Tien Hoanhtien
|
||||
* Tim Lancina
|
||||
* Tim Perry
|
||||
* Tim Viiding-Spader
|
||||
* Tingan Ho
|
||||
* Todd Thomson
|
||||
* togru
|
||||
* Tomas Grubliauskas
|
||||
* Torben Fitschen
|
||||
* TruongSinh Tran-Nguyen
|
||||
* Vidar Tonaas Fauske
|
||||
* Viktor Zozulyak
|
||||
* Vilic Vane
|
||||
* Vladimir Matveev
|
||||
* Wesley Wigham
|
||||
* York Yao
|
||||
* @yortus
|
||||
* Yuichi Nukiyama
|
||||
* Zev Spitz
|
||||
* Zhengbo Li
|
||||
@@ -183,5 +183,3 @@ jake baseline-accept
|
||||
```
|
||||
|
||||
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
|
||||
|
||||
**Note** that `baseline-accept` should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run.
|
||||
|
||||
+4
-3
@@ -128,7 +128,8 @@ const es2016LibrarySourceMap = es2016LibrarySource.map(function(source) {
|
||||
|
||||
const es2017LibrarySource = [
|
||||
"es2017.object.d.ts",
|
||||
"es2017.sharedmemory.d.ts"
|
||||
"es2017.sharedmemory.d.ts",
|
||||
"es2017.string.d.ts",
|
||||
];
|
||||
|
||||
const es2017LibrarySourceMap = es2017LibrarySource.map(function(source) {
|
||||
@@ -176,7 +177,7 @@ for (const i in libraryTargets) {
|
||||
const configureNightlyJs = path.join(scriptsDirectory, "configureNightly.js");
|
||||
const configureNightlyTs = path.join(scriptsDirectory, "configureNightly.ts");
|
||||
const packageJson = "package.json";
|
||||
const programTs = path.join(compilerDirectory, "program.ts");
|
||||
const versionFile = path.join(compilerDirectory, "core.ts");
|
||||
|
||||
function needsUpdate(source: string | string[], dest: string | string[]): boolean {
|
||||
if (typeof source === "string" && typeof dest === "string") {
|
||||
@@ -284,7 +285,7 @@ gulp.task(configureNightlyJs, false, [], () => {
|
||||
|
||||
// Nightly management tasks
|
||||
gulp.task("configure-nightly", "Runs scripts/configureNightly.ts to prepare a build for nightly publishing", [configureNightlyJs], (done) => {
|
||||
exec(host, [configureNightlyJs, packageJson, programTs], done, done);
|
||||
exec(host, [configureNightlyJs, packageJson, versionFile], done, done);
|
||||
});
|
||||
gulp.task("publish-nightly", "Runs `npm publish --tag next` to create a new nightly build on npm", ["LKG"], () => {
|
||||
return runSequence("clean", "useDebugMode", "runtests", (done) => {
|
||||
|
||||
+37
-30
@@ -70,13 +70,16 @@ var compilerSources = [
|
||||
"visitor.ts",
|
||||
"transformers/destructuring.ts",
|
||||
"transformers/ts.ts",
|
||||
"transformers/module/es6.ts",
|
||||
"transformers/jsx.ts",
|
||||
"transformers/esnext.ts",
|
||||
"transformers/es2017.ts",
|
||||
"transformers/es2016.ts",
|
||||
"transformers/es2015.ts",
|
||||
"transformers/generators.ts",
|
||||
"transformers/es5.ts",
|
||||
"transformers/module/es2015.ts",
|
||||
"transformers/module/system.ts",
|
||||
"transformers/module/module.ts",
|
||||
"transformers/jsx.ts",
|
||||
"transformers/es7.ts",
|
||||
"transformers/generators.ts",
|
||||
"transformers/es6.ts",
|
||||
"transformer.ts",
|
||||
"sourcemap.ts",
|
||||
"comments.ts",
|
||||
@@ -104,13 +107,16 @@ var servicesSources = [
|
||||
"visitor.ts",
|
||||
"transformers/destructuring.ts",
|
||||
"transformers/ts.ts",
|
||||
"transformers/module/es6.ts",
|
||||
"transformers/jsx.ts",
|
||||
"transformers/esnext.ts",
|
||||
"transformers/es2017.ts",
|
||||
"transformers/es2016.ts",
|
||||
"transformers/es2015.ts",
|
||||
"transformers/generators.ts",
|
||||
"transformers/es5.ts",
|
||||
"transformers/module/es2015.ts",
|
||||
"transformers/module/system.ts",
|
||||
"transformers/module/module.ts",
|
||||
"transformers/jsx.ts",
|
||||
"transformers/es7.ts",
|
||||
"transformers/generators.ts",
|
||||
"transformers/es6.ts",
|
||||
"transformer.ts",
|
||||
"sourcemap.ts",
|
||||
"comments.ts",
|
||||
@@ -167,6 +173,7 @@ var servicesSources = [
|
||||
|
||||
var serverCoreSources = [
|
||||
"types.d.ts",
|
||||
"shared.ts",
|
||||
"utilities.ts",
|
||||
"scriptVersionCache.ts",
|
||||
"typingsCache.ts",
|
||||
@@ -189,6 +196,7 @@ var cancellationTokenSources = [
|
||||
|
||||
var typingsInstallerSources = [
|
||||
"../types.d.ts",
|
||||
"../shared.ts",
|
||||
"typingsInstaller.ts",
|
||||
"nodeTypingsInstaller.ts"
|
||||
].map(function (f) {
|
||||
@@ -242,13 +250,14 @@ var harnessSources = harnessCoreSources.concat([
|
||||
"convertToBase64.ts",
|
||||
"transpile.ts",
|
||||
"reuseProgramStructure.ts",
|
||||
"textStorage.ts",
|
||||
"cachingInServerLSHost.ts",
|
||||
"moduleResolution.ts",
|
||||
"tsconfigParsing.ts",
|
||||
"commandLineParsing.ts",
|
||||
"configurationExtension.ts",
|
||||
"convertCompilerOptionsFromJson.ts",
|
||||
"convertTypingOptionsFromJson.ts",
|
||||
"convertTypeAcquisitionFromJson.ts",
|
||||
"tsserverProjectSystem.ts",
|
||||
"compileOnSave.ts",
|
||||
"typingsInstaller.ts",
|
||||
@@ -295,7 +304,8 @@ var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) {
|
||||
|
||||
var es2017LibrarySource = [
|
||||
"es2017.object.d.ts",
|
||||
"es2017.sharedmemory.d.ts"
|
||||
"es2017.sharedmemory.d.ts",
|
||||
"es2017.string.d.ts",
|
||||
];
|
||||
|
||||
var es2017LibrarySourceMap = es2017LibrarySource.map(function (source) {
|
||||
@@ -343,18 +353,16 @@ function prependFile(prefixFile, destinationFile) {
|
||||
// concatenate a list of sourceFiles to a destinationFile
|
||||
function concatenateFiles(destinationFile, sourceFiles) {
|
||||
var temp = "temptemp";
|
||||
// Copy the first file to temp
|
||||
if (!fs.existsSync(sourceFiles[0])) {
|
||||
fail(sourceFiles[0] + " does not exist!");
|
||||
}
|
||||
jake.cpR(sourceFiles[0], temp, { silent: true });
|
||||
// append all files in sequence
|
||||
for (var i = 1; i < sourceFiles.length; i++) {
|
||||
var text = "";
|
||||
for (var i = 0; i < sourceFiles.length; i++) {
|
||||
if (!fs.existsSync(sourceFiles[i])) {
|
||||
fail(sourceFiles[i] + " does not exist!");
|
||||
}
|
||||
fs.appendFileSync(temp, fs.readFileSync(sourceFiles[i]));
|
||||
if (i > 0) { text += "\n\n"; }
|
||||
text += fs.readFileSync(sourceFiles[i]).toString().replace(/\r?\n/g, "\n");
|
||||
}
|
||||
fs.writeFileSync(temp, text);
|
||||
// Move the file to the final destination
|
||||
fs.renameSync(temp, destinationFile);
|
||||
}
|
||||
@@ -443,6 +451,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
|
||||
options += " --stripInternal";
|
||||
}
|
||||
|
||||
options += " --target es5 --noUnusedLocals --noUnusedParameters";
|
||||
|
||||
var cmd = host + " " + compilerPath + " " + options + " ";
|
||||
cmd = cmd + sources.join(" ");
|
||||
console.log(cmd + "\n");
|
||||
@@ -581,7 +591,7 @@ task("generate-diagnostics", [diagnosticInfoMapTs]);
|
||||
var configureNightlyJs = path.join(scriptsDirectory, "configureNightly.js");
|
||||
var configureNightlyTs = path.join(scriptsDirectory, "configureNightly.ts");
|
||||
var packageJson = "package.json";
|
||||
var programTs = path.join(compilerDirectory, "program.ts");
|
||||
var versionFile = path.join(compilerDirectory, "core.ts");
|
||||
|
||||
file(configureNightlyTs);
|
||||
|
||||
@@ -597,7 +607,7 @@ task("setDebugMode", function () {
|
||||
});
|
||||
|
||||
task("configure-nightly", [configureNightlyJs], function () {
|
||||
var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs;
|
||||
var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + versionFile;
|
||||
console.log(cmd);
|
||||
exec(cmd);
|
||||
}, { async: true });
|
||||
@@ -628,7 +638,7 @@ task("importDefinitelyTypedTests", [importDefinitelyTypedTestsJs], function () {
|
||||
|
||||
// Local target to build the compiler and services
|
||||
var tscFile = path.join(builtLocalDirectory, compilerFilename);
|
||||
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
|
||||
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false, { noMapRoot: true });
|
||||
|
||||
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
|
||||
var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js");
|
||||
@@ -918,7 +928,7 @@ function runConsoleTests(defaultReporter, runInParallel) {
|
||||
}
|
||||
|
||||
if (tests && tests.toLocaleLowerCase() === "rwc") {
|
||||
testTimeout = 400000;
|
||||
testTimeout = 800000;
|
||||
}
|
||||
|
||||
colors = process.env.colors || process.env.color;
|
||||
@@ -1074,12 +1084,10 @@ task("tests-debug", ["setDebugMode", "tests"]);
|
||||
// Makes the test results the new baseline
|
||||
desc("Makes the most recent test results the new baseline, overwriting the old baseline");
|
||||
task("baseline-accept", function () {
|
||||
acceptBaseline("");
|
||||
acceptBaseline(localBaseline, refBaseline);
|
||||
});
|
||||
|
||||
function acceptBaseline(containerFolder) {
|
||||
var sourceFolder = path.join(localBaseline, containerFolder);
|
||||
var targetFolder = path.join(refBaseline, containerFolder);
|
||||
function acceptBaseline(sourceFolder, targetFolder) {
|
||||
console.log('Accept baselines from ' + sourceFolder + ' to ' + targetFolder);
|
||||
var files = fs.readdirSync(sourceFolder);
|
||||
var deleteEnding = '.delete';
|
||||
@@ -1103,12 +1111,12 @@ function acceptBaseline(containerFolder) {
|
||||
|
||||
desc("Makes the most recent rwc test results the new baseline, overwriting the old baseline");
|
||||
task("baseline-accept-rwc", function () {
|
||||
acceptBaseline("rwc");
|
||||
acceptBaseline(localRwcBaseline, refRwcBaseline);
|
||||
});
|
||||
|
||||
desc("Makes the most recent test262 test results the new baseline, overwriting the old baseline");
|
||||
task("baseline-accept-test262", function () {
|
||||
acceptBaseline("test262");
|
||||
acceptBaseline(localTest262Baseline, refTest262Baseline);
|
||||
});
|
||||
|
||||
|
||||
@@ -1171,7 +1179,6 @@ task("update-sublime", ["local", serverFile], function () {
|
||||
var tslintRuleDir = "scripts/tslint";
|
||||
var tslintRules = [
|
||||
"nextLineRule",
|
||||
"preferConstRule",
|
||||
"booleanTriviaRule",
|
||||
"typeOperatorSpacingRule",
|
||||
"noInOperatorRule",
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->
|
||||
<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->
|
||||
|
||||
**TypeScript Version:** 1.8.0 / nightly (2.0.0-dev.201xxxxx)
|
||||
**TypeScript Version:** 2.1.1 / nightly (2.2.0-dev.201xxxxx)
|
||||
|
||||
**Code**
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
|
||||
**Expected behavior:**
|
||||
|
||||
**Actual behavior:**
|
||||
**Actual behavior:**
|
||||
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Set up NVM
|
||||
export NVM_DIR="/home/dotnet-bot/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||
|
||||
nvm install $1
|
||||
|
||||
npm uninstall typescript
|
||||
npm uninstall tslint
|
||||
npm install
|
||||
npm update
|
||||
npm test
|
||||
@@ -0,0 +1 @@
|
||||
* text eol=lf
|
||||
+5
-5
@@ -1,5 +1,5 @@
|
||||
# Read This!
|
||||
|
||||
**These files are not meant to be edited by hand.**
|
||||
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory.
|
||||
Running `jake LKG` will then appropriately update the files in this directory.
|
||||
# Read This!
|
||||
|
||||
**These files are not meant to be edited by hand.**
|
||||
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory.
|
||||
Running `jake LKG` will then appropriately update the files in this directory.
|
||||
|
||||
+15
-15
@@ -1,18 +1,18 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
"use strict";
|
||||
var fs = require("fs");
|
||||
function createCancellationToken(args) {
|
||||
|
||||
Vendored
+18215
-19045
File diff suppressed because it is too large
Load Diff
Vendored
+13738
-14641
File diff suppressed because it is too large
Load Diff
Vendored
+33
-29
@@ -1,29 +1,33 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference path="lib.dom.d.ts" />
|
||||
|
||||
interface DOMTokenList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
[Symbol.iterator](): IterableIterator<Node>
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
[Symbol.iterator](): IterableIterator<TNode>
|
||||
}
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.dom.d.ts" />
|
||||
|
||||
interface DOMTokenList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
[Symbol.iterator](): IterableIterator<Node>
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
[Symbol.iterator](): IterableIterator<TNode>
|
||||
}
|
||||
|
||||
Vendored
+92
-88
@@ -1,88 +1,92 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
delete(key: K): boolean;
|
||||
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): this;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new (): Map<any, any>;
|
||||
new <K, V>(entries?: [K, V][]): Map<K, V>;
|
||||
readonly prototype: Map<any, any>;
|
||||
}
|
||||
declare var Map: MapConstructor;
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V|undefined;
|
||||
has(key: K): boolean;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface WeakMap<K, V> {
|
||||
delete(key: K): boolean;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): this;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new (): WeakMap<any, any>;
|
||||
new <K, V>(entries?: [K, V][]): WeakMap<K, V>;
|
||||
readonly prototype: WeakMap<any, any>;
|
||||
}
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
interface Set<T> {
|
||||
add(value: T): this;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new (): Set<any>;
|
||||
new <T>(values?: T[]): Set<T>;
|
||||
readonly prototype: Set<any>;
|
||||
}
|
||||
declare var Set: SetConstructor;
|
||||
|
||||
interface ReadonlySet<T> {
|
||||
forEach(callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface WeakSet<T> {
|
||||
add(value: T): this;
|
||||
delete(value: T): boolean;
|
||||
has(value: T): boolean;
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new (): WeakSet<any>;
|
||||
new <T>(values?: T[]): WeakSet<T>;
|
||||
readonly prototype: WeakSet<any>;
|
||||
}
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
delete(key: K): boolean;
|
||||
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): this;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new (): Map<any, any>;
|
||||
new <K, V>(entries?: [K, V][]): Map<K, V>;
|
||||
readonly prototype: Map<any, any>;
|
||||
}
|
||||
declare var Map: MapConstructor;
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V|undefined;
|
||||
has(key: K): boolean;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface WeakMap<K, V> {
|
||||
delete(key: K): boolean;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): this;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new (): WeakMap<any, any>;
|
||||
new <K, V>(entries?: [K, V][]): WeakMap<K, V>;
|
||||
readonly prototype: WeakMap<any, any>;
|
||||
}
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
interface Set<T> {
|
||||
add(value: T): this;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new (): Set<any>;
|
||||
new <T>(values?: T[]): Set<T>;
|
||||
readonly prototype: Set<any>;
|
||||
}
|
||||
declare var Set: SetConstructor;
|
||||
|
||||
interface ReadonlySet<T> {
|
||||
forEach(callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
readonly size: number;
|
||||
}
|
||||
|
||||
interface WeakSet<T> {
|
||||
add(value: T): this;
|
||||
delete(value: T): boolean;
|
||||
has(value: T): boolean;
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new (): WeakSet<any>;
|
||||
new <T>(values?: T[]): WeakSet<T>;
|
||||
readonly prototype: WeakSet<any>;
|
||||
}
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
Vendored
+544
-540
File diff suppressed because it is too large
Load Diff
Vendored
+29
-25
@@ -1,26 +1,30 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference path="lib.es2015.core.d.ts" />
|
||||
/// <reference path="lib.es2015.collection.d.ts" />
|
||||
/// <reference path="lib.es2015.generator.d.ts" />
|
||||
/// <reference path="lib.es2015.iterable.d.ts" />
|
||||
/// <reference path="lib.es2015.promise.d.ts" />
|
||||
/// <reference path="lib.es2015.proxy.d.ts" />
|
||||
/// <reference path="lib.es2015.reflect.d.ts" />
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
/// <reference path="lib.es2015.symbol.wellknown.d.ts" />
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.core.d.ts" />
|
||||
/// <reference path="lib.es2015.collection.d.ts" />
|
||||
/// <reference path="lib.es2015.generator.d.ts" />
|
||||
/// <reference path="lib.es2015.iterable.d.ts" />
|
||||
/// <reference path="lib.es2015.promise.d.ts" />
|
||||
/// <reference path="lib.es2015.proxy.d.ts" />
|
||||
/// <reference path="lib.es2015.reflect.d.ts" />
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
/// <reference path="lib.es2015.symbol.wellknown.d.ts" />
|
||||
/// <reference path="lib.es5.d.ts" />
|
||||
Vendored
+32
-28
@@ -1,28 +1,32 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
interface GeneratorFunction extends Function { }
|
||||
|
||||
interface GeneratorFunctionConstructor {
|
||||
/**
|
||||
* Creates a new Generator function.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
new (...args: string[]): GeneratorFunction;
|
||||
(...args: string[]): GeneratorFunction;
|
||||
readonly prototype: GeneratorFunction;
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface GeneratorFunction extends Function { }
|
||||
|
||||
interface GeneratorFunctionConstructor {
|
||||
/**
|
||||
* Creates a new Generator function.
|
||||
* @param args A list of arguments the function accepts.
|
||||
*/
|
||||
new (...args: string[]): GeneratorFunction;
|
||||
(...args: string[]): GeneratorFunction;
|
||||
readonly prototype: GeneratorFunction;
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
|
||||
Vendored
+464
-460
@@ -1,461 +1,465 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that returns the default iterator for an object. Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
readonly iterator: symbol;
|
||||
}
|
||||
|
||||
interface IteratorResult<T> {
|
||||
done: boolean;
|
||||
value: T;
|
||||
}
|
||||
|
||||
interface Iterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
return?(value?: any): IteratorResult<T>;
|
||||
throw?(e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface Iterable<T> {
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
|
||||
|
||||
/**
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
*/
|
||||
from<T>(iterable: Iterable<T>): Array<T>;
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
[Symbol.iterator](): IterableIterator<[K,V]>;
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
keys(): IterableIterator<K>;
|
||||
values(): IterableIterator<V>;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new <K, V>(iterable: Iterable<[K, V]>): Map<K, V>;
|
||||
}
|
||||
|
||||
interface WeakMap<K, V> { }
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new <K, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
keys(): IterableIterator<T>;
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new <T>(iterable: Iterable<T>): Set<T>;
|
||||
}
|
||||
|
||||
interface WeakSet<T> { }
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T>(iterable: Iterable<T>): WeakSet<T>;
|
||||
}
|
||||
|
||||
interface Promise<T> { }
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T>(values: Iterable<T | PromiseLike<T>>): Promise<T>;
|
||||
}
|
||||
|
||||
declare namespace Reflect {
|
||||
function enumerate(target: any): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int8ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint8ClampedArray;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int16ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint16ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit float values. The contents are initialized to 0. If the requested number
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Float32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 64-bit float values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float64ArrayConstructor {
|
||||
new (elements: Iterable<number>): Float64Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that returns the default iterator for an object. Called by the semantics of the
|
||||
* for-of statement.
|
||||
*/
|
||||
readonly iterator: symbol;
|
||||
}
|
||||
|
||||
interface IteratorResult<T> {
|
||||
done: boolean;
|
||||
value: T;
|
||||
}
|
||||
|
||||
interface Iterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
return?(value?: any): IteratorResult<T>;
|
||||
throw?(e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface Iterable<T> {
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
|
||||
interface IterableIterator<T> extends Iterator<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from<T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
|
||||
|
||||
/**
|
||||
* Creates an array from an iterable object.
|
||||
* @param iterable An iterable object to convert to an array.
|
||||
*/
|
||||
from<T>(iterable: Iterable<T>): Array<T>;
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
[Symbol.iterator](): IterableIterator<[K,V]>;
|
||||
entries(): IterableIterator<[K, V]>;
|
||||
keys(): IterableIterator<K>;
|
||||
values(): IterableIterator<V>;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new <K, V>(iterable: Iterable<[K, V]>): Map<K, V>;
|
||||
}
|
||||
|
||||
interface WeakMap<K, V> { }
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new <K, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
entries(): IterableIterator<[T, T]>;
|
||||
keys(): IterableIterator<T>;
|
||||
values(): IterableIterator<T>;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new <T>(iterable: Iterable<T>): Set<T>;
|
||||
}
|
||||
|
||||
interface WeakSet<T> { }
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T>(iterable: Iterable<T>): WeakSet<T>;
|
||||
}
|
||||
|
||||
interface Promise<T> { }
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T>(values: Iterable<T | PromiseLike<T>>): Promise<T>;
|
||||
}
|
||||
|
||||
declare namespace Reflect {
|
||||
function enumerate(target: any): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int8ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint8Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint8ClampedArray;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int16ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint16ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint16Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Int32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Int32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Uint32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit float values. The contents are initialized to 0. If the requested number
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float32ArrayConstructor {
|
||||
new (elements: Iterable<number>): Float32Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 64-bit float values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
[Symbol.iterator](): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): IterableIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): IterableIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): IterableIterator<number>;
|
||||
}
|
||||
|
||||
interface Float64ArrayConstructor {
|
||||
new (elements: Iterable<number>): Float64Array;
|
||||
|
||||
/**
|
||||
* Creates an array from an array-like or iterable object.
|
||||
* @param arrayLike An array-like or iterable object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of the array.
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
|
||||
}
|
||||
Vendored
+273
-269
@@ -1,270 +1,274 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
interface Promise<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then(onfulfilled?: ((value: T) => T | PromiseLike<T>) | undefined | null, onrejected?: ((reason: any) => T | PromiseLike<T>) | undefined | null): Promise<T>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: ((value: T) => T | PromiseLike<T>) | undefined | null, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<TResult>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch(onrejected?: ((reason: any) => T | PromiseLike<T>) | undefined | null): Promise<T>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch<TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Promise<any>;
|
||||
|
||||
/**
|
||||
* Creates a new Promise.
|
||||
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
|
||||
* a resolve callback used resolve the promise with a value or the result of another promise,
|
||||
* and a reject callback used to reject the promise with a provided reason or error.
|
||||
*/
|
||||
new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<T1 | T2 | T3 | T4 | T5 | T6>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<T1 | T2 | T3 | T4 | T5>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<T1 | T2 | T3 | T4>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<T1 | T2 | T3>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<T1 | T2>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T>(values: (T | PromiseLike<T>)[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject(reason: any): Promise<never>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject<T>(reason: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise .
|
||||
* @returns A resolved promise.
|
||||
*/
|
||||
resolve(): Promise<void>;
|
||||
}
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
interface Promise<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then(onfulfilled?: ((value: T) => T | PromiseLike<T>) | undefined | null, onrejected?: ((reason: any) => T | PromiseLike<T>) | undefined | null): Promise<T>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: ((value: T) => T | PromiseLike<T>) | undefined | null, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled: (value: T) => TResult | PromiseLike<TResult>, onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<TResult>;
|
||||
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult1, TResult2>(onfulfilled: (value: T) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch(onrejected?: ((reason: any) => T | PromiseLike<T>) | undefined | null): Promise<T>;
|
||||
|
||||
/**
|
||||
* Attaches a callback for only the rejection of the Promise.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch<TResult>(onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<T | TResult>;
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Promise<any>;
|
||||
|
||||
/**
|
||||
* Creates a new Promise.
|
||||
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
|
||||
* a resolve callback used resolve the promise with a value or the result of another promise,
|
||||
* and a reject callback used to reject the promise with a provided reason or error.
|
||||
*/
|
||||
new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike <T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||
* resolve, or rejected when any Promise is rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<T1 | T2 | T3 | T4 | T5 | T6>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<T1 | T2 | T3 | T4 | T5>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<T1 | T2 | T3 | T4>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<T1 | T2 | T3>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<T1 | T2>;
|
||||
|
||||
/**
|
||||
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
|
||||
* or rejected.
|
||||
* @param values An array of Promises.
|
||||
* @returns A new Promise.
|
||||
*/
|
||||
race<T>(values: (T | PromiseLike<T>)[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject(reason: any): Promise<never>;
|
||||
|
||||
/**
|
||||
* Creates a new rejected promise for the provided reason.
|
||||
* @param reason The reason the promise was rejected.
|
||||
* @returns A new rejected Promise.
|
||||
*/
|
||||
reject<T>(reason: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise for the provided value.
|
||||
* @param value A promise.
|
||||
* @returns A promise whose internal state matches the provided promise.
|
||||
*/
|
||||
resolve<T>(value: T | PromiseLike<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new resolved promise .
|
||||
* @returns A resolved promise.
|
||||
*/
|
||||
resolve(): Promise<void>;
|
||||
}
|
||||
|
||||
declare var Promise: PromiseConstructor;
|
||||
Vendored
+42
-38
@@ -1,38 +1,42 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
interface ProxyHandler<T> {
|
||||
getPrototypeOf? (target: T): any;
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
isExtensible? (target: T): boolean;
|
||||
preventExtensions? (target: T): boolean;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor;
|
||||
has? (target: T, p: PropertyKey): boolean;
|
||||
get? (target: T, p: PropertyKey, receiver: any): any;
|
||||
set? (target: T, p: PropertyKey, value: any, receiver: any): boolean;
|
||||
deleteProperty? (target: T, p: PropertyKey): boolean;
|
||||
defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
enumerate? (target: T): PropertyKey[];
|
||||
ownKeys? (target: T): PropertyKey[];
|
||||
apply? (target: T, thisArg: any, argArray?: any): any;
|
||||
construct? (target: T, thisArg: any, argArray?: any): any;
|
||||
}
|
||||
|
||||
interface ProxyConstructor {
|
||||
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
|
||||
new <T>(target: T, handler: ProxyHandler<T>): T
|
||||
}
|
||||
declare var Proxy: ProxyConstructor;
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface ProxyHandler<T> {
|
||||
getPrototypeOf? (target: T): {} | null;
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
isExtensible? (target: T): boolean;
|
||||
preventExtensions? (target: T): boolean;
|
||||
getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor;
|
||||
has? (target: T, p: PropertyKey): boolean;
|
||||
get? (target: T, p: PropertyKey, receiver: any): any;
|
||||
set? (target: T, p: PropertyKey, value: any, receiver: any): boolean;
|
||||
deleteProperty? (target: T, p: PropertyKey): boolean;
|
||||
defineProperty? (target: T, p: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
enumerate? (target: T): PropertyKey[];
|
||||
ownKeys? (target: T): PropertyKey[];
|
||||
apply? (target: T, thisArg: any, argArray?: any): any;
|
||||
construct? (target: T, argArray: any, newTarget?: any): {};
|
||||
}
|
||||
|
||||
interface ProxyConstructor {
|
||||
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
|
||||
new <T>(target: T, handler: ProxyHandler<T>): T
|
||||
}
|
||||
declare var Proxy: ProxyConstructor;
|
||||
|
||||
Vendored
+34
-30
@@ -1,31 +1,35 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
declare namespace Reflect {
|
||||
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
|
||||
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;
|
||||
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
|
||||
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
|
||||
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
function getPrototypeOf(target: any): any;
|
||||
function has(target: any, propertyKey: PropertyKey): boolean;
|
||||
function isExtensible(target: any): boolean;
|
||||
function ownKeys(target: any): Array<PropertyKey>;
|
||||
function preventExtensions(target: any): boolean;
|
||||
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
|
||||
function setPrototypeOf(target: any, proto: any): boolean;
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
declare namespace Reflect {
|
||||
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
|
||||
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;
|
||||
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
function deleteProperty(target: any, propertyKey: PropertyKey): boolean;
|
||||
function get(target: any, propertyKey: PropertyKey, receiver?: any): any;
|
||||
function getOwnPropertyDescriptor(target: any, propertyKey: PropertyKey): PropertyDescriptor;
|
||||
function getPrototypeOf(target: any): any;
|
||||
function has(target: any, propertyKey: PropertyKey): boolean;
|
||||
function isExtensible(target: any): boolean;
|
||||
function ownKeys(target: any): Array<PropertyKey>;
|
||||
function preventExtensions(target: any): boolean;
|
||||
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
|
||||
function setPrototypeOf(target: any, proto: any): boolean;
|
||||
}
|
||||
Vendored
+55
-51
@@ -1,52 +1,56 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
interface Symbol {
|
||||
/** Returns a string representation of an object. */
|
||||
toString(): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): Object;
|
||||
}
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Symbol;
|
||||
|
||||
/**
|
||||
* Returns a new unique Symbol value.
|
||||
* @param description Description of the new Symbol object.
|
||||
*/
|
||||
(description?: string|number): symbol;
|
||||
|
||||
/**
|
||||
* Returns a Symbol object from the global symbol registry matching the given key if found.
|
||||
* Otherwise, returns a new symbol with this key.
|
||||
* @param key key to search for.
|
||||
*/
|
||||
for(key: string): symbol;
|
||||
|
||||
/**
|
||||
* Returns a key from the global symbol registry matching the given Symbol if found.
|
||||
* Otherwise, returns a undefined.
|
||||
* @param sym Symbol to find the key for.
|
||||
*/
|
||||
keyFor(sym: symbol): string | undefined;
|
||||
}
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface Symbol {
|
||||
/** Returns a string representation of an object. */
|
||||
toString(): string;
|
||||
|
||||
/** Returns the primitive value of the specified object. */
|
||||
valueOf(): Object;
|
||||
}
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A reference to the prototype.
|
||||
*/
|
||||
readonly prototype: Symbol;
|
||||
|
||||
/**
|
||||
* Returns a new unique Symbol value.
|
||||
* @param description Description of the new Symbol object.
|
||||
*/
|
||||
(description?: string|number): symbol;
|
||||
|
||||
/**
|
||||
* Returns a Symbol object from the global symbol registry matching the given key if found.
|
||||
* Otherwise, returns a new symbol with this key.
|
||||
* @param key key to search for.
|
||||
*/
|
||||
for(key: string): symbol;
|
||||
|
||||
/**
|
||||
* Returns a key from the global symbol registry matching the given Symbol if found.
|
||||
* Otherwise, returns a undefined.
|
||||
* @param sym Symbol to find the key for.
|
||||
*/
|
||||
keyFor(sym: symbol): string | undefined;
|
||||
}
|
||||
|
||||
declare var Symbol: SymbolConstructor;
|
||||
Vendored
+346
-342
@@ -1,343 +1,347 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that determines if a constructor object recognizes an object as one of the
|
||||
* constructor’s instances. Called by the semantics of the instanceof operator.
|
||||
*/
|
||||
readonly hasInstance: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object should flatten to its array elements
|
||||
* by Array.prototype.concat.
|
||||
*/
|
||||
readonly isConcatSpreadable: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that matches the regular expression against a string. Called
|
||||
* by the String.prototype.match method.
|
||||
*/
|
||||
readonly match: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that replaces matched substrings of a string. Called by the
|
||||
* String.prototype.replace method.
|
||||
*/
|
||||
readonly replace: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that returns the index within a string that matches the
|
||||
* regular expression. Called by the String.prototype.search method.
|
||||
*/
|
||||
readonly search: symbol;
|
||||
|
||||
/**
|
||||
* A function valued property that is the constructor function that is used to create
|
||||
* derived objects.
|
||||
*/
|
||||
readonly species: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that splits a string at the indices that match the regular
|
||||
* expression. Called by the String.prototype.split method.
|
||||
*/
|
||||
readonly split: symbol;
|
||||
|
||||
/**
|
||||
* A method that converts an object to a corresponding primitive value.
|
||||
* Called by the ToPrimitive abstract operation.
|
||||
*/
|
||||
readonly toPrimitive: symbol;
|
||||
|
||||
/**
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built-in method Object.prototype.toString.
|
||||
*/
|
||||
readonly toStringTag: symbol;
|
||||
|
||||
/**
|
||||
* An Object whose own property names are property names that are excluded from the 'with'
|
||||
* environment bindings of the associated objects.
|
||||
*/
|
||||
readonly unscopables: symbol;
|
||||
}
|
||||
|
||||
interface Symbol {
|
||||
readonly [Symbol.toStringTag]: "Symbol";
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Returns an object whose properties have the value 'true'
|
||||
* when they will be absent when used in a 'with' statement.
|
||||
*/
|
||||
[Symbol.unscopables](): {
|
||||
copyWithin: boolean;
|
||||
entries: boolean;
|
||||
fill: boolean;
|
||||
find: boolean;
|
||||
findIndex: boolean;
|
||||
keys: boolean;
|
||||
values: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface Date {
|
||||
/**
|
||||
* Converts a Date object to a string.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: "default"): string;
|
||||
/**
|
||||
* Converts a Date object to a string.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: "string"): string;
|
||||
/**
|
||||
* Converts a Date object to a number.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: "number"): number;
|
||||
/**
|
||||
* Converts a Date object to a string or number.
|
||||
*
|
||||
* @param hint The strings "number", "string", or "default" to specify what primitive to return.
|
||||
*
|
||||
* @throws {TypeError} If 'hint' was given something other than "number", "string", or "default".
|
||||
* @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default".
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: string): string | number;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
readonly [Symbol.toStringTag]: "Map";
|
||||
}
|
||||
|
||||
interface WeakMap<K, V>{
|
||||
readonly [Symbol.toStringTag]: "WeakMap";
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
readonly [Symbol.toStringTag]: "Set";
|
||||
}
|
||||
|
||||
interface WeakSet<T> {
|
||||
readonly [Symbol.toStringTag]: "WeakSet";
|
||||
}
|
||||
|
||||
interface JSON {
|
||||
readonly [Symbol.toStringTag]: "JSON";
|
||||
}
|
||||
|
||||
interface Function {
|
||||
/**
|
||||
* Determines whether the given value inherits from this function if this function was used
|
||||
* as a constructor function.
|
||||
*
|
||||
* A constructor function can control which objects are recognized as its instances by
|
||||
* 'instanceof' by overriding this method.
|
||||
*/
|
||||
[Symbol.hasInstance](value: any): boolean;
|
||||
}
|
||||
|
||||
interface GeneratorFunction extends Function {
|
||||
readonly [Symbol.toStringTag]: "GeneratorFunction";
|
||||
}
|
||||
|
||||
interface Math {
|
||||
readonly [Symbol.toStringTag]: "Math";
|
||||
}
|
||||
|
||||
interface Promise<T> {
|
||||
readonly [Symbol.toStringTag]: "Promise";
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
readonly [Symbol.species]: Function;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Matches a string with this regular expression, and returns an array containing the results of
|
||||
* that search.
|
||||
* @param string A string to search within.
|
||||
*/
|
||||
[Symbol.match](string: string): RegExpMatchArray | null;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replaceValue A String object or string literal containing the text to replace for every
|
||||
* successful match of this regular expression.
|
||||
*/
|
||||
[Symbol.replace](string: string, replaceValue: string): string;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
[Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string;
|
||||
|
||||
/**
|
||||
* Finds the position beginning first substring match in a regular expression search
|
||||
* using this regular expression.
|
||||
*
|
||||
* @param string The string to search within.
|
||||
*/
|
||||
[Symbol.search](string: string): number;
|
||||
|
||||
/**
|
||||
* Returns an array of substrings that were delimited by strings in the original input that
|
||||
* match against this regular expression.
|
||||
*
|
||||
* If the regular expression contains capturing parentheses, then each time this
|
||||
* regular expression matches, the results (including any undefined results) of the
|
||||
* capturing parentheses are spliced.
|
||||
*
|
||||
* @param string string value to split
|
||||
* @param limit if not undefined, the output array is truncated so that it contains no more
|
||||
* than 'limit' elements.
|
||||
*/
|
||||
[Symbol.split](string: string, limit?: number): string[];
|
||||
}
|
||||
|
||||
interface RegExpConstructor {
|
||||
[Symbol.species](): RegExpConstructor;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Matches a string an object that supports being matched against, and returns an array containing the results of that search.
|
||||
* @param matcher An object that supports being matched against.
|
||||
*/
|
||||
match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using an object that supports replacement within a string.
|
||||
* @param searchValue A object can search for and replace matches within a string.
|
||||
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
||||
*/
|
||||
replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using an object that supports replacement within a string.
|
||||
* @param searchValue A object can search for and replace matches within a string.
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string;
|
||||
|
||||
/**
|
||||
* Finds the first substring match in a regular expression search.
|
||||
* @param searcher An object which supports searching within a string.
|
||||
*/
|
||||
search(searcher: { [Symbol.search](string: string): number; }): number;
|
||||
|
||||
/**
|
||||
* Split a string into substrings using the specified separator and return them as an array.
|
||||
* @param splitter An object that can split a string.
|
||||
* @param limit A value used to limit the number of elements returned in the array.
|
||||
*/
|
||||
split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a raw buffer of binary data, which is used to store data for the
|
||||
* different typed arrays. ArrayBuffers cannot be read from or written to directly,
|
||||
* but can be passed to a typed array or DataView Object to interpret the raw
|
||||
* buffer as needed.
|
||||
*/
|
||||
interface ArrayBuffer {
|
||||
readonly [Symbol.toStringTag]: "ArrayBuffer";
|
||||
}
|
||||
|
||||
interface DataView {
|
||||
readonly [Symbol.toStringTag]: "DataView";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
readonly [Symbol.toStringTag]: "Int8Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
readonly [Symbol.toStringTag]: "UInt8Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
readonly [Symbol.toStringTag]: "Uint8ClampedArray";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
readonly [Symbol.toStringTag]: "Int16Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
readonly [Symbol.toStringTag]: "Uint16Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
readonly [Symbol.toStringTag]: "Int32Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
readonly [Symbol.toStringTag]: "Uint32Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit float values. The contents are initialized to 0. If the requested number
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
readonly [Symbol.toStringTag]: "Float32Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 64-bit float values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
readonly [Symbol.toStringTag]: "Float64Array";
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
* A method that determines if a constructor object recognizes an object as one of the
|
||||
* constructor’s instances. Called by the semantics of the instanceof operator.
|
||||
*/
|
||||
readonly hasInstance: symbol;
|
||||
|
||||
/**
|
||||
* A Boolean value that if true indicates that an object should flatten to its array elements
|
||||
* by Array.prototype.concat.
|
||||
*/
|
||||
readonly isConcatSpreadable: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that matches the regular expression against a string. Called
|
||||
* by the String.prototype.match method.
|
||||
*/
|
||||
readonly match: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that replaces matched substrings of a string. Called by the
|
||||
* String.prototype.replace method.
|
||||
*/
|
||||
readonly replace: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that returns the index within a string that matches the
|
||||
* regular expression. Called by the String.prototype.search method.
|
||||
*/
|
||||
readonly search: symbol;
|
||||
|
||||
/**
|
||||
* A function valued property that is the constructor function that is used to create
|
||||
* derived objects.
|
||||
*/
|
||||
readonly species: symbol;
|
||||
|
||||
/**
|
||||
* A regular expression method that splits a string at the indices that match the regular
|
||||
* expression. Called by the String.prototype.split method.
|
||||
*/
|
||||
readonly split: symbol;
|
||||
|
||||
/**
|
||||
* A method that converts an object to a corresponding primitive value.
|
||||
* Called by the ToPrimitive abstract operation.
|
||||
*/
|
||||
readonly toPrimitive: symbol;
|
||||
|
||||
/**
|
||||
* A String value that is used in the creation of the default string description of an object.
|
||||
* Called by the built-in method Object.prototype.toString.
|
||||
*/
|
||||
readonly toStringTag: symbol;
|
||||
|
||||
/**
|
||||
* An Object whose own property names are property names that are excluded from the 'with'
|
||||
* environment bindings of the associated objects.
|
||||
*/
|
||||
readonly unscopables: symbol;
|
||||
}
|
||||
|
||||
interface Symbol {
|
||||
readonly [Symbol.toStringTag]: "Symbol";
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Returns an object whose properties have the value 'true'
|
||||
* when they will be absent when used in a 'with' statement.
|
||||
*/
|
||||
[Symbol.unscopables](): {
|
||||
copyWithin: boolean;
|
||||
entries: boolean;
|
||||
fill: boolean;
|
||||
find: boolean;
|
||||
findIndex: boolean;
|
||||
keys: boolean;
|
||||
values: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface Date {
|
||||
/**
|
||||
* Converts a Date object to a string.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: "default"): string;
|
||||
/**
|
||||
* Converts a Date object to a string.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: "string"): string;
|
||||
/**
|
||||
* Converts a Date object to a number.
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: "number"): number;
|
||||
/**
|
||||
* Converts a Date object to a string or number.
|
||||
*
|
||||
* @param hint The strings "number", "string", or "default" to specify what primitive to return.
|
||||
*
|
||||
* @throws {TypeError} If 'hint' was given something other than "number", "string", or "default".
|
||||
* @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default".
|
||||
*/
|
||||
[Symbol.toPrimitive](hint: string): string | number;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
readonly [Symbol.toStringTag]: "Map";
|
||||
}
|
||||
|
||||
interface WeakMap<K, V>{
|
||||
readonly [Symbol.toStringTag]: "WeakMap";
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
readonly [Symbol.toStringTag]: "Set";
|
||||
}
|
||||
|
||||
interface WeakSet<T> {
|
||||
readonly [Symbol.toStringTag]: "WeakSet";
|
||||
}
|
||||
|
||||
interface JSON {
|
||||
readonly [Symbol.toStringTag]: "JSON";
|
||||
}
|
||||
|
||||
interface Function {
|
||||
/**
|
||||
* Determines whether the given value inherits from this function if this function was used
|
||||
* as a constructor function.
|
||||
*
|
||||
* A constructor function can control which objects are recognized as its instances by
|
||||
* 'instanceof' by overriding this method.
|
||||
*/
|
||||
[Symbol.hasInstance](value: any): boolean;
|
||||
}
|
||||
|
||||
interface GeneratorFunction extends Function {
|
||||
readonly [Symbol.toStringTag]: "GeneratorFunction";
|
||||
}
|
||||
|
||||
interface Math {
|
||||
readonly [Symbol.toStringTag]: "Math";
|
||||
}
|
||||
|
||||
interface Promise<T> {
|
||||
readonly [Symbol.toStringTag]: "Promise";
|
||||
}
|
||||
|
||||
interface PromiseConstructor {
|
||||
readonly [Symbol.species]: Function;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Matches a string with this regular expression, and returns an array containing the results of
|
||||
* that search.
|
||||
* @param string A string to search within.
|
||||
*/
|
||||
[Symbol.match](string: string): RegExpMatchArray | null;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replaceValue A String object or string literal containing the text to replace for every
|
||||
* successful match of this regular expression.
|
||||
*/
|
||||
[Symbol.replace](string: string, replaceValue: string): string;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using this regular expression.
|
||||
* @param string A String object or string literal whose contents matching against
|
||||
* this regular expression will be replaced
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
[Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string;
|
||||
|
||||
/**
|
||||
* Finds the position beginning first substring match in a regular expression search
|
||||
* using this regular expression.
|
||||
*
|
||||
* @param string The string to search within.
|
||||
*/
|
||||
[Symbol.search](string: string): number;
|
||||
|
||||
/**
|
||||
* Returns an array of substrings that were delimited by strings in the original input that
|
||||
* match against this regular expression.
|
||||
*
|
||||
* If the regular expression contains capturing parentheses, then each time this
|
||||
* regular expression matches, the results (including any undefined results) of the
|
||||
* capturing parentheses are spliced.
|
||||
*
|
||||
* @param string string value to split
|
||||
* @param limit if not undefined, the output array is truncated so that it contains no more
|
||||
* than 'limit' elements.
|
||||
*/
|
||||
[Symbol.split](string: string, limit?: number): string[];
|
||||
}
|
||||
|
||||
interface RegExpConstructor {
|
||||
[Symbol.species](): RegExpConstructor;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Matches a string an object that supports being matched against, and returns an array containing the results of that search.
|
||||
* @param matcher An object that supports being matched against.
|
||||
*/
|
||||
match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using an object that supports replacement within a string.
|
||||
* @param searchValue A object can search for and replace matches within a string.
|
||||
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
||||
*/
|
||||
replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string;
|
||||
|
||||
/**
|
||||
* Replaces text in a string, using an object that supports replacement within a string.
|
||||
* @param searchValue A object can search for and replace matches within a string.
|
||||
* @param replacer A function that returns the replacement text.
|
||||
*/
|
||||
replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string;
|
||||
|
||||
/**
|
||||
* Finds the first substring match in a regular expression search.
|
||||
* @param searcher An object which supports searching within a string.
|
||||
*/
|
||||
search(searcher: { [Symbol.search](string: string): number; }): number;
|
||||
|
||||
/**
|
||||
* Split a string into substrings using the specified separator and return them as an array.
|
||||
* @param splitter An object that can split a string.
|
||||
* @param limit A value used to limit the number of elements returned in the array.
|
||||
*/
|
||||
split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a raw buffer of binary data, which is used to store data for the
|
||||
* different typed arrays. ArrayBuffers cannot be read from or written to directly,
|
||||
* but can be passed to a typed array or DataView Object to interpret the raw
|
||||
* buffer as needed.
|
||||
*/
|
||||
interface ArrayBuffer {
|
||||
readonly [Symbol.toStringTag]: "ArrayBuffer";
|
||||
}
|
||||
|
||||
interface DataView {
|
||||
readonly [Symbol.toStringTag]: "DataView";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int8Array {
|
||||
readonly [Symbol.toStringTag]: "Int8Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8Array {
|
||||
readonly [Symbol.toStringTag]: "UInt8Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.
|
||||
* If the requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint8ClampedArray {
|
||||
readonly [Symbol.toStringTag]: "Uint8ClampedArray";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int16Array {
|
||||
readonly [Symbol.toStringTag]: "Int16Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint16Array {
|
||||
readonly [Symbol.toStringTag]: "Uint16Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit signed integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Int32Array {
|
||||
readonly [Symbol.toStringTag]: "Int32Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the
|
||||
* requested number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Uint32Array {
|
||||
readonly [Symbol.toStringTag]: "Uint32Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 32-bit float values. The contents are initialized to 0. If the requested number
|
||||
* of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float32Array {
|
||||
readonly [Symbol.toStringTag]: "Float32Array";
|
||||
}
|
||||
|
||||
/**
|
||||
* A typed array of 64-bit float values. The contents are initialized to 0. If the requested
|
||||
* number of bytes could not be allocated an exception is raised.
|
||||
*/
|
||||
interface Float64Array {
|
||||
readonly [Symbol.toStringTag]: "Float64Array";
|
||||
}
|
||||
Vendored
+117
-104
@@ -1,105 +1,118 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: T, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int8Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint8Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArray {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int16Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint16Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int32Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint32Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Float32Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Float64Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: T, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: T, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int8Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint8Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArray {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int16Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint16Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Int32Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Uint32Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Float32Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
|
||||
interface Float64Array {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
* @param searchElement The element to search for.
|
||||
* @param fromIndex The position in this array at which to begin searching for searchElement.
|
||||
*/
|
||||
includes(searchElement: number, fromIndex?: number): boolean;
|
||||
}
|
||||
Vendored
+21
-17
@@ -1,18 +1,22 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference path="lib.es2015.d.ts" />
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.d.ts" />
|
||||
/// <reference path="lib.es2016.array.include.d.ts" />
|
||||
Vendored
+24
-19
@@ -1,19 +1,24 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference path="lib.es2016.d.ts" />
|
||||
/// <reference path="lib.es2017.object.d.ts" />
|
||||
/// <reference path="lib.es2017.sharedmemory.d.ts" />
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2016.d.ts" />
|
||||
/// <reference path="lib.es2017.object.d.ts" />
|
||||
/// <reference path="lib.es2017.sharedmemory.d.ts" />
|
||||
/// <reference path="lib.es2017.string.d.ts" />
|
||||
|
||||
Vendored
+45
-30
@@ -1,30 +1,45 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Returns an array of values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
values<T>(o: { [s: string]: T }): T[];
|
||||
values(o: any): any[];
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
entries<T>(o: { [s: string]: T }): [string, T][];
|
||||
entries(o: any): [string, any][];
|
||||
}
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Returns an array of values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
values<T>(o: { [s: string]: T }): T[];
|
||||
|
||||
/**
|
||||
* Returns an array of values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
values(o: any): any[];
|
||||
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
entries<T>(o: { [s: string]: T }): [string, T][];
|
||||
|
||||
/**
|
||||
* Returns an array of key/values of the enumerable properties of an object
|
||||
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
|
||||
*/
|
||||
entries(o: any): [string, any][];
|
||||
}
|
||||
|
||||
Vendored
+46
-42
@@ -1,43 +1,47 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
/// <reference path="lib.es2015.symbol.wellknown.d.ts" />
|
||||
|
||||
interface SharedArrayBuffer {
|
||||
/**
|
||||
* Read-only. The length of the ArrayBuffer (in bytes).
|
||||
*/
|
||||
readonly byteLength: number;
|
||||
|
||||
/*
|
||||
* The SharedArrayBuffer constructor's length property whose value is 1.
|
||||
*/
|
||||
length: number;
|
||||
/**
|
||||
* Returns a section of an SharedArrayBuffer.
|
||||
*/
|
||||
slice(begin:number, end?:number): SharedArrayBuffer;
|
||||
readonly [Symbol.species]: SharedArrayBuffer;
|
||||
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
|
||||
}
|
||||
|
||||
interface SharedArrayBufferConstructor {
|
||||
readonly prototype: SharedArrayBuffer;
|
||||
new (byteLength: number): SharedArrayBuffer;
|
||||
}
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
/// <reference path="lib.es2015.symbol.wellknown.d.ts" />
|
||||
|
||||
interface SharedArrayBuffer {
|
||||
/**
|
||||
* Read-only. The length of the ArrayBuffer (in bytes).
|
||||
*/
|
||||
readonly byteLength: number;
|
||||
|
||||
/*
|
||||
* The SharedArrayBuffer constructor's length property whose value is 1.
|
||||
*/
|
||||
length: number;
|
||||
/**
|
||||
* Returns a section of an SharedArrayBuffer.
|
||||
*/
|
||||
slice(begin:number, end?:number): SharedArrayBuffer;
|
||||
readonly [Symbol.species]: SharedArrayBuffer;
|
||||
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
|
||||
}
|
||||
|
||||
interface SharedArrayBufferConstructor {
|
||||
readonly prototype: SharedArrayBuffer;
|
||||
new (byteLength: number): SharedArrayBuffer;
|
||||
}
|
||||
|
||||
declare var SharedArrayBuffer: SharedArrayBufferConstructor;
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
||||
* The padding is applied from the start (left) of the current string.
|
||||
*
|
||||
* @param maxLength The length of the resulting string once the current string has been padded.
|
||||
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
|
||||
*
|
||||
* @param fillString The string to pad the current string with.
|
||||
* If this string is too long, it will be truncated and the left-most part will be applied.
|
||||
* The default value for this parameter is " " (U+0020).
|
||||
*/
|
||||
padStart(maxLength: number, fillString?: string): string;
|
||||
|
||||
/**
|
||||
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
||||
* The padding is applied from the end (right) of the current string.
|
||||
*
|
||||
* @param maxLength The length of the resulting string once the current string has been padded.
|
||||
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
|
||||
*
|
||||
* @param fillString The string to pad the current string with.
|
||||
* If this string is too long, it will be truncated and the left-most part will be applied.
|
||||
* The default value for this parameter is " " (U+0020).
|
||||
*/
|
||||
padEnd(maxLength: number, fillString?: string): string;
|
||||
}
|
||||
Vendored
+4195
-4124
File diff suppressed because it is too large
Load Diff
Vendored
+19950
-20759
File diff suppressed because it is too large
Load Diff
Vendored
+311
-307
@@ -1,307 +1,311 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// Windows Script Host APIS
|
||||
/////////////////////////////
|
||||
|
||||
|
||||
interface ActiveXObject {
|
||||
new (s: string): any;
|
||||
}
|
||||
declare var ActiveXObject: ActiveXObject;
|
||||
|
||||
interface ITextWriter {
|
||||
Write(s: string): void;
|
||||
WriteLine(s: string): void;
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
interface TextStreamBase {
|
||||
/**
|
||||
* The column number of the current character position in an input stream.
|
||||
*/
|
||||
Column: number;
|
||||
|
||||
/**
|
||||
* The current line number in an input stream.
|
||||
*/
|
||||
Line: number;
|
||||
|
||||
/**
|
||||
* Closes a text stream.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If
|
||||
* you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
*/
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
interface TextStreamWriter extends TextStreamBase {
|
||||
/**
|
||||
* Sends a string to an output stream.
|
||||
*/
|
||||
Write(s: string): void;
|
||||
|
||||
/**
|
||||
* Sends a specified number of blank lines (newline characters) to an output stream.
|
||||
*/
|
||||
WriteBlankLines(intLines: number): void;
|
||||
|
||||
/**
|
||||
* Sends a string followed by a newline character to an output stream.
|
||||
*/
|
||||
WriteLine(s: string): void;
|
||||
}
|
||||
|
||||
interface TextStreamReader extends TextStreamBase {
|
||||
/**
|
||||
* Returns a specified number of characters from an input stream, starting at the current pointer position.
|
||||
* Does not return until the ENTER key is pressed.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
Read(characters: number): string;
|
||||
|
||||
/**
|
||||
* Returns all characters from an input stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadAll(): string;
|
||||
|
||||
/**
|
||||
* Returns an entire line from an input stream.
|
||||
* Although this method extracts the newline character, it does not add it to the returned string.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadLine(): string;
|
||||
|
||||
/**
|
||||
* Skips a specified number of characters when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
|
||||
*/
|
||||
Skip(characters: number): void;
|
||||
|
||||
/**
|
||||
* Skips the next line when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode, not writing or appending mode.
|
||||
*/
|
||||
SkipLine(): void;
|
||||
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a line.
|
||||
*/
|
||||
AtEndOfLine: boolean;
|
||||
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a stream.
|
||||
*/
|
||||
AtEndOfStream: boolean;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
/**
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by
|
||||
* a newline (under CScript.exe).
|
||||
*/
|
||||
Echo(s: any): void;
|
||||
|
||||
/**
|
||||
* Exposes the write-only error output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdErr: TextStreamWriter;
|
||||
|
||||
/**
|
||||
* Exposes the write-only output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdOut: TextStreamWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
|
||||
/**
|
||||
* The full path of the currently running script.
|
||||
*/
|
||||
ScriptFullName: string;
|
||||
|
||||
/**
|
||||
* Forces the script to stop immediately, with an optional exit code.
|
||||
*/
|
||||
Quit(exitCode?: number): number;
|
||||
|
||||
/**
|
||||
* The Windows Script Host build version number.
|
||||
*/
|
||||
BuildVersion: number;
|
||||
|
||||
/**
|
||||
* Fully qualified path of the host executable.
|
||||
*/
|
||||
FullName: string;
|
||||
|
||||
/**
|
||||
* Gets/sets the script mode - interactive(true) or batch(false).
|
||||
*/
|
||||
Interactive: boolean;
|
||||
|
||||
/**
|
||||
* The name of the host executable (WScript.exe or CScript.exe).
|
||||
*/
|
||||
Name: string;
|
||||
|
||||
/**
|
||||
* Path of the directory containing the host executable.
|
||||
*/
|
||||
Path: string;
|
||||
|
||||
/**
|
||||
* The filename of the currently running script.
|
||||
*/
|
||||
ScriptName: string;
|
||||
|
||||
/**
|
||||
* Exposes the read-only input stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdIn: TextStreamReader;
|
||||
|
||||
/**
|
||||
* Windows Script Host version
|
||||
*/
|
||||
Version: string;
|
||||
|
||||
/**
|
||||
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
|
||||
*/
|
||||
ConnectObject(objEventSource: any, strPrefix: string): void;
|
||||
|
||||
/**
|
||||
* Creates a COM object.
|
||||
* @param strProgiID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
CreateObject(strProgID: string, strPrefix?: string): any;
|
||||
|
||||
/**
|
||||
* Disconnects a COM object from its event sources.
|
||||
*/
|
||||
DisconnectObject(obj: any): void;
|
||||
|
||||
/**
|
||||
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
|
||||
* @param strPathname Fully qualified path to the file containing the object persisted to disk.
|
||||
* For objects in memory, pass a zero-length string.
|
||||
* @param strProgID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
|
||||
|
||||
/**
|
||||
* Suspends script execution for a specified length of time, then continues execution.
|
||||
* @param intTime Interval (in milliseconds) to suspend script execution.
|
||||
*/
|
||||
Sleep(intTime: number): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows enumerating over a COM collection, which may not have indexed item access.
|
||||
*/
|
||||
interface Enumerator<T> {
|
||||
/**
|
||||
* Returns true if the current item is the last one in the collection, or the collection is empty,
|
||||
* or the current item is undefined.
|
||||
*/
|
||||
atEnd(): boolean;
|
||||
|
||||
/**
|
||||
* Returns the current item in the collection
|
||||
*/
|
||||
item(): T;
|
||||
|
||||
/**
|
||||
* Resets the current item in the collection to the first item. If there are no items in the collection,
|
||||
* the current item is set to undefined.
|
||||
*/
|
||||
moveFirst(): void;
|
||||
|
||||
/**
|
||||
* Moves the current item to the next item in the collection. If the enumerator is at the end of
|
||||
* the collection or the collection is empty, the current item is set to undefined.
|
||||
*/
|
||||
moveNext(): void;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new <T>(collection: any): Enumerator<T>;
|
||||
new (collection: any): Enumerator<any>;
|
||||
}
|
||||
|
||||
declare var Enumerator: EnumeratorConstructor;
|
||||
|
||||
/**
|
||||
* Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.
|
||||
*/
|
||||
interface VBArray<T> {
|
||||
/**
|
||||
* Returns the number of dimensions (1-based).
|
||||
*/
|
||||
dimensions(): number;
|
||||
|
||||
/**
|
||||
* Takes an index for each dimension in the array, and returns the item at the corresponding location.
|
||||
*/
|
||||
getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T;
|
||||
|
||||
/**
|
||||
* Returns the smallest available index for a given dimension.
|
||||
* @param dimension 1-based dimension (defaults to 1)
|
||||
*/
|
||||
lbound(dimension?: number): number;
|
||||
|
||||
/**
|
||||
* Returns the largest available index for a given dimension.
|
||||
* @param dimension 1-based dimension (defaults to 1)
|
||||
*/
|
||||
ubound(dimension?: number): number;
|
||||
|
||||
/**
|
||||
* Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions,
|
||||
* each successive dimension is appended to the end of the array.
|
||||
* Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6]
|
||||
*/
|
||||
toArray(): T[];
|
||||
}
|
||||
|
||||
interface VBArrayConstructor {
|
||||
new <T>(safeArray: any): VBArray<T>;
|
||||
new (safeArray: any): VBArray<any>;
|
||||
}
|
||||
|
||||
declare var VBArray: VBArrayConstructor;
|
||||
|
||||
/**
|
||||
* Automation date (VT_DATE)
|
||||
*/
|
||||
interface VarDate { }
|
||||
|
||||
interface DateConstructor {
|
||||
new (vd: VarDate): Date;
|
||||
}
|
||||
|
||||
interface Date {
|
||||
getVarDate: () => VarDate;
|
||||
}
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// Windows Script Host APIS
|
||||
/////////////////////////////
|
||||
|
||||
|
||||
interface ActiveXObject {
|
||||
new (s: string): any;
|
||||
}
|
||||
declare var ActiveXObject: ActiveXObject;
|
||||
|
||||
interface ITextWriter {
|
||||
Write(s: string): void;
|
||||
WriteLine(s: string): void;
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
interface TextStreamBase {
|
||||
/**
|
||||
* The column number of the current character position in an input stream.
|
||||
*/
|
||||
Column: number;
|
||||
|
||||
/**
|
||||
* The current line number in an input stream.
|
||||
*/
|
||||
Line: number;
|
||||
|
||||
/**
|
||||
* Closes a text stream.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If
|
||||
* you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
*/
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
interface TextStreamWriter extends TextStreamBase {
|
||||
/**
|
||||
* Sends a string to an output stream.
|
||||
*/
|
||||
Write(s: string): void;
|
||||
|
||||
/**
|
||||
* Sends a specified number of blank lines (newline characters) to an output stream.
|
||||
*/
|
||||
WriteBlankLines(intLines: number): void;
|
||||
|
||||
/**
|
||||
* Sends a string followed by a newline character to an output stream.
|
||||
*/
|
||||
WriteLine(s: string): void;
|
||||
}
|
||||
|
||||
interface TextStreamReader extends TextStreamBase {
|
||||
/**
|
||||
* Returns a specified number of characters from an input stream, starting at the current pointer position.
|
||||
* Does not return until the ENTER key is pressed.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
Read(characters: number): string;
|
||||
|
||||
/**
|
||||
* Returns all characters from an input stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadAll(): string;
|
||||
|
||||
/**
|
||||
* Returns an entire line from an input stream.
|
||||
* Although this method extracts the newline character, it does not add it to the returned string.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadLine(): string;
|
||||
|
||||
/**
|
||||
* Skips a specified number of characters when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
|
||||
*/
|
||||
Skip(characters: number): void;
|
||||
|
||||
/**
|
||||
* Skips the next line when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode, not writing or appending mode.
|
||||
*/
|
||||
SkipLine(): void;
|
||||
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a line.
|
||||
*/
|
||||
AtEndOfLine: boolean;
|
||||
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a stream.
|
||||
*/
|
||||
AtEndOfStream: boolean;
|
||||
}
|
||||
|
||||
declare var WScript: {
|
||||
/**
|
||||
* Outputs text to either a message box (under WScript.exe) or the command console window followed by
|
||||
* a newline (under CScript.exe).
|
||||
*/
|
||||
Echo(s: any): void;
|
||||
|
||||
/**
|
||||
* Exposes the write-only error output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdErr: TextStreamWriter;
|
||||
|
||||
/**
|
||||
* Exposes the write-only output stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdOut: TextStreamWriter;
|
||||
Arguments: { length: number; Item(n: number): string; };
|
||||
|
||||
/**
|
||||
* The full path of the currently running script.
|
||||
*/
|
||||
ScriptFullName: string;
|
||||
|
||||
/**
|
||||
* Forces the script to stop immediately, with an optional exit code.
|
||||
*/
|
||||
Quit(exitCode?: number): number;
|
||||
|
||||
/**
|
||||
* The Windows Script Host build version number.
|
||||
*/
|
||||
BuildVersion: number;
|
||||
|
||||
/**
|
||||
* Fully qualified path of the host executable.
|
||||
*/
|
||||
FullName: string;
|
||||
|
||||
/**
|
||||
* Gets/sets the script mode - interactive(true) or batch(false).
|
||||
*/
|
||||
Interactive: boolean;
|
||||
|
||||
/**
|
||||
* The name of the host executable (WScript.exe or CScript.exe).
|
||||
*/
|
||||
Name: string;
|
||||
|
||||
/**
|
||||
* Path of the directory containing the host executable.
|
||||
*/
|
||||
Path: string;
|
||||
|
||||
/**
|
||||
* The filename of the currently running script.
|
||||
*/
|
||||
ScriptName: string;
|
||||
|
||||
/**
|
||||
* Exposes the read-only input stream for the current script.
|
||||
* Can be accessed only while using CScript.exe.
|
||||
*/
|
||||
StdIn: TextStreamReader;
|
||||
|
||||
/**
|
||||
* Windows Script Host version
|
||||
*/
|
||||
Version: string;
|
||||
|
||||
/**
|
||||
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
|
||||
*/
|
||||
ConnectObject(objEventSource: any, strPrefix: string): void;
|
||||
|
||||
/**
|
||||
* Creates a COM object.
|
||||
* @param strProgiID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
CreateObject(strProgID: string, strPrefix?: string): any;
|
||||
|
||||
/**
|
||||
* Disconnects a COM object from its event sources.
|
||||
*/
|
||||
DisconnectObject(obj: any): void;
|
||||
|
||||
/**
|
||||
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
|
||||
* @param strPathname Fully qualified path to the file containing the object persisted to disk.
|
||||
* For objects in memory, pass a zero-length string.
|
||||
* @param strProgID
|
||||
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
|
||||
*/
|
||||
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
|
||||
|
||||
/**
|
||||
* Suspends script execution for a specified length of time, then continues execution.
|
||||
* @param intTime Interval (in milliseconds) to suspend script execution.
|
||||
*/
|
||||
Sleep(intTime: number): void;
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows enumerating over a COM collection, which may not have indexed item access.
|
||||
*/
|
||||
interface Enumerator<T> {
|
||||
/**
|
||||
* Returns true if the current item is the last one in the collection, or the collection is empty,
|
||||
* or the current item is undefined.
|
||||
*/
|
||||
atEnd(): boolean;
|
||||
|
||||
/**
|
||||
* Returns the current item in the collection
|
||||
*/
|
||||
item(): T;
|
||||
|
||||
/**
|
||||
* Resets the current item in the collection to the first item. If there are no items in the collection,
|
||||
* the current item is set to undefined.
|
||||
*/
|
||||
moveFirst(): void;
|
||||
|
||||
/**
|
||||
* Moves the current item to the next item in the collection. If the enumerator is at the end of
|
||||
* the collection or the collection is empty, the current item is set to undefined.
|
||||
*/
|
||||
moveNext(): void;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new <T>(collection: any): Enumerator<T>;
|
||||
new (collection: any): Enumerator<any>;
|
||||
}
|
||||
|
||||
declare var Enumerator: EnumeratorConstructor;
|
||||
|
||||
/**
|
||||
* Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.
|
||||
*/
|
||||
interface VBArray<T> {
|
||||
/**
|
||||
* Returns the number of dimensions (1-based).
|
||||
*/
|
||||
dimensions(): number;
|
||||
|
||||
/**
|
||||
* Takes an index for each dimension in the array, and returns the item at the corresponding location.
|
||||
*/
|
||||
getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T;
|
||||
|
||||
/**
|
||||
* Returns the smallest available index for a given dimension.
|
||||
* @param dimension 1-based dimension (defaults to 1)
|
||||
*/
|
||||
lbound(dimension?: number): number;
|
||||
|
||||
/**
|
||||
* Returns the largest available index for a given dimension.
|
||||
* @param dimension 1-based dimension (defaults to 1)
|
||||
*/
|
||||
ubound(dimension?: number): number;
|
||||
|
||||
/**
|
||||
* Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions,
|
||||
* each successive dimension is appended to the end of the array.
|
||||
* Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6]
|
||||
*/
|
||||
toArray(): T[];
|
||||
}
|
||||
|
||||
interface VBArrayConstructor {
|
||||
new <T>(safeArray: any): VBArray<T>;
|
||||
new (safeArray: any): VBArray<any>;
|
||||
}
|
||||
|
||||
declare var VBArray: VBArrayConstructor;
|
||||
|
||||
/**
|
||||
* Automation date (VT_DATE)
|
||||
*/
|
||||
interface VarDate { }
|
||||
|
||||
interface DateConstructor {
|
||||
new (vd: VarDate): Date;
|
||||
}
|
||||
|
||||
interface Date {
|
||||
getVarDate: () => VarDate;
|
||||
}
|
||||
|
||||
Vendored
+1273
-1219
File diff suppressed because it is too large
Load Diff
Vendored
+1881
File diff suppressed because it is too large
Load Diff
+15905
-12504
File diff suppressed because it is too large
Load Diff
+21459
-14847
File diff suppressed because it is too large
Load Diff
Vendored
+3158
-1092
File diff suppressed because one or more lines are too long
+21203
-14821
File diff suppressed because it is too large
Load Diff
Vendored
+913
-482
File diff suppressed because it is too large
Load Diff
+22956
-17221
File diff suppressed because it is too large
Load Diff
Vendored
+912
-481
File diff suppressed because it is too large
Load Diff
+22956
-17221
File diff suppressed because it is too large
Load Diff
+1429
-869
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
// Import the utility functionality.
|
||||
import jobs.generation.Utilities;
|
||||
|
||||
// Defines a the new of the repo, used elsewhere in the file
|
||||
def project = GithubProject
|
||||
def branch = GithubBranchName
|
||||
|
||||
def nodeVersions = ['stable', '6', '4']
|
||||
|
||||
nodeVersions.each { nodeVer ->
|
||||
|
||||
def newJobName = "typescript_node.${nodeVer}"
|
||||
def newJob = job(Utilities.getFullJobName(project, newJobName, true)) {
|
||||
steps {
|
||||
shell("./jenkins.sh ${nodeVer}")
|
||||
}
|
||||
}
|
||||
|
||||
Utilities.standardJobSetup(newJob, project, true, "*/${branch}")
|
||||
Utilities.setMachineAffinity(newJob, 'Ubuntu', '20161020')
|
||||
Utilities.addGithubPRTriggerForBranch(newJob, branch, "TypeScript Test Run ${newJobName}")
|
||||
}
|
||||
+2
-3
@@ -2,7 +2,7 @@
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "http://typescriptlang.org/",
|
||||
"version": "2.1.0",
|
||||
"version": "2.2.0",
|
||||
"license": "Apache-2.0",
|
||||
"description": "TypeScript is a language for application scale JavaScript development",
|
||||
"keywords": [
|
||||
@@ -26,7 +26,7 @@
|
||||
"tsserver": "./bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
"node": ">=4.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/browserify": "latest",
|
||||
@@ -75,7 +75,6 @@
|
||||
"through2": "latest",
|
||||
"travis-fold": "latest",
|
||||
"ts-node": "latest",
|
||||
"tsd": "latest",
|
||||
"tslint": "next",
|
||||
"typescript": "next"
|
||||
},
|
||||
|
||||
+53
-11
@@ -10,6 +10,8 @@ function endsWith(s: string, suffix: string) {
|
||||
class DeclarationsWalker {
|
||||
private visitedTypes: ts.Type[] = [];
|
||||
private text = "";
|
||||
private removedTypes: ts.Type[] = [];
|
||||
|
||||
private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) {
|
||||
}
|
||||
|
||||
@@ -17,9 +19,18 @@ class DeclarationsWalker {
|
||||
let text = "declare namespace ts.server.protocol {\n";
|
||||
var walker = new DeclarationsWalker(typeChecker, protocolFile);
|
||||
walker.visitTypeNodes(protocolFile);
|
||||
return walker.text
|
||||
text = walker.text
|
||||
? `declare namespace ts.server.protocol {\n${walker.text}}`
|
||||
: "";
|
||||
if (walker.removedTypes) {
|
||||
text += "\ndeclare namespace ts {\n";
|
||||
text += " // these types are empty stubs for types from services and should not be used directly\n"
|
||||
for (const type of walker.removedTypes) {
|
||||
text += ` export type ${type.symbol.name} = never;\n`;
|
||||
}
|
||||
text += "}"
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private processType(type: ts.Type): void {
|
||||
@@ -41,12 +52,18 @@ class DeclarationsWalker {
|
||||
if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") {
|
||||
return;
|
||||
}
|
||||
// splice declaration in final d.ts file
|
||||
const text = decl.getFullText();
|
||||
this.text += `${text}\n`;
|
||||
if (decl.kind === ts.SyntaxKind.EnumDeclaration) {
|
||||
this.removedTypes.push(type);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// splice declaration in final d.ts file
|
||||
let text = decl.getFullText();
|
||||
this.text += `${text}\n`;
|
||||
// recursively pull all dependencies into result dts file
|
||||
|
||||
// recursively pull all dependencies into result dts file
|
||||
this.visitTypeNodes(decl);
|
||||
this.visitTypeNodes(decl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,15 +79,37 @@ class DeclarationsWalker {
|
||||
case ts.SyntaxKind.Parameter:
|
||||
case ts.SyntaxKind.IndexSignature:
|
||||
if (((<ts.VariableDeclaration | ts.MethodDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.PropertySignature | ts.MethodSignature | ts.IndexSignatureDeclaration>node.parent).type) === node) {
|
||||
const type = this.typeChecker.getTypeAtLocation(node);
|
||||
if (type && !(type.flags & ts.TypeFlags.TypeParameter)) {
|
||||
this.processType(type);
|
||||
}
|
||||
this.processTypeOfNode(node);
|
||||
}
|
||||
break;
|
||||
case ts.SyntaxKind.InterfaceDeclaration:
|
||||
const heritageClauses = (<ts.InterfaceDeclaration>node.parent).heritageClauses;
|
||||
if (heritageClauses) {
|
||||
if (heritageClauses[0].token !== ts.SyntaxKind.ExtendsKeyword) {
|
||||
throw new Error(`Unexpected kind of heritage clause: ${ts.SyntaxKind[heritageClauses[0].kind]}`);
|
||||
}
|
||||
for (const type of heritageClauses[0].types) {
|
||||
this.processTypeOfNode(type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
ts.forEachChild(node, n => this.visitTypeNodes(n));
|
||||
}
|
||||
|
||||
private processTypeOfNode(node: ts.Node): void {
|
||||
if (node.kind === ts.SyntaxKind.UnionType) {
|
||||
for (const t of (<ts.UnionTypeNode>node).types) {
|
||||
this.processTypeOfNode(t);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const type = this.typeChecker.getTypeAtLocation(node);
|
||||
if (type && !(type.flags & (ts.TypeFlags.TypeParameter))) {
|
||||
this.processType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,9 +160,12 @@ function generateProtocolFile(protocolTs: string, typeScriptServicesDts: string)
|
||||
if (extraDeclarations) {
|
||||
protocolDts += extraDeclarations;
|
||||
}
|
||||
protocolDts += "\nimport protocol = ts.server.protocol;";
|
||||
protocolDts += "\nexport = protocol;";
|
||||
protocolDts += "\nexport as namespace protocol;";
|
||||
// do sanity check and try to compile generated text as standalone program
|
||||
const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false);
|
||||
const diagnostics = [...program.getSyntacticDiagnostics(), ...program.getSemanticDiagnostics(), ...program.getGlobalDiagnostics()];
|
||||
const diagnostics = [...sanityCheckProgram.getSyntacticDiagnostics(), ...sanityCheckProgram.getSemanticDiagnostics(), ...sanityCheckProgram.getGlobalDiagnostics()];
|
||||
if (diagnostics.length) {
|
||||
const flattenedDiagnostics = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("\n");
|
||||
throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`);
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
var Linter = require("tslint");
|
||||
var tslint = require("tslint");
|
||||
var fs = require("fs");
|
||||
|
||||
function getLinterOptions() {
|
||||
return {
|
||||
configuration: require("../tslint.json"),
|
||||
formatter: "prose",
|
||||
formattersDirectory: undefined,
|
||||
rulesDirectory: "built/local/tslint"
|
||||
};
|
||||
}
|
||||
|
||||
function lintFileContents(options, path, contents) {
|
||||
var ll = new Linter(path, contents, options);
|
||||
return ll.lint();
|
||||
function getLinterConfiguration() {
|
||||
return require("../tslint.json");
|
||||
}
|
||||
|
||||
function lintFileAsync(options, path, cb) {
|
||||
function lintFileContents(options, configuration, path, contents) {
|
||||
var ll = new tslint.Linter(options);
|
||||
ll.lint(path, contents, configuration);
|
||||
return ll.getResult();
|
||||
}
|
||||
|
||||
function lintFileAsync(options, configuration, path, cb) {
|
||||
fs.readFile(path, "utf8", function (err, contents) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
var result = lintFileContents(options, path, contents);
|
||||
var result = lintFileContents(options, configuration, path, contents);
|
||||
cb(undefined, result);
|
||||
});
|
||||
}
|
||||
@@ -30,7 +33,8 @@ process.on("message", function (data) {
|
||||
case "file":
|
||||
var target = data.name;
|
||||
var lintOptions = getLinterOptions();
|
||||
lintFileAsync(lintOptions, target, function (err, result) {
|
||||
var lintConfiguration = getLinterConfiguration();
|
||||
lintFileAsync(lintOptions, lintConfiguration, target, function (err, result) {
|
||||
if (err) {
|
||||
process.send({ kind: "error", error: err.toString() });
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
export class Rule extends Lint.Rules.AbstractRule {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
const OPTION_CATCH = "check-catch";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
import * as Lint from "tslint/lib/lint";
|
||||
import * as ts from "typescript";
|
||||
|
||||
export class Rule extends Lint.Rules.AbstractRule {
|
||||
public static FAILURE_STRING_FACTORY = (identifier: string) => `Identifier '${identifier}' never appears on the LHS of an assignment - use const instead of let for its declaration.`;
|
||||
|
||||
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
||||
return this.applyWithWalker(new PreferConstWalker(sourceFile, this.getOptions()));
|
||||
}
|
||||
}
|
||||
|
||||
function isLet(node: ts.Node) {
|
||||
return !!(ts.getCombinedNodeFlags(node) & ts.NodeFlags.Let);
|
||||
}
|
||||
|
||||
function isExported(node: ts.Node) {
|
||||
return !!(ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export);
|
||||
}
|
||||
|
||||
function isAssignmentOperator(token: ts.SyntaxKind): boolean {
|
||||
return token >= ts.SyntaxKind.FirstAssignment && token <= ts.SyntaxKind.LastAssignment;
|
||||
}
|
||||
|
||||
function isBindingLiteralExpression(node: ts.Node): node is (ts.ArrayLiteralExpression | ts.ObjectLiteralExpression) {
|
||||
return (!!node) && (node.kind === ts.SyntaxKind.ObjectLiteralExpression || node.kind === ts.SyntaxKind.ArrayLiteralExpression);
|
||||
}
|
||||
|
||||
interface DeclarationUsages {
|
||||
declaration: ts.VariableDeclaration;
|
||||
usages: number;
|
||||
}
|
||||
|
||||
class PreferConstWalker extends Lint.RuleWalker {
|
||||
private inScopeLetDeclarations: ts.MapLike<DeclarationUsages>[] = [];
|
||||
private errors: Lint.RuleFailure[] = [];
|
||||
private markAssignment(identifier: ts.Identifier) {
|
||||
const name = identifier.text;
|
||||
for (let i = this.inScopeLetDeclarations.length - 1; i >= 0; i--) {
|
||||
const declarations = this.inScopeLetDeclarations[i];
|
||||
if (declarations[name]) {
|
||||
declarations[name].usages++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visitSourceFile(node: ts.SourceFile) {
|
||||
super.visitSourceFile(node);
|
||||
// Sort errors by position because tslint doesn't
|
||||
this.errors.sort((a, b) => a.getStartPosition().getPosition() - b.getStartPosition().getPosition()).forEach(e => this.addFailure(e));
|
||||
}
|
||||
|
||||
visitBinaryExpression(node: ts.BinaryExpression) {
|
||||
if (isAssignmentOperator(node.operatorToken.kind)) {
|
||||
this.visitLeftHandSideExpression(node.left);
|
||||
}
|
||||
super.visitBinaryExpression(node);
|
||||
}
|
||||
|
||||
private visitLeftHandSideExpression(node: ts.Expression) {
|
||||
while (node.kind === ts.SyntaxKind.ParenthesizedExpression) {
|
||||
node = (node as ts.ParenthesizedExpression).expression;
|
||||
}
|
||||
if (node.kind === ts.SyntaxKind.Identifier) {
|
||||
this.markAssignment(node as ts.Identifier);
|
||||
}
|
||||
else if (isBindingLiteralExpression(node)) {
|
||||
this.visitBindingLiteralExpression(node as (ts.ArrayLiteralExpression | ts.ObjectLiteralExpression));
|
||||
}
|
||||
}
|
||||
|
||||
private visitBindingLiteralExpression(node: ts.ArrayLiteralExpression | ts.ObjectLiteralExpression) {
|
||||
if (node.kind === ts.SyntaxKind.ObjectLiteralExpression) {
|
||||
const pattern = node as ts.ObjectLiteralExpression;
|
||||
for (const element of pattern.properties) {
|
||||
const kind = element.kind;
|
||||
|
||||
if (kind === ts.SyntaxKind.ShorthandPropertyAssignment) {
|
||||
this.markAssignment((element as ts.ShorthandPropertyAssignment).name);
|
||||
}
|
||||
else if (kind === ts.SyntaxKind.PropertyAssignment) {
|
||||
this.visitLeftHandSideExpression((element as ts.PropertyAssignment).initializer);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.kind === ts.SyntaxKind.ArrayLiteralExpression) {
|
||||
const pattern = node as ts.ArrayLiteralExpression;
|
||||
for (const element of pattern.elements) {
|
||||
this.visitLeftHandSideExpression(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private visitBindingPatternIdentifiers(pattern: ts.BindingPattern) {
|
||||
for (const element of pattern.elements) {
|
||||
if (element.kind !== ts.SyntaxKind.BindingElement) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const name = (<ts.BindingElement>element).name;
|
||||
if (name.kind === ts.SyntaxKind.Identifier) {
|
||||
this.markAssignment(name as ts.Identifier);
|
||||
}
|
||||
else {
|
||||
this.visitBindingPatternIdentifiers(name as ts.BindingPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression) {
|
||||
this.visitAnyUnaryExpression(node);
|
||||
super.visitPrefixUnaryExpression(node);
|
||||
}
|
||||
|
||||
visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression) {
|
||||
this.visitAnyUnaryExpression(node);
|
||||
super.visitPostfixUnaryExpression(node);
|
||||
}
|
||||
|
||||
private visitAnyUnaryExpression(node: ts.PrefixUnaryExpression | ts.PostfixUnaryExpression) {
|
||||
if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator === ts.SyntaxKind.MinusMinusToken) {
|
||||
this.visitLeftHandSideExpression(node.operand);
|
||||
}
|
||||
}
|
||||
|
||||
visitModuleDeclaration(node: ts.ModuleDeclaration) {
|
||||
if (node.body.kind === ts.SyntaxKind.ModuleBlock) {
|
||||
// For some reason module blocks are left out of the visit block traversal
|
||||
this.visitBlock(node.body as any as ts.Block);
|
||||
}
|
||||
super.visitModuleDeclaration(node);
|
||||
}
|
||||
|
||||
visitForOfStatement(node: ts.ForOfStatement) {
|
||||
this.visitAnyForStatement(node);
|
||||
super.visitForOfStatement(node);
|
||||
this.popDeclarations();
|
||||
}
|
||||
|
||||
visitForInStatement(node: ts.ForInStatement) {
|
||||
this.visitAnyForStatement(node);
|
||||
super.visitForInStatement(node);
|
||||
this.popDeclarations();
|
||||
}
|
||||
|
||||
private visitAnyForStatement(node: ts.ForOfStatement | ts.ForInStatement) {
|
||||
const names: ts.MapLike<DeclarationUsages> = {};
|
||||
if (isLet(node.initializer)) {
|
||||
if (node.initializer.kind === ts.SyntaxKind.VariableDeclarationList) {
|
||||
this.collectLetIdentifiers(node.initializer as ts.VariableDeclarationList, names);
|
||||
}
|
||||
}
|
||||
this.inScopeLetDeclarations.push(names);
|
||||
}
|
||||
|
||||
private popDeclarations() {
|
||||
const completed = this.inScopeLetDeclarations.pop();
|
||||
for (const name in completed) {
|
||||
if (Object.hasOwnProperty.call(completed, name)) {
|
||||
const element = completed[name];
|
||||
if (element.usages === 0) {
|
||||
this.errors.push(this.createFailure(element.declaration.getStart(this.getSourceFile()), element.declaration.getWidth(this.getSourceFile()), Rule.FAILURE_STRING_FACTORY(name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visitBlock(node: ts.Block) {
|
||||
const names: ts.MapLike<DeclarationUsages> = {};
|
||||
for (const statement of node.statements) {
|
||||
if (statement.kind === ts.SyntaxKind.VariableStatement) {
|
||||
this.collectLetIdentifiers((statement as ts.VariableStatement).declarationList, names);
|
||||
}
|
||||
}
|
||||
this.inScopeLetDeclarations.push(names);
|
||||
super.visitBlock(node);
|
||||
this.popDeclarations();
|
||||
}
|
||||
|
||||
private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.MapLike<DeclarationUsages>) {
|
||||
for (const node of list.declarations) {
|
||||
if (isLet(node) && !isExported(node)) {
|
||||
this.collectNameIdentifiers(node, node.name, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private collectNameIdentifiers(declaration: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.MapLike<DeclarationUsages>) {
|
||||
if (node.kind === ts.SyntaxKind.Identifier) {
|
||||
table[(node as ts.Identifier).text] = { declaration, usages: 0 };
|
||||
}
|
||||
else {
|
||||
this.collectBindingPatternIdentifiers(declaration, node as ts.BindingPattern, table);
|
||||
}
|
||||
}
|
||||
|
||||
private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.MapLike<DeclarationUsages>) {
|
||||
for (const element of pattern.elements) {
|
||||
if (element.kind === ts.SyntaxKind.BindingElement) {
|
||||
this.collectNameIdentifiers(value, (<ts.BindingElement>element).name, table);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Lint from "tslint/lib/lint";
|
||||
import * as Lint from "tslint/lib";
|
||||
import * as ts from "typescript";
|
||||
|
||||
|
||||
|
||||
+483
-173
File diff suppressed because it is too large
Load Diff
+2456
-1102
File diff suppressed because it is too large
Load Diff
@@ -77,6 +77,11 @@ namespace ts {
|
||||
type: "string",
|
||||
description: Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit
|
||||
},
|
||||
{
|
||||
name: "jsxFactory",
|
||||
type: "string",
|
||||
description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
|
||||
},
|
||||
{
|
||||
name: "listFiles",
|
||||
type: "boolean",
|
||||
@@ -101,7 +106,7 @@ namespace ts {
|
||||
"amd": ModuleKind.AMD,
|
||||
"system": ModuleKind.System,
|
||||
"umd": ModuleKind.UMD,
|
||||
"es6": ModuleKind.ES6,
|
||||
"es6": ModuleKind.ES2015,
|
||||
"es2015": ModuleKind.ES2015,
|
||||
}),
|
||||
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
|
||||
@@ -261,10 +266,13 @@ namespace ts {
|
||||
type: createMap({
|
||||
"es3": ScriptTarget.ES3,
|
||||
"es5": ScriptTarget.ES5,
|
||||
"es6": ScriptTarget.ES6,
|
||||
"es6": ScriptTarget.ES2015,
|
||||
"es2015": ScriptTarget.ES2015,
|
||||
"es2016": ScriptTarget.ES2016,
|
||||
"es2017": ScriptTarget.ES2017,
|
||||
"esnext": ScriptTarget.ESNext,
|
||||
}),
|
||||
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
|
||||
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT,
|
||||
paramType: Diagnostics.VERSION,
|
||||
},
|
||||
{
|
||||
@@ -426,7 +434,8 @@ namespace ts {
|
||||
"es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts",
|
||||
"es2016.array.include": "lib.es2016.array.include.d.ts",
|
||||
"es2017.object": "lib.es2017.object.d.ts",
|
||||
"es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts"
|
||||
"es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts",
|
||||
"es2017.string": "lib.es2017.string.d.ts",
|
||||
}),
|
||||
},
|
||||
description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
|
||||
@@ -444,15 +453,27 @@ namespace ts {
|
||||
name: "importHelpers",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Import_emit_helpers_from_tslib
|
||||
},
|
||||
{
|
||||
name: "alwaysStrict",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
|
||||
}
|
||||
];
|
||||
|
||||
/* @internal */
|
||||
export let typingOptionDeclarations: CommandLineOption[] = [
|
||||
export let typeAcquisitionDeclarations: CommandLineOption[] = [
|
||||
{
|
||||
/* @deprecated typingOptions.enableAutoDiscovery
|
||||
* Use typeAcquisition.enable instead.
|
||||
*/
|
||||
name: "enableAutoDiscovery",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "enable",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "include",
|
||||
type: "list",
|
||||
@@ -487,6 +508,20 @@ namespace ts {
|
||||
|
||||
let optionNameMapCache: OptionNameMap;
|
||||
|
||||
/* @internal */
|
||||
export function convertEnableAutoDiscoveryToEnable(typeAcquisition: TypeAcquisition): TypeAcquisition {
|
||||
// Convert deprecated typingOptions.enableAutoDiscovery to typeAcquisition.enable
|
||||
if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
|
||||
const result: TypeAcquisition = {
|
||||
enable: typeAcquisition.enableAutoDiscovery,
|
||||
include: typeAcquisition.include || [],
|
||||
exclude: typeAcquisition.exclude || []
|
||||
};
|
||||
return result;
|
||||
}
|
||||
return typeAcquisition;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getOptionNameMap(): OptionNameMap {
|
||||
if (optionNameMapCache) {
|
||||
@@ -508,23 +543,13 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic {
|
||||
const namesOfType: string[] = [];
|
||||
for (const key in opt.type) {
|
||||
namesOfType.push(` '${key}'`);
|
||||
}
|
||||
const namesOfType = Object.keys(opt.type).map(key => `'${key}'`).join(", ");
|
||||
return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) {
|
||||
const key = trimString((value || "")).toLowerCase();
|
||||
const map = opt.type;
|
||||
if (key in map) {
|
||||
return map[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
|
||||
}
|
||||
return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -547,7 +572,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine {
|
||||
const options: CompilerOptions = {};
|
||||
const fileNames: string[] = [];
|
||||
@@ -595,7 +619,13 @@ namespace ts {
|
||||
i++;
|
||||
break;
|
||||
case "boolean":
|
||||
options[opt.name] = true;
|
||||
// boolean flag has optional value true, false, others
|
||||
const optValue = args[i];
|
||||
options[opt.name] = optValue !== "false";
|
||||
// consume next argument as boolean flag value
|
||||
if (optValue === "false" || optValue === "true") {
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case "string":
|
||||
options[opt.name] = args[i] || "";
|
||||
@@ -748,7 +778,7 @@ namespace ts {
|
||||
break;
|
||||
default:
|
||||
const value = options[name];
|
||||
let optionDefinition = optionsNameMap[name.toLowerCase()];
|
||||
const optionDefinition = optionsNameMap[name.toLowerCase()];
|
||||
if (optionDefinition) {
|
||||
const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition);
|
||||
if (!customTypeMap) {
|
||||
@@ -810,15 +840,16 @@ namespace ts {
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = []): ParsedCommandLine {
|
||||
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: FileExtensionInfo[] = []): ParsedCommandLine {
|
||||
const errors: Diagnostic[] = [];
|
||||
basePath = normalizeSlashes(basePath);
|
||||
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames);
|
||||
const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName);
|
||||
if (resolutionStack.indexOf(resolvedPath) >= 0) {
|
||||
return {
|
||||
options: {},
|
||||
fileNames: [],
|
||||
typingOptions: {},
|
||||
typeAcquisition: {},
|
||||
raw: json,
|
||||
errors: [createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))],
|
||||
wildcardDirectories: {}
|
||||
@@ -826,7 +857,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
let options: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName);
|
||||
const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName);
|
||||
// typingOptions has been deprecated and is only supported for backward compatibility purposes.
|
||||
// It should be removed in future releases - use typeAcquisition instead.
|
||||
const jsonOptions = json["typeAcquisition"] || json["typingOptions"];
|
||||
const typeAcquisition: TypeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
||||
|
||||
if (json["extends"]) {
|
||||
let [include, exclude, files, baseOptions]: [string[], string[], string[], CompilerOptions] = [undefined, undefined, undefined, {}];
|
||||
@@ -857,7 +891,7 @@ namespace ts {
|
||||
return {
|
||||
options,
|
||||
fileNames,
|
||||
typingOptions,
|
||||
typeAcquisition,
|
||||
raw: json,
|
||||
errors,
|
||||
wildcardDirectories,
|
||||
@@ -867,7 +901,7 @@ namespace ts {
|
||||
function tryExtendsName(extendedConfig: string): [string[], string[], string[], CompilerOptions] {
|
||||
// If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future)
|
||||
if (!(isRootedDiskPath(extendedConfig) || startsWith(normalizeSlashes(extendedConfig), "./") || startsWith(normalizeSlashes(extendedConfig), "../"))) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted));
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig));
|
||||
return;
|
||||
}
|
||||
let extendedConfigPath = toPath(extendedConfig, basePath, getCanonicalFileName);
|
||||
@@ -902,6 +936,9 @@ namespace ts {
|
||||
if (hasProperty(json, "files")) {
|
||||
if (isArray(json["files"])) {
|
||||
fileNames = <string[]>json["files"];
|
||||
if (fileNames.length === 0) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array"));
|
||||
@@ -931,8 +968,8 @@ namespace ts {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
||||
}
|
||||
else {
|
||||
// By default, exclude common package folders and the outDir
|
||||
excludeSpecs = ["node_modules", "bower_components", "jspm_packages"];
|
||||
// If no includes were specified, exclude common package folders and the outDir
|
||||
excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"];
|
||||
|
||||
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
|
||||
if (outDir) {
|
||||
@@ -944,7 +981,18 @@ namespace ts {
|
||||
includeSpecs = ["**/*"];
|
||||
}
|
||||
|
||||
return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors);
|
||||
const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions);
|
||||
|
||||
if (result.fileNames.length === 0 && !hasProperty(json, "files") && resolutionStack.length === 0) {
|
||||
errors.push(
|
||||
createCompilerDiagnostic(
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
configFileName || "tsconfig.json",
|
||||
JSON.stringify(includeSpecs || []),
|
||||
JSON.stringify(excludeSpecs || [])));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -965,9 +1013,9 @@ namespace ts {
|
||||
return { options, errors };
|
||||
}
|
||||
|
||||
export function convertTypingOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypingOptions, errors: Diagnostic[] } {
|
||||
export function convertTypeAcquisitionFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: TypeAcquisition, errors: Diagnostic[] } {
|
||||
const errors: Diagnostic[] = [];
|
||||
const options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
||||
const options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
|
||||
return { options, errors };
|
||||
}
|
||||
|
||||
@@ -981,18 +1029,18 @@ namespace ts {
|
||||
return options;
|
||||
}
|
||||
|
||||
function convertTypingOptionsFromJsonWorker(jsonOptions: any,
|
||||
basePath: string, errors: Diagnostic[], configFileName?: string): TypingOptions {
|
||||
function convertTypeAcquisitionFromJsonWorker(jsonOptions: any,
|
||||
basePath: string, errors: Diagnostic[], configFileName?: string): TypeAcquisition {
|
||||
|
||||
const options: TypeAcquisition = { enable: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
|
||||
const typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
|
||||
convertOptionsFromJson(typeAcquisitionDeclarations, typeAcquisition, basePath, options, Diagnostics.Unknown_type_acquisition_option_0, errors);
|
||||
|
||||
const options: TypingOptions = getBaseFileName(configFileName) === "jsconfig.json"
|
||||
? { enableAutoDiscovery: true, include: [], exclude: [] }
|
||||
: { enableAutoDiscovery: false, include: [], exclude: [] };
|
||||
convertOptionsFromJson(typingOptionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_typing_option_0, errors);
|
||||
return options;
|
||||
}
|
||||
|
||||
function convertOptionsFromJson(optionDeclarations: CommandLineOption[], jsonOptions: any, basePath: string,
|
||||
defaultOptions: CompilerOptions | TypingOptions, diagnosticMessage: DiagnosticMessage, errors: Diagnostic[]) {
|
||||
defaultOptions: CompilerOptions | TypeAcquisition, diagnosticMessage: DiagnosticMessage, errors: Diagnostic[]) {
|
||||
|
||||
if (!jsonOptions) {
|
||||
return;
|
||||
@@ -1137,7 +1185,7 @@ namespace ts {
|
||||
* @param host The host used to resolve files and directories.
|
||||
* @param errors An array for diagnostic reporting.
|
||||
*/
|
||||
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[]): ExpandResult {
|
||||
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[], extraFileExtensions: FileExtensionInfo[]): ExpandResult {
|
||||
basePath = normalizePath(basePath);
|
||||
|
||||
// The exclude spec list is converted into a regular expression, which allows us to quickly
|
||||
@@ -1171,7 +1219,7 @@ namespace ts {
|
||||
|
||||
// Rather than requery this for each file and filespec, we query the supported extensions
|
||||
// once and store it on the expansion context.
|
||||
const supportedExtensions = getSupportedExtensions(options);
|
||||
const supportedExtensions = getSupportedExtensions(options, extraFileExtensions);
|
||||
|
||||
// Literal files are always included verbatim. An "include" or "exclude" specification cannot
|
||||
// remove a literal file.
|
||||
@@ -1239,12 +1287,13 @@ namespace ts {
|
||||
/**
|
||||
* Gets directories in a set of include patterns that should be watched for changes.
|
||||
*/
|
||||
function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean) {
|
||||
function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): Map<WatchDirectoryFlags> {
|
||||
// We watch a directory recursively if it contains a wildcard anywhere in a directory segment
|
||||
// of the pattern:
|
||||
//
|
||||
// /a/b/**/d - Watch /a/b recursively to catch changes to any d in any subfolder recursively
|
||||
// /a/b/*/d - Watch /a/b recursively to catch any d in any immediate subfolder, even if a new subfolder is added
|
||||
// /a/b - Watch /a/b recursively to catch changes to anything in any recursive subfoler
|
||||
//
|
||||
// We watch a directory without recursion if it contains a wildcard in the file segment of
|
||||
// the pattern:
|
||||
@@ -1257,15 +1306,14 @@ namespace ts {
|
||||
if (include !== undefined) {
|
||||
const recursiveKeys: string[] = [];
|
||||
for (const file of include) {
|
||||
const name = normalizePath(combinePaths(path, file));
|
||||
if (excludeRegex && excludeRegex.test(name)) {
|
||||
const spec = normalizePath(combinePaths(path, file));
|
||||
if (excludeRegex && excludeRegex.test(spec)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const match = wildcardDirectoryPattern.exec(name);
|
||||
const match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
|
||||
if (match) {
|
||||
const key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase();
|
||||
const flags = watchRecursivePattern.test(name) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None;
|
||||
const { key, flags } = match;
|
||||
const existingFlags = wildcardDirectories[key];
|
||||
if (existingFlags === undefined || existingFlags < flags) {
|
||||
wildcardDirectories[key] = flags;
|
||||
@@ -1289,6 +1337,20 @@ namespace ts {
|
||||
return wildcardDirectories;
|
||||
}
|
||||
|
||||
function getWildcardDirectoryFromSpec(spec: string, useCaseSensitiveFileNames: boolean): { key: string, flags: WatchDirectoryFlags } | undefined {
|
||||
const match = wildcardDirectoryPattern.exec(spec);
|
||||
if (match) {
|
||||
return {
|
||||
key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(),
|
||||
flags: watchRecursivePattern.test(spec) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None
|
||||
};
|
||||
}
|
||||
if (isImplicitGlob(spec)) {
|
||||
return { key: spec, flags: WatchDirectoryFlags.Recursive };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a literal or wildcard file has already been included that has a higher
|
||||
* extension priority.
|
||||
|
||||
@@ -156,6 +156,9 @@ namespace ts {
|
||||
|
||||
if (!skipTrailingComments) {
|
||||
emitLeadingComments(detachedRange.end, /*isEmittedNode*/ true);
|
||||
if (hasWrittenComment && !writer.isAtStartOfLine()) {
|
||||
writer.writeLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (extendedDiagnostics) {
|
||||
@@ -188,7 +191,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) {
|
||||
function emitLeadingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) {
|
||||
if (!hasWrittenComment) {
|
||||
emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos);
|
||||
hasWrittenComment = true;
|
||||
@@ -211,7 +214,7 @@ namespace ts {
|
||||
forEachTrailingCommentToEmit(pos, emitTrailingComment);
|
||||
}
|
||||
|
||||
function emitTrailingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) {
|
||||
function emitTrailingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
|
||||
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
|
||||
if (!writer.isAtStartOfLine()) {
|
||||
writer.write(" ");
|
||||
@@ -242,7 +245,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) {
|
||||
function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
|
||||
// trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
|
||||
|
||||
emitPos(commentPos);
|
||||
|
||||
+400
-148
@@ -1,6 +1,11 @@
|
||||
/// <reference path="types.ts"/>
|
||||
/// <reference path="performance.ts" />
|
||||
|
||||
namespace ts {
|
||||
/** The version of the TypeScript compiler release */
|
||||
export const version = "2.2.0";
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
/**
|
||||
@@ -20,6 +25,9 @@ namespace ts {
|
||||
|
||||
const createObject = Object.create;
|
||||
|
||||
// More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times.
|
||||
export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined;
|
||||
|
||||
export function createMap<T>(template?: MapLike<T>): Map<T> {
|
||||
const map: Map<T> = createObject(null); // tslint:disable-line:no-null-keyword
|
||||
|
||||
@@ -111,7 +119,7 @@ namespace ts {
|
||||
*/
|
||||
export function forEach<T, U>(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined {
|
||||
if (array) {
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const result = callback(array[i], i);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -121,6 +129,13 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function zipWith<T, U>(arrayA: T[], arrayB: U[], callback: (a: T, b: U, index: number) => void): void {
|
||||
Debug.assert(arrayA.length === arrayB.length);
|
||||
for (let i = 0; i < arrayA.length; i++) {
|
||||
callback(arrayA[i], arrayB[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through `array` by index and performs the callback on each element of array until the callback
|
||||
* returns a falsey value, then returns false.
|
||||
@@ -128,7 +143,7 @@ namespace ts {
|
||||
*/
|
||||
export function every<T>(array: T[], callback: (element: T, index: number) => boolean): boolean {
|
||||
if (array) {
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (!callback(array[i], i)) {
|
||||
return false;
|
||||
}
|
||||
@@ -140,7 +155,7 @@ namespace ts {
|
||||
|
||||
/** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */
|
||||
export function find<T>(array: T[], predicate: (element: T, index: number) => boolean): T | undefined {
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const value = array[i];
|
||||
if (predicate(value, i)) {
|
||||
return value;
|
||||
@@ -154,7 +169,7 @@ namespace ts {
|
||||
* This is like `forEach`, but never returns undefined.
|
||||
*/
|
||||
export function findMap<T, U>(array: T[], callback: (element: T, index: number) => U | undefined): U {
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const result = callback(array[i], i);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -176,7 +191,7 @@ namespace ts {
|
||||
|
||||
export function indexOf<T>(array: T[], value: T): number {
|
||||
if (array) {
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i] === value) {
|
||||
return i;
|
||||
}
|
||||
@@ -186,7 +201,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number {
|
||||
for (let i = start || 0, len = text.length; i < len; i++) {
|
||||
for (let i = start || 0; i < text.length; i++) {
|
||||
if (contains(charCodes, text.charCodeAt(i))) {
|
||||
return i;
|
||||
}
|
||||
@@ -265,13 +280,33 @@ namespace ts {
|
||||
if (array) {
|
||||
result = [];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const v = array[i];
|
||||
result.push(f(v, i));
|
||||
result.push(f(array[i], i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Maps from T to T and avoids allocation if all elements map to themselves
|
||||
export function sameMap<T>(array: T[], f: (x: T, i: number) => T): T[] {
|
||||
let result: T[];
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (result) {
|
||||
result.push(f(array[i], i));
|
||||
}
|
||||
else {
|
||||
const item = array[i];
|
||||
const mapped = f(item, i);
|
||||
if (item !== mapped) {
|
||||
result = array.slice(0, i);
|
||||
result.push(mapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result || array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens an array containing a mix of array or non-array elements.
|
||||
*
|
||||
@@ -399,9 +434,25 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function some<T>(array: T[], predicate?: (value: T) => boolean): boolean {
|
||||
if (array) {
|
||||
if (predicate) {
|
||||
for (const v of array) {
|
||||
if (predicate(v)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return array.length > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function concatenate<T>(array1: T[], array2: T[]): T[] {
|
||||
if (!array2 || !array2.length) return array1;
|
||||
if (!array1 || !array1.length) return array2;
|
||||
if (!some(array2)) return array1;
|
||||
if (!some(array1)) return array2;
|
||||
return [...array1, ...array2];
|
||||
}
|
||||
|
||||
@@ -422,6 +473,44 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function arrayIsEqualTo<T>(array1: ReadonlyArray<T>, array2: ReadonlyArray<T>, equaler?: (a: T, b: T) => boolean): boolean {
|
||||
if (!array1 || !array2) {
|
||||
return array1 === array2;
|
||||
}
|
||||
|
||||
if (array1.length !== array2.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < array1.length; i++) {
|
||||
const equals = equaler ? equaler(array1[i], array2[i]) : array1[i] === array2[i];
|
||||
if (!equals) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function changesAffectModuleResolution(oldOptions: CompilerOptions, newOptions: CompilerOptions): boolean {
|
||||
return !oldOptions ||
|
||||
(oldOptions.module !== newOptions.module) ||
|
||||
(oldOptions.moduleResolution !== newOptions.moduleResolution) ||
|
||||
(oldOptions.noResolve !== newOptions.noResolve) ||
|
||||
(oldOptions.target !== newOptions.target) ||
|
||||
(oldOptions.noLib !== newOptions.noLib) ||
|
||||
(oldOptions.jsx !== newOptions.jsx) ||
|
||||
(oldOptions.allowJs !== newOptions.allowJs) ||
|
||||
(oldOptions.rootDir !== newOptions.rootDir) ||
|
||||
(oldOptions.configFilePath !== newOptions.configFilePath) ||
|
||||
(oldOptions.baseUrl !== newOptions.baseUrl) ||
|
||||
(oldOptions.maxNodeModuleJsDepth !== newOptions.maxNodeModuleJsDepth) ||
|
||||
!arrayIsEqualTo(oldOptions.lib, newOptions.lib) ||
|
||||
!arrayIsEqualTo(oldOptions.typeRoots, newOptions.typeRoots) ||
|
||||
!arrayIsEqualTo(oldOptions.rootDirs, newOptions.rootDirs) ||
|
||||
!equalOwnProperties(oldOptions.paths, newOptions.paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compacts an array, removing any falsey elements.
|
||||
*/
|
||||
@@ -443,6 +532,27 @@ namespace ts {
|
||||
return result || array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relative complement of `arrayA` with respect to `b`, returning the elements that
|
||||
* are not present in `arrayA` but are present in `arrayB`. Assumes both arrays are sorted
|
||||
* based on the provided comparer.
|
||||
*/
|
||||
export function relativeComplement<T>(arrayA: T[] | undefined, arrayB: T[] | undefined, comparer: (x: T, y: T) => Comparison = compareValues, offsetA = 0, offsetB = 0): T[] | undefined {
|
||||
if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) return arrayB;
|
||||
const result: T[] = [];
|
||||
outer: for (; offsetB < arrayB.length; offsetB++) {
|
||||
inner: for (; offsetA < arrayA.length; offsetA++) {
|
||||
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
|
||||
case Comparison.LessThan: break inner;
|
||||
case Comparison.EqualTo: continue outer;
|
||||
case Comparison.GreaterThan: continue inner;
|
||||
}
|
||||
}
|
||||
result.push(arrayB[offsetB]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function sum(array: any[], prop: string): number {
|
||||
let result = 0;
|
||||
for (const v of array) {
|
||||
@@ -451,14 +561,45 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function addRange<T>(to: T[], from: T[]): void {
|
||||
if (to && from) {
|
||||
for (const v of from) {
|
||||
if (v !== undefined) {
|
||||
to.push(v);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Appends a value to an array, returning the array.
|
||||
*
|
||||
* @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array
|
||||
* is created if `value` was appended.
|
||||
* @param value The value to append to the array. If `value` is `undefined`, nothing is
|
||||
* appended.
|
||||
*/
|
||||
export function append<T>(to: T[] | undefined, value: T | undefined): T[] | undefined {
|
||||
if (value === undefined) return to;
|
||||
if (to === undefined) return [value];
|
||||
to.push(value);
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a range of value to an array, returning the array.
|
||||
*
|
||||
* @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array
|
||||
* is created if `value` was appended.
|
||||
* @param from The values to append to the array. If `from` is `undefined`, nothing is
|
||||
* appended. If an element of `from` is `undefined`, that element is not appended.
|
||||
*/
|
||||
export function addRange<T>(to: T[] | undefined, from: T[] | undefined): T[] | undefined {
|
||||
if (from === undefined) return to;
|
||||
for (const v of from) {
|
||||
to = append(to, v);
|
||||
}
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stable sort of an array. Elements equal to each other maintain their relative position in the array.
|
||||
*/
|
||||
export function stableSort<T>(array: T[], comparer: (x: T, y: T) => Comparison = compareValues) {
|
||||
return array
|
||||
.map((_, i) => i) // create array of indices
|
||||
.sort((x, y) => comparer(array[x], array[y]) || compareValues(x, y)) // sort indices by value then position
|
||||
.map(i => array[i]); // get sorted array
|
||||
}
|
||||
|
||||
export function rangeEquals<T>(array1: T[], array2: T[], pos: number, end: number) {
|
||||
@@ -471,31 +612,47 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first element of an array if non-empty, `undefined` otherwise.
|
||||
*/
|
||||
export function firstOrUndefined<T>(array: T[]): T {
|
||||
return array && array.length > 0
|
||||
? array[0]
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last element of an array if non-empty, `undefined` otherwise.
|
||||
*/
|
||||
export function lastOrUndefined<T>(array: T[]): T {
|
||||
return array && array.length > 0
|
||||
? array[array.length - 1]
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the only element of an array if it contains only one element, `undefined` otherwise.
|
||||
*/
|
||||
export function singleOrUndefined<T>(array: T[]): T {
|
||||
return array && array.length === 1
|
||||
? array[0]
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the only element of an array if it contains only one element; otheriwse, returns the
|
||||
* array.
|
||||
*/
|
||||
export function singleOrMany<T>(array: T[]): T | T[] {
|
||||
return array && array.length === 1
|
||||
? array[0]
|
||||
: array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last element of an array if non-empty, undefined otherwise.
|
||||
*/
|
||||
export function lastOrUndefined<T>(array: T[]): T {
|
||||
return array && array.length > 0
|
||||
? array[array.length - 1]
|
||||
: undefined;
|
||||
export function replaceElement<T>(array: T[], index: number, value: T): T[] {
|
||||
const result = array.slice(0);
|
||||
result[index] = value;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,12 +662,12 @@ namespace ts {
|
||||
* @param array A sorted array whose first element must be no larger than number
|
||||
* @param number The value to be searched for in the array.
|
||||
*/
|
||||
export function binarySearch<T>(array: T[], value: T, comparer?: (v1: T, v2: T) => number): number {
|
||||
export function binarySearch<T>(array: T[], value: T, comparer?: (v1: T, v2: T) => number, offset?: number): number {
|
||||
if (!array || array.length === 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
let low = 0;
|
||||
let low = offset || 0;
|
||||
let high = array.length - 1;
|
||||
comparer = comparer !== undefined
|
||||
? comparer
|
||||
@@ -669,6 +826,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function appendProperty<T>(map: Map<T>, key: string | number, value: T): Map<T> {
|
||||
if (key === undefined || value === undefined) return map;
|
||||
if (map === undefined) map = createMap<T>();
|
||||
map[key] = value;
|
||||
return map;
|
||||
}
|
||||
|
||||
export function assign<T1 extends MapLike<{}>, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3;
|
||||
export function assign<T1 extends MapLike<{}>, T2>(t: T1, arg1: T2): T1 & T2;
|
||||
export function assign<T1 extends MapLike<{}>>(t: T1, ...args: any[]): any;
|
||||
@@ -699,24 +863,6 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce the properties defined on a map-like (but not from its prototype chain).
|
||||
*
|
||||
* NOTE: This is intended for use with MapLike<T> objects. For Map<T> objects, use
|
||||
* reduceProperties instead as it offers better performance.
|
||||
*
|
||||
* @param map The map-like to reduce
|
||||
* @param callback An aggregation function that is called for each entry in the map
|
||||
* @param initial The initial value for the reduction.
|
||||
*/
|
||||
export function reduceOwnProperties<T, U>(map: MapLike<T>, callback: (aggregate: U, value: T, key: string) => U, initial: U): U {
|
||||
let result = initial;
|
||||
for (const key in map) if (hasOwnProperty.call(map, key)) {
|
||||
result = callback(result, map[key], String(key));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a shallow equality comparison of the contents of two map-likes.
|
||||
*
|
||||
@@ -781,7 +927,7 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function extend<T1, T2>(first: T1 , second: T2): T1 & T2 {
|
||||
export function extend<T1, T2>(first: T1, second: T2): T1 & T2 {
|
||||
const result: T1 & T2 = <any>{};
|
||||
for (const id in second) if (hasOwnProperty.call(second, id)) {
|
||||
(result as any)[id] = (second as any)[id];
|
||||
@@ -796,7 +942,7 @@ namespace ts {
|
||||
* Adds the value to an array of values associated with the key, and returns the array.
|
||||
* Creates the array if it does not already exist.
|
||||
*/
|
||||
export function multiMapAdd<V>(map: Map<V[]>, key: string, value: V): V[] {
|
||||
export function multiMapAdd<V>(map: Map<V[]>, key: string | number, value: V): V[] {
|
||||
const values = map[key];
|
||||
if (values) {
|
||||
values.push(value);
|
||||
@@ -829,6 +975,14 @@ namespace ts {
|
||||
return Array.isArray ? Array.isArray(value) : value instanceof Array;
|
||||
}
|
||||
|
||||
/** Does nothing. */
|
||||
export function noop(): void {}
|
||||
|
||||
/** Throws an error because a function is not implemented. */
|
||||
export function notImplemented(): never {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
export function memoize<T>(callback: () => T): () => T {
|
||||
let value: T;
|
||||
return () => {
|
||||
@@ -869,7 +1023,7 @@ namespace ts {
|
||||
return t => compose(a(t));
|
||||
}
|
||||
else {
|
||||
return t => u => u;
|
||||
return _ => u => u;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -906,10 +1060,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function formatStringFromArgs(text: string, args: { [index: number]: any; }, baseIndex?: number): string {
|
||||
function formatStringFromArgs(text: string, args: { [index: number]: string; }, baseIndex?: number): string {
|
||||
baseIndex = baseIndex || 0;
|
||||
|
||||
return text.replace(/{(\d+)}/g, (match, index?) => args[+index + baseIndex]);
|
||||
return text.replace(/{(\d+)}/g, (_match, index?) => args[+index + baseIndex]);
|
||||
}
|
||||
|
||||
export let localizedDiagnosticMessages: Map<string> = undefined;
|
||||
@@ -918,7 +1072,7 @@ namespace ts {
|
||||
return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
|
||||
}
|
||||
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
|
||||
const end = start + length;
|
||||
|
||||
@@ -926,8 +1080,8 @@ namespace ts {
|
||||
Debug.assert(length >= 0, "length must be non-negative, is " + length);
|
||||
|
||||
if (file) {
|
||||
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
|
||||
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
|
||||
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${start} > ${file.text.length}`);
|
||||
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${end} > ${file.text.length}`);
|
||||
}
|
||||
|
||||
let text = getLocaleSpecificMessage(message);
|
||||
@@ -948,7 +1102,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* internal */
|
||||
export function formatMessage(dummy: any, message: DiagnosticMessage): string {
|
||||
export function formatMessage(_dummy: any, message: DiagnosticMessage): string {
|
||||
let text = getLocaleSpecificMessage(message);
|
||||
|
||||
if (arguments.length > 2) {
|
||||
@@ -958,7 +1112,7 @@ namespace ts {
|
||||
return text;
|
||||
}
|
||||
|
||||
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
|
||||
export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic {
|
||||
let text = getLocaleSpecificMessage(message);
|
||||
|
||||
@@ -977,6 +1131,18 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic {
|
||||
return {
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
|
||||
code: chain.code,
|
||||
category: chain.category,
|
||||
messageText: chain.next ? chain : chain.messageText
|
||||
};
|
||||
}
|
||||
|
||||
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
|
||||
export function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage): DiagnosticMessageChain {
|
||||
let text = getLocaleSpecificMessage(message);
|
||||
@@ -1016,7 +1182,8 @@ namespace ts {
|
||||
if (a === undefined) return Comparison.LessThan;
|
||||
if (b === undefined) return Comparison.GreaterThan;
|
||||
if (ignoreCase) {
|
||||
if (String.prototype.localeCompare) {
|
||||
if (collator && String.prototype.localeCompare) {
|
||||
// accent means a ≠ b, a ≠ á, a = A
|
||||
const result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" });
|
||||
return result < 0 ? Comparison.LessThan : result > 0 ? Comparison.GreaterThan : Comparison.EqualTo;
|
||||
}
|
||||
@@ -1177,12 +1344,12 @@ namespace ts {
|
||||
|
||||
/**
|
||||
* Returns the path except for its basename. Eg:
|
||||
*
|
||||
*
|
||||
* /path/to/file.ext -> /path/to
|
||||
*/
|
||||
export function getDirectoryPath(path: Path): Path;
|
||||
export function getDirectoryPath(path: string): string;
|
||||
export function getDirectoryPath(path: string): any {
|
||||
export function getDirectoryPath(path: string): string {
|
||||
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));
|
||||
}
|
||||
|
||||
@@ -1203,7 +1370,15 @@ namespace ts {
|
||||
export function getEmitModuleKind(compilerOptions: CompilerOptions) {
|
||||
return typeof compilerOptions.module === "number" ?
|
||||
compilerOptions.module :
|
||||
getEmitScriptTarget(compilerOptions) === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS;
|
||||
getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS;
|
||||
}
|
||||
|
||||
export function getEmitModuleResolutionKind(compilerOptions: CompilerOptions) {
|
||||
let moduleResolution = compilerOptions.moduleResolution;
|
||||
if (moduleResolution === undefined) {
|
||||
moduleResolution = getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
|
||||
}
|
||||
return moduleResolution;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -1442,6 +1617,10 @@ namespace ts {
|
||||
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
|
||||
}
|
||||
|
||||
export function hasExtension(fileName: string): boolean {
|
||||
return getBaseFileName(fileName).indexOf(".") >= 0;
|
||||
}
|
||||
|
||||
export function fileExtensionIs(path: string, extension: string): boolean {
|
||||
return path.length > extension.length && endsWith(path, extension);
|
||||
}
|
||||
@@ -1476,7 +1655,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther;
|
||||
const replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther;
|
||||
const singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther;
|
||||
|
||||
/**
|
||||
@@ -1487,73 +1666,21 @@ namespace ts {
|
||||
|
||||
let pattern = "";
|
||||
let hasWrittenSubpattern = false;
|
||||
spec: for (const spec of specs) {
|
||||
for (const spec of specs) {
|
||||
if (!spec) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let subpattern = "";
|
||||
let hasRecursiveDirectoryWildcard = false;
|
||||
let hasWrittenComponent = false;
|
||||
const components = getNormalizedPathComponents(spec, basePath);
|
||||
if (usage !== "exclude" && components[components.length - 1] === "**") {
|
||||
continue spec;
|
||||
}
|
||||
|
||||
// getNormalizedPathComponents includes the separator for the root component.
|
||||
// We need to remove to create our regex correctly.
|
||||
components[0] = removeTrailingDirectorySeparator(components[0]);
|
||||
|
||||
let optionalCount = 0;
|
||||
for (let component of components) {
|
||||
if (component === "**") {
|
||||
if (hasRecursiveDirectoryWildcard) {
|
||||
continue spec;
|
||||
}
|
||||
|
||||
subpattern += doubleAsteriskRegexFragment;
|
||||
hasRecursiveDirectoryWildcard = true;
|
||||
hasWrittenComponent = true;
|
||||
}
|
||||
else {
|
||||
if (usage === "directories") {
|
||||
subpattern += "(";
|
||||
optionalCount++;
|
||||
}
|
||||
|
||||
if (hasWrittenComponent) {
|
||||
subpattern += directorySeparator;
|
||||
}
|
||||
|
||||
if (usage !== "exclude") {
|
||||
// The * and ? wildcards should not match directories or files that start with . if they
|
||||
// appear first in a component. Dotted directories and files can be included explicitly
|
||||
// like so: **/.*/.*
|
||||
if (component.charCodeAt(0) === CharacterCodes.asterisk) {
|
||||
subpattern += "([^./]" + singleAsteriskRegexFragment + ")?";
|
||||
component = component.substr(1);
|
||||
}
|
||||
else if (component.charCodeAt(0) === CharacterCodes.question) {
|
||||
subpattern += "[^./]";
|
||||
component = component.substr(1);
|
||||
}
|
||||
}
|
||||
|
||||
subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
|
||||
hasWrittenComponent = true;
|
||||
}
|
||||
}
|
||||
|
||||
while (optionalCount > 0) {
|
||||
subpattern += ")?";
|
||||
optionalCount--;
|
||||
const subPattern = getSubPatternFromSpec(spec, basePath, usage, singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter);
|
||||
if (subPattern === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hasWrittenSubpattern) {
|
||||
pattern += "|";
|
||||
}
|
||||
|
||||
pattern += "(" + subpattern + ")";
|
||||
pattern += "(" + subPattern + ")";
|
||||
hasWrittenSubpattern = true;
|
||||
}
|
||||
|
||||
@@ -1561,7 +1688,83 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$");
|
||||
// If excluding, match "foo/bar/baz...", but if including, only allow "foo".
|
||||
const terminator = usage === "exclude" ? "($|/)" : "$";
|
||||
return `^(${pattern})${terminator}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension,
|
||||
* and does not contain any glob characters itself.
|
||||
*/
|
||||
export function isImplicitGlob(lastPathComponent: string): boolean {
|
||||
return !/[.*?]/.test(lastPathComponent);
|
||||
}
|
||||
|
||||
function getSubPatternFromSpec(spec: string, basePath: string, usage: "files" | "directories" | "exclude", singleAsteriskRegexFragment: string, doubleAsteriskRegexFragment: string, replaceWildcardCharacter: (match: string) => string): string | undefined {
|
||||
let subpattern = "";
|
||||
let hasRecursiveDirectoryWildcard = false;
|
||||
let hasWrittenComponent = false;
|
||||
const components = getNormalizedPathComponents(spec, basePath);
|
||||
const lastComponent = lastOrUndefined(components);
|
||||
if (usage !== "exclude" && lastComponent === "**") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// getNormalizedPathComponents includes the separator for the root component.
|
||||
// We need to remove to create our regex correctly.
|
||||
components[0] = removeTrailingDirectorySeparator(components[0]);
|
||||
|
||||
if (isImplicitGlob(lastComponent)) {
|
||||
components.push("**", "*");
|
||||
}
|
||||
|
||||
let optionalCount = 0;
|
||||
for (let component of components) {
|
||||
if (component === "**") {
|
||||
if (hasRecursiveDirectoryWildcard) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
subpattern += doubleAsteriskRegexFragment;
|
||||
hasRecursiveDirectoryWildcard = true;
|
||||
}
|
||||
else {
|
||||
if (usage === "directories") {
|
||||
subpattern += "(";
|
||||
optionalCount++;
|
||||
}
|
||||
|
||||
if (hasWrittenComponent) {
|
||||
subpattern += directorySeparator;
|
||||
}
|
||||
|
||||
if (usage !== "exclude") {
|
||||
// The * and ? wildcards should not match directories or files that start with . if they
|
||||
// appear first in a component. Dotted directories and files can be included explicitly
|
||||
// like so: **/.*/.*
|
||||
if (component.charCodeAt(0) === CharacterCodes.asterisk) {
|
||||
subpattern += "([^./]" + singleAsteriskRegexFragment + ")?";
|
||||
component = component.substr(1);
|
||||
}
|
||||
else if (component.charCodeAt(0) === CharacterCodes.question) {
|
||||
subpattern += "[^./]";
|
||||
component = component.substr(1);
|
||||
}
|
||||
}
|
||||
|
||||
subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
|
||||
}
|
||||
|
||||
hasWrittenComponent = true;
|
||||
}
|
||||
|
||||
while (optionalCount > 0) {
|
||||
subpattern += ")?";
|
||||
optionalCount--;
|
||||
}
|
||||
|
||||
return subpattern;
|
||||
}
|
||||
|
||||
function replaceWildCardCharacterFiles(match: string) {
|
||||
@@ -1588,7 +1791,7 @@ namespace ts {
|
||||
basePaths: string[];
|
||||
}
|
||||
|
||||
export function getFileMatcherPatterns(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
|
||||
export function getFileMatcherPatterns(path: string, excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
|
||||
path = normalizePath(path);
|
||||
currentDirectory = normalizePath(currentDirectory);
|
||||
const absolutePath = combinePaths(currentDirectory, path);
|
||||
@@ -1605,7 +1808,7 @@ namespace ts {
|
||||
path = normalizePath(path);
|
||||
currentDirectory = normalizePath(currentDirectory);
|
||||
|
||||
const patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
|
||||
const patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
|
||||
|
||||
const regexFlag = useCaseSensitiveFileNames ? "" : "i";
|
||||
const includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag);
|
||||
@@ -1648,6 +1851,7 @@ namespace ts {
|
||||
function getBasePaths(path: string, includes: string[], useCaseSensitiveFileNames: boolean) {
|
||||
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
|
||||
const basePaths: string[] = [path];
|
||||
|
||||
if (includes) {
|
||||
// Storage for literal base paths amongst the include patterns.
|
||||
const includeBasePaths: string[] = [];
|
||||
@@ -1655,14 +1859,8 @@ namespace ts {
|
||||
// We also need to check the relative paths by converting them to absolute and normalizing
|
||||
// in case they escape the base path (e.g "..\somedirectory")
|
||||
const absolute: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include));
|
||||
|
||||
const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
|
||||
const includeBasePath = wildcardOffset < 0
|
||||
? removeTrailingDirectorySeparator(getDirectoryPath(absolute))
|
||||
: absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
|
||||
|
||||
// Append the literal and canonical candidate base paths.
|
||||
includeBasePaths.push(includeBasePath);
|
||||
includeBasePaths.push(getIncludeBasePath(absolute));
|
||||
}
|
||||
|
||||
// Sort the offsets array using either the literal or canonical path representations.
|
||||
@@ -1670,21 +1868,27 @@ namespace ts {
|
||||
|
||||
// Iterate over each include base path and include unique base paths that are not a
|
||||
// subpath of an existing base path
|
||||
include: for (let i = 0; i < includeBasePaths.length; i++) {
|
||||
const includeBasePath = includeBasePaths[i];
|
||||
for (let j = 0; j < basePaths.length; j++) {
|
||||
if (containsPath(basePaths[j], includeBasePath, path, !useCaseSensitiveFileNames)) {
|
||||
continue include;
|
||||
}
|
||||
for (const includeBasePath of includeBasePaths) {
|
||||
if (ts.every(basePaths, basePath => !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames))) {
|
||||
basePaths.push(includeBasePath);
|
||||
}
|
||||
|
||||
basePaths.push(includeBasePath);
|
||||
}
|
||||
}
|
||||
|
||||
return basePaths;
|
||||
}
|
||||
|
||||
function getIncludeBasePath(absolute: string): string {
|
||||
const wildcardOffset = indexOfAnyCharCode(absolute, wildcardCharCodes);
|
||||
if (wildcardOffset < 0) {
|
||||
// No "*" or "?" in the path
|
||||
return !hasExtension(absolute)
|
||||
? absolute
|
||||
: removeTrailingDirectorySeparator(getDirectoryPath(absolute));
|
||||
}
|
||||
return absolute.substring(0, absolute.lastIndexOf(directorySeparator, wildcardOffset));
|
||||
}
|
||||
|
||||
export function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind {
|
||||
// Using scriptKind as a condition handles both:
|
||||
// - 'scriptKind' is unspecified and thus it is `undefined`
|
||||
@@ -1718,10 +1922,20 @@ namespace ts {
|
||||
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
|
||||
export const supportedTypescriptExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
|
||||
export const supportedJavascriptExtensions = [".js", ".jsx"];
|
||||
const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions);
|
||||
const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions);
|
||||
|
||||
export function getSupportedExtensions(options?: CompilerOptions): string[] {
|
||||
return options && options.allowJs ? allSupportedExtensions : supportedTypeScriptExtensions;
|
||||
export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]): string[] {
|
||||
const needAllExtensions = options && options.allowJs;
|
||||
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
||||
return needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions;
|
||||
}
|
||||
const extensions = (needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions).slice(0);
|
||||
for (const extInfo of extraFileExtensions) {
|
||||
if (needAllExtensions || extInfo.scriptKind === ScriptKind.TS) {
|
||||
extensions.push(extInfo.extension);
|
||||
}
|
||||
}
|
||||
return extensions;
|
||||
}
|
||||
|
||||
export function hasJavaScriptFileExtension(fileName: string) {
|
||||
@@ -1732,10 +1946,10 @@ namespace ts {
|
||||
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
|
||||
}
|
||||
|
||||
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions) {
|
||||
export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: FileExtensionInfo[]) {
|
||||
if (!fileName) { return false; }
|
||||
|
||||
for (const extension of getSupportedExtensions(compilerOptions)) {
|
||||
for (const extension of getSupportedExtensions(compilerOptions, extraFileExtensions)) {
|
||||
if (fileExtensionIs(fileName, extension)) {
|
||||
return true;
|
||||
}
|
||||
@@ -1815,10 +2029,6 @@ namespace ts {
|
||||
return path.substring(0, path.length - extension.length);
|
||||
}
|
||||
|
||||
export function isJsxOrTsxExtension(ext: string): boolean {
|
||||
return ext === ".jsx" || ext === ".tsx";
|
||||
}
|
||||
|
||||
export function changeExtension<T extends string | Path>(path: T, newExtension: string): T {
|
||||
return <T>(removeFileExtension(path) + newExtension);
|
||||
}
|
||||
@@ -1839,11 +2049,11 @@ namespace ts {
|
||||
this.declarations = undefined;
|
||||
}
|
||||
|
||||
function Type(this: Type, checker: TypeChecker, flags: TypeFlags) {
|
||||
function Type(this: Type, _checker: TypeChecker, flags: TypeFlags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
function Signature(checker: TypeChecker) {
|
||||
function Signature() {
|
||||
}
|
||||
|
||||
function Node(this: Node, kind: SyntaxKind, pos: number, end: number) {
|
||||
@@ -1876,9 +2086,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
export namespace Debug {
|
||||
declare var process: any;
|
||||
declare var require: any;
|
||||
|
||||
export let currentAssertionLevel = AssertionLevel.None;
|
||||
|
||||
export function shouldAssert(level: AssertionLevel): boolean {
|
||||
@@ -1902,6 +2109,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Remove an item from an array, moving everything to its right one space left. */
|
||||
export function orderedRemoveItem<T>(array: T[], item: T): boolean {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (array[i] === item) {
|
||||
orderedRemoveItemAt(array, i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Remove an item by index from an array, moving everything to its right one space left. */
|
||||
export function orderedRemoveItemAt<T>(array: T[], index: number): void {
|
||||
// This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`.
|
||||
for (let i = index; i < array.length - 1; i++) {
|
||||
@@ -2014,4 +2232,38 @@ namespace ts {
|
||||
// pos === undefined || pos === null || isNaN(pos) || pos < 0;
|
||||
return !(pos >= 0);
|
||||
}
|
||||
|
||||
/** True if an extension is one of the supported TypeScript extensions. */
|
||||
export function extensionIsTypeScript(ext: Extension): boolean {
|
||||
return ext <= Extension.LastTypeScriptExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extension from a path.
|
||||
* Path must have a valid extension.
|
||||
*/
|
||||
export function extensionFromPath(path: string): Extension {
|
||||
const ext = tryGetExtensionFromPath(path);
|
||||
if (ext !== undefined) {
|
||||
return ext;
|
||||
}
|
||||
Debug.fail(`File ${path} has unknown extension.`);
|
||||
}
|
||||
export function tryGetExtensionFromPath(path: string): Extension | undefined {
|
||||
if (fileExtensionIs(path, ".d.ts")) {
|
||||
return Extension.Dts;
|
||||
}
|
||||
if (fileExtensionIs(path, ".ts")) {
|
||||
return Extension.Ts;
|
||||
}
|
||||
if (fileExtensionIs(path, ".tsx")) {
|
||||
return Extension.Tsx;
|
||||
}
|
||||
if (fileExtensionIs(path, ".js")) {
|
||||
return Extension.Js;
|
||||
}
|
||||
if (fileExtensionIs(path, ".jsx")) {
|
||||
return Extension.Jsx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ts {
|
||||
let isCurrentFileExternalModule: boolean;
|
||||
let reportedDeclarationError = false;
|
||||
let errorNameNode: DeclarationName;
|
||||
const emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments;
|
||||
const emitJsDocComments = compilerOptions.removeComments ? noop : writeJsDocComments;
|
||||
const emit = compilerOptions.stripInternal ? stripInternal : emitNode;
|
||||
let noDeclare: boolean;
|
||||
|
||||
@@ -194,6 +194,7 @@ namespace ts {
|
||||
writer.writeSpace = writer.write;
|
||||
writer.writeStringLiteral = writer.writeLiteral;
|
||||
writer.writeParameter = writer.write;
|
||||
writer.writeProperty = writer.write;
|
||||
writer.writeSymbol = writer.write;
|
||||
setWriter(writer);
|
||||
}
|
||||
@@ -371,7 +372,7 @@ namespace ts {
|
||||
|
||||
function writeJsDocComments(declaration: Node) {
|
||||
if (declaration) {
|
||||
const jsDocComments = getJsDocCommentsFromText(declaration, currentText);
|
||||
const jsDocComments = getJSDocCommentRanges(declaration, currentText);
|
||||
emitNewLineBeforeLeadingComments(currentLineMap, writer, declaration, jsDocComments);
|
||||
// jsDoc comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
emitComments(currentText, currentLineMap, writer, jsDocComments, /*leadingSeparator*/ false, /*trailingSeparator*/ true, newLine, writeCommentRange);
|
||||
@@ -413,6 +414,12 @@ namespace ts {
|
||||
return emitIntersectionType(<IntersectionTypeNode>type);
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return emitParenType(<ParenthesizedTypeNode>type);
|
||||
case SyntaxKind.TypeOperator:
|
||||
return emitTypeOperator(<TypeOperatorNode>type);
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return emitIndexedAccessType(<IndexedAccessTypeNode>type);
|
||||
case SyntaxKind.MappedType:
|
||||
return emitMappedType(<MappedTypeNode>type);
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
return emitSignatureDeclarationWithJsDocComments(<FunctionOrConstructorTypeNode>type);
|
||||
@@ -506,6 +513,45 @@ namespace ts {
|
||||
write(")");
|
||||
}
|
||||
|
||||
function emitTypeOperator(type: TypeOperatorNode) {
|
||||
write(tokenToString(type.operator));
|
||||
write(" ");
|
||||
emitType(type.type);
|
||||
}
|
||||
|
||||
function emitIndexedAccessType(node: IndexedAccessTypeNode) {
|
||||
emitType(node.objectType);
|
||||
write("[");
|
||||
emitType(node.indexType);
|
||||
write("]");
|
||||
}
|
||||
|
||||
function emitMappedType(node: MappedTypeNode) {
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
write("{");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
if (node.readonlyToken) {
|
||||
write("readonly ");
|
||||
}
|
||||
write("[");
|
||||
writeEntityName(node.typeParameter.name);
|
||||
write(" in ");
|
||||
emitType(node.typeParameter.constraint);
|
||||
write("]");
|
||||
if (node.questionToken) {
|
||||
write("?");
|
||||
}
|
||||
write(": ");
|
||||
emitType(node.type);
|
||||
write(";");
|
||||
writeLine();
|
||||
decreaseIndent();
|
||||
write("}");
|
||||
enclosingDeclaration = prevEnclosingDeclaration;
|
||||
}
|
||||
|
||||
function emitTypeLiteral(type: TypeLiteralNode) {
|
||||
write("{");
|
||||
if (type.members.length) {
|
||||
@@ -580,7 +626,7 @@ namespace ts {
|
||||
writeAsynchronousModuleElements(nodes);
|
||||
}
|
||||
|
||||
function getDefaultExportAccessibilityDiagnostic(diagnostic: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getDefaultExportAccessibilityDiagnostic(): SymbolAccessibilityDiagnostic {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
|
||||
errorNode: node
|
||||
@@ -710,7 +756,7 @@ namespace ts {
|
||||
}
|
||||
writer.writeLine();
|
||||
|
||||
function getImportEntityNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getImportEntityNameVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Import_declaration_0_is_using_private_name_1,
|
||||
errorNode: node,
|
||||
@@ -888,7 +934,7 @@ namespace ts {
|
||||
writeLine();
|
||||
enclosingDeclaration = prevEnclosingDeclaration;
|
||||
|
||||
function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getTypeAliasDeclarationVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
|
||||
errorNode: node.type,
|
||||
@@ -955,7 +1001,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getTypeParameterConstraintVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
// Type parameter constraints are named by user so we should always be able to name it
|
||||
let diagnosticMessage: DiagnosticMessage;
|
||||
switch (node.parent.kind) {
|
||||
@@ -992,6 +1038,10 @@ namespace ts {
|
||||
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
|
||||
break;
|
||||
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
|
||||
}
|
||||
@@ -1029,7 +1079,7 @@ namespace ts {
|
||||
resolver.writeBaseConstructorTypeOfClass(<ClassLikeDeclaration>enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
}
|
||||
|
||||
function getHeritageClauseVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
let diagnosticMessage: DiagnosticMessage;
|
||||
// Heritage clause is written by user so it can always be named
|
||||
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
@@ -1098,7 +1148,10 @@ namespace ts {
|
||||
const prevEnclosingDeclaration = enclosingDeclaration;
|
||||
enclosingDeclaration = node;
|
||||
emitTypeParameters(node.typeParameters);
|
||||
emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false);
|
||||
const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression));
|
||||
if (interfaceExtendsTypes && interfaceExtendsTypes.length) {
|
||||
emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false);
|
||||
}
|
||||
write(" {");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
@@ -1573,6 +1626,12 @@ namespace ts {
|
||||
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
|
||||
Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
|
||||
|
||||
case SyntaxKind.IndexSignature:
|
||||
// Interfaces cannot have parameter types that cannot be named
|
||||
return symbolAccessibilityResult.errorModuleName ?
|
||||
Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
|
||||
Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
if (hasModifier(node.parent, ModifierFlags.Static)) {
|
||||
@@ -1743,7 +1802,7 @@ namespace ts {
|
||||
}
|
||||
return addedBundledEmitReference;
|
||||
|
||||
function getDeclFileName(emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) {
|
||||
function getDeclFileName(emitFileNames: EmitFileNames, _sourceFiles: SourceFile[], isBundledEmit: boolean) {
|
||||
// Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path
|
||||
if (isBundledEmit && !addBundledFileReference) {
|
||||
return;
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
"category": "Error",
|
||||
"code": 1054
|
||||
},
|
||||
"Type '{0}' is not a valid async function return type.": {
|
||||
"Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.": {
|
||||
"category": "Error",
|
||||
"code": 1055
|
||||
},
|
||||
@@ -227,7 +227,7 @@
|
||||
"category": "Error",
|
||||
"code": 1084
|
||||
},
|
||||
"Octal literals are not available when targeting ECMAScript 5 and higher.": {
|
||||
"Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 1085
|
||||
},
|
||||
@@ -603,10 +603,6 @@
|
||||
"category": "Error",
|
||||
"code": 1194
|
||||
},
|
||||
"Catch clause variable name must be an identifier.": {
|
||||
"category": "Error",
|
||||
"code": 1195
|
||||
},
|
||||
"Catch clause variable cannot have a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 1196
|
||||
@@ -855,6 +851,14 @@
|
||||
"category": "Error",
|
||||
"code": 1317
|
||||
},
|
||||
"An abstract accessor cannot have an implementation.": {
|
||||
"category": "Error",
|
||||
"code": 1318
|
||||
},
|
||||
"A default export can only be used in an ECMAScript-style module.": {
|
||||
"category": "Error",
|
||||
"code": 1319
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2300
|
||||
@@ -1027,6 +1031,10 @@
|
||||
"category": "Error",
|
||||
"code": 2342
|
||||
},
|
||||
"This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2343
|
||||
},
|
||||
"Type '{0}' does not satisfy the constraint '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2344
|
||||
@@ -1067,6 +1075,10 @@
|
||||
"category": "Error",
|
||||
"code": 2353
|
||||
},
|
||||
"This syntax requires an imported helper but module '{0}' cannot be found.": {
|
||||
"category": "Error",
|
||||
"code": 2354
|
||||
},
|
||||
"A function whose declared type is neither 'void' nor 'any' must return a value.": {
|
||||
"category": "Error",
|
||||
"code": 2355
|
||||
@@ -1075,7 +1087,7 @@
|
||||
"category": "Error",
|
||||
"code": 2356
|
||||
},
|
||||
"The operand of an increment or decrement operator must be a variable, property or indexer.": {
|
||||
"The operand of an increment or decrement operator must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2357
|
||||
},
|
||||
@@ -1103,7 +1115,7 @@
|
||||
"category": "Error",
|
||||
"code": 2363
|
||||
},
|
||||
"Invalid left-hand side of assignment expression.": {
|
||||
"The left-hand side of an assignment expression must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2364
|
||||
},
|
||||
@@ -1263,7 +1275,7 @@
|
||||
"category": "Error",
|
||||
"code": 2405
|
||||
},
|
||||
"Invalid left-hand side in 'for...in' statement.": {
|
||||
"The left-hand side of a 'for...in' statement must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2406
|
||||
},
|
||||
@@ -1415,14 +1427,6 @@
|
||||
"category": "Error",
|
||||
"code": 2448
|
||||
},
|
||||
"The operand of an increment or decrement operator cannot be a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2449
|
||||
},
|
||||
"Left-hand side of assignment expression cannot be a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2450
|
||||
},
|
||||
"Cannot redeclare block-scoped variable '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2451
|
||||
@@ -1467,7 +1471,7 @@
|
||||
"category": "Error",
|
||||
"code": 2461
|
||||
},
|
||||
"A rest element must be last in an array destructuring pattern": {
|
||||
"A rest element must be last in a destructuring pattern": {
|
||||
"category": "Error",
|
||||
"code": 2462
|
||||
},
|
||||
@@ -1555,15 +1559,7 @@
|
||||
"category": "Error",
|
||||
"code": 2484
|
||||
},
|
||||
"The left-hand side of a 'for...of' statement cannot be a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2485
|
||||
},
|
||||
"The left-hand side of a 'for...in' statement cannot be a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2486
|
||||
},
|
||||
"Invalid left-hand side in 'for...of' statement.": {
|
||||
"The left-hand side of a 'for...of' statement must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2487
|
||||
},
|
||||
@@ -1751,6 +1747,34 @@
|
||||
"category": "Error",
|
||||
"code": 2535
|
||||
},
|
||||
"Type '{0}' cannot be used to index type '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2536
|
||||
},
|
||||
"Type '{0}' has no matching index signature for type '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2537
|
||||
},
|
||||
"Type '{0}' cannot be used as an index type.": {
|
||||
"category": "Error",
|
||||
"code": 2538
|
||||
},
|
||||
"Cannot assign to '{0}' because it is not a variable.": {
|
||||
"category": "Error",
|
||||
"code": 2539
|
||||
},
|
||||
"Cannot assign to '{0}' because it is a constant or a read-only property.": {
|
||||
"category": "Error",
|
||||
"code": 2540
|
||||
},
|
||||
"The target of an assignment must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2541
|
||||
},
|
||||
"Index signature in type '{0}' only permits reading.": {
|
||||
"category": "Error",
|
||||
"code": 2542
|
||||
},
|
||||
"JSX element attributes type '{0}' may not be a union type.": {
|
||||
"category": "Error",
|
||||
"code": 2600
|
||||
@@ -1787,6 +1811,10 @@
|
||||
"category": "Error",
|
||||
"code": 2608
|
||||
},
|
||||
"JSX spread child must be an array type.": {
|
||||
"category": "Error",
|
||||
"code": 2609
|
||||
},
|
||||
"Cannot emit namespaced JSX elements in React": {
|
||||
"category": "Error",
|
||||
"code": 2650
|
||||
@@ -1843,6 +1871,10 @@
|
||||
"category": "Error",
|
||||
"code": 2664
|
||||
},
|
||||
"Invalid module name in augmentation. Module '{0}' resolves to an untyped module at '{1}', which cannot be augmented.": {
|
||||
"category": "Error",
|
||||
"code": 2665
|
||||
},
|
||||
"Exports and export assignments are not permitted in module augmentations.": {
|
||||
"category": "Error",
|
||||
"code": 2666
|
||||
@@ -1967,6 +1999,34 @@
|
||||
"category": "Error",
|
||||
"code": 2696
|
||||
},
|
||||
"An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.": {
|
||||
"category": "Error",
|
||||
"code": 2697
|
||||
},
|
||||
"Spread types may only be created from object types.": {
|
||||
"category": "Error",
|
||||
"code": 2698
|
||||
},
|
||||
"Rest types may only be created from object types.": {
|
||||
"category": "Error",
|
||||
"code": 2700
|
||||
},
|
||||
"The target of an object rest assignment must be a variable or a property access.": {
|
||||
"category": "Error",
|
||||
"code": 2701
|
||||
},
|
||||
"'{0}' only refers to a type, but is being used as a namespace here.": {
|
||||
"category": "Error",
|
||||
"code": 2702
|
||||
},
|
||||
"The operand of a delete operator must be a property reference": {
|
||||
"category": "Error",
|
||||
"code": 2703
|
||||
},
|
||||
"The operand of a delete operator cannot be a read-only property": {
|
||||
"category": "Error",
|
||||
"code": 2704
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@@ -2248,10 +2308,22 @@
|
||||
"category": "Error",
|
||||
"code": 4082
|
||||
},
|
||||
"Type parameter '{0}' of exported type alias has or is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4083
|
||||
},
|
||||
"Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": {
|
||||
"category": "Message",
|
||||
"code": 4090
|
||||
},
|
||||
"Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 4091
|
||||
},
|
||||
"Parameter '{0}' of index signature from exported interface has or is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4092
|
||||
},
|
||||
|
||||
"The current host does not support the '{0}' option.": {
|
||||
"category": "Error",
|
||||
@@ -2365,6 +2437,10 @@
|
||||
"category": "Error",
|
||||
"code": 5066
|
||||
},
|
||||
"Invalid value for 'jsxFactory'. '{0}' is not a valid identifier or qualified-name.": {
|
||||
"category": "Error",
|
||||
"code": 5067
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
@@ -2413,7 +2489,7 @@
|
||||
"category": "Message",
|
||||
"code": 6012
|
||||
},
|
||||
"Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'": {
|
||||
"Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'": {
|
||||
"category": "Message",
|
||||
"code": 6015
|
||||
},
|
||||
@@ -2625,6 +2701,10 @@
|
||||
"category": "Message",
|
||||
"code": 6080
|
||||
},
|
||||
"File '{0}' has an unsupported extension, so skipping it.": {
|
||||
"category": "Message",
|
||||
"code": 6081
|
||||
},
|
||||
"Only 'amd' and 'system' modules are supported alongside --{0}.": {
|
||||
"category": "Error",
|
||||
"code": 6082
|
||||
@@ -2677,7 +2757,7 @@
|
||||
"category": "Message",
|
||||
"code": 6094
|
||||
},
|
||||
"Loading module as file / folder, candidate module location '{0}'.": {
|
||||
"Loading module as file / folder, candidate module location '{0}', target file type '{1}'.": {
|
||||
"category": "Message",
|
||||
"code": 6095
|
||||
},
|
||||
@@ -2689,7 +2769,7 @@
|
||||
"category": "Message",
|
||||
"code": 6097
|
||||
},
|
||||
"Loading module '{0}' from 'node_modules' folder.": {
|
||||
"Loading module '{0}' from 'node_modules' folder, target file type '{1}'.": {
|
||||
"category": "Message",
|
||||
"code": 6098
|
||||
},
|
||||
@@ -2697,7 +2777,7 @@
|
||||
"category": "Message",
|
||||
"code": 6099
|
||||
},
|
||||
"'package.json' does not have 'types' field.": {
|
||||
"'package.json' does not have a 'types' or 'main' field.": {
|
||||
"category": "Message",
|
||||
"code": 6100
|
||||
},
|
||||
@@ -2845,7 +2925,7 @@
|
||||
"category": "Message",
|
||||
"code": 6136
|
||||
},
|
||||
"No types specified in 'package.json' but 'allowJs' is set, so returning 'main' value of '{0}'": {
|
||||
"No types specified in 'package.json', so returning 'main' value of '{0}'": {
|
||||
"category": "Message",
|
||||
"code": 6137
|
||||
},
|
||||
@@ -2861,6 +2941,38 @@
|
||||
"category": "Error",
|
||||
"code": 6140
|
||||
},
|
||||
"Parse in strict mode and emit \"use strict\" for each source file": {
|
||||
"category": "Message",
|
||||
"code": 6141
|
||||
},
|
||||
"Module '{0}' was resolved to '{1}', but '--jsx' is not set.": {
|
||||
"category": "Error",
|
||||
"code": 6142
|
||||
},
|
||||
"Module '{0}' was resolved to '{1}', but '--allowJs' is not set.": {
|
||||
"category": "Error",
|
||||
"code": 6143
|
||||
},
|
||||
"Module '{0}' was resolved as locally declared ambient module in file '{1}'.": {
|
||||
"category": "Message",
|
||||
"code": 6144
|
||||
},
|
||||
"Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified.": {
|
||||
"category": "Message",
|
||||
"code": 6145
|
||||
},
|
||||
"Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'.": {
|
||||
"category": "Message",
|
||||
"code": 6146
|
||||
},
|
||||
"Resolution for module '{0}' was found in cache.": {
|
||||
"category": "Message",
|
||||
"code": 6147
|
||||
},
|
||||
"Directory '{0}' does not exist, skipping all lookups in it.": {
|
||||
"category": "Message",
|
||||
"code": 6148
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
@@ -2893,7 +3005,11 @@
|
||||
"category": "Error",
|
||||
"code": 7015
|
||||
},
|
||||
"Index signature of object type implicitly has an 'any' type.": {
|
||||
"Could not find a declaration file for module '{0}'. '{1}' implicitly has an 'any' type.": {
|
||||
"category": "Error",
|
||||
"code": 7016
|
||||
},
|
||||
"Element implicitly has an 'any' type because type '{0}' has no index signature.": {
|
||||
"category": "Error",
|
||||
"code": 7017
|
||||
},
|
||||
@@ -2957,7 +3073,7 @@
|
||||
"category": "Error",
|
||||
"code": 7033
|
||||
},
|
||||
"Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined.": {
|
||||
"Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined.": {
|
||||
"category": "Error",
|
||||
"code": 7034
|
||||
},
|
||||
@@ -3029,6 +3145,10 @@
|
||||
"category": "Error",
|
||||
"code": 9003
|
||||
},
|
||||
"Language service is disabled.": {
|
||||
"category": "Error",
|
||||
"code": 9004
|
||||
},
|
||||
"JSX attributes must only be assigned a non-empty 'expression'.": {
|
||||
"category": "Error",
|
||||
"code": 17000
|
||||
@@ -3069,18 +3189,32 @@
|
||||
"category": "Error",
|
||||
"code": 17009
|
||||
},
|
||||
"Unknown typing option '{0}'.": {
|
||||
"Unknown type acquisition option '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 17010
|
||||
},
|
||||
"'super' must be called before accessing a property of 'super' in the constructor of a derived class.": {
|
||||
"category": "Error",
|
||||
"code": 17011
|
||||
},
|
||||
|
||||
"Circularity detected while resolving configuration: {0}": {
|
||||
"category": "Error",
|
||||
"code": 18000
|
||||
},
|
||||
"The path in an 'extends' options must be relative or rooted.": {
|
||||
"A path in an 'extends' option must be relative or rooted, but '{0}' is not.": {
|
||||
"category": "Error",
|
||||
"code": 18001
|
||||
},
|
||||
"The 'files' list in config file '{0}' is empty.": {
|
||||
"category": "Error",
|
||||
"code": 18002
|
||||
},
|
||||
"No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 18003
|
||||
},
|
||||
|
||||
"Add missing 'super()' call.": {
|
||||
"category": "Message",
|
||||
"code": 90001
|
||||
@@ -3108,5 +3242,33 @@
|
||||
"Implement inherited abstract class": {
|
||||
"category": "Message",
|
||||
"code": 90007
|
||||
},
|
||||
"Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig": {
|
||||
"category": "Error",
|
||||
"code": 90009
|
||||
},
|
||||
"Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated.": {
|
||||
"category": "Error",
|
||||
"code": 90010
|
||||
},
|
||||
"Import {0} from {1}": {
|
||||
"category": "Message",
|
||||
"code": 90013
|
||||
},
|
||||
"Change {0} to {1}": {
|
||||
"category": "Message",
|
||||
"code": 90014
|
||||
},
|
||||
"Add {0} to existing import declaration from {1}": {
|
||||
"category": "Message",
|
||||
"code": 90015
|
||||
},
|
||||
"Octal literal types must use ES2015 syntax. Use the syntax '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 8017
|
||||
},
|
||||
"Octal literals are not allowed in enums members initializer. Use the syntax '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 8018
|
||||
}
|
||||
}
|
||||
|
||||
+165
-290
@@ -14,180 +14,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
const id = (s: SourceFile) => s;
|
||||
const nullTransformers: Transformer[] = [ctx => id];
|
||||
const nullTransformers: Transformer[] = [_ => id];
|
||||
|
||||
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
|
||||
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult {
|
||||
const delimiters = createDelimiterMap();
|
||||
const brackets = createBracketsMap();
|
||||
|
||||
// emit output for the __extends helper function
|
||||
const extendsHelper = `
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};`;
|
||||
|
||||
// Emit output for the __assign helper function.
|
||||
// This is typically used for JSX spread attributes,
|
||||
// and can be used for object literal spread properties.
|
||||
const assignHelper = `
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};`;
|
||||
|
||||
// emit output for the __decorate helper function
|
||||
const decorateHelper = `
|
||||
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;
|
||||
};`;
|
||||
|
||||
// emit output for the __metadata helper function
|
||||
const metadataHelper = `
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};`;
|
||||
|
||||
// emit output for the __param helper function
|
||||
const paramHelper = `
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};`;
|
||||
|
||||
// emit output for the __awaiter helper function
|
||||
const awaiterHelper = `
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments)).next());
|
||||
});
|
||||
};`;
|
||||
|
||||
// The __generator helper is used by down-level transformations to emulate the runtime
|
||||
// semantics of an ES2015 generator function. When called, this helper returns an
|
||||
// object that implements the Iterator protocol, in that it has `next`, `return`, and
|
||||
// `throw` methods that step through the generator when invoked.
|
||||
//
|
||||
// parameters:
|
||||
// thisArg The value to use as the `this` binding for the transformed generator body.
|
||||
// body A function that acts as the transformed generator body.
|
||||
//
|
||||
// variables:
|
||||
// _ Persistent state for the generator that is shared between the helper and the
|
||||
// generator body. The state object has the following members:
|
||||
// sent() - A method that returns or throws the current completion value.
|
||||
// label - The next point at which to resume evaluation of the generator body.
|
||||
// trys - A stack of protected regions (try/catch/finally blocks).
|
||||
// ops - A stack of pending instructions when inside of a finally block.
|
||||
// f A value indicating whether the generator is executing.
|
||||
// y An iterator to delegate for a yield*.
|
||||
// t A temporary variable that holds one of the following values (note that these
|
||||
// cases do not overlap):
|
||||
// - The completion value when resuming from a `yield` or `yield*`.
|
||||
// - The error value for a catch block.
|
||||
// - The current protected region (array of try/catch/finally/end labels).
|
||||
// - The verb (`next`, `throw`, or `return` method) to delegate to the expression
|
||||
// of a `yield*`.
|
||||
// - The result of evaluating the verb delegated to the expression of a `yield*`.
|
||||
//
|
||||
// functions:
|
||||
// verb(n) Creates a bound callback to the `step` function for opcode `n`.
|
||||
// step(op) Evaluates opcodes in a generator body until execution is suspended or
|
||||
// completed.
|
||||
//
|
||||
// The __generator helper understands a limited set of instructions:
|
||||
// 0: next(value?) - Start or resume the generator with the specified value.
|
||||
// 1: throw(error) - Resume the generator with an exception. If the generator is
|
||||
// suspended inside of one or more protected regions, evaluates
|
||||
// any intervening finally blocks between the current label and
|
||||
// the nearest catch block or function boundary. If uncaught, the
|
||||
// exception is thrown to the caller.
|
||||
// 2: return(value?) - Resume the generator as if with a return. If the generator is
|
||||
// suspended inside of one or more protected regions, evaluates any
|
||||
// intervening finally blocks.
|
||||
// 3: break(label) - Jump to the specified label. If the label is outside of the
|
||||
// current protected region, evaluates any intervening finally
|
||||
// blocks.
|
||||
// 4: yield(value?) - Yield execution to the caller with an optional value. When
|
||||
// resumed, the generator will continue at the next label.
|
||||
// 5: yield*(value) - Delegates evaluation to the supplied iterator. When
|
||||
// delegation completes, the generator will continue at the next
|
||||
// label.
|
||||
// 6: catch(error) - Handles an exception thrown from within the generator body. If
|
||||
// the current label is inside of one or more protected regions,
|
||||
// evaluates any intervening finally blocks between the current
|
||||
// label and the nearest catch block or function boundary. If
|
||||
// uncaught, the exception is thrown to the caller.
|
||||
// 7: endfinally - Ends a finally block, resuming the last instruction prior to
|
||||
// entering a finally block.
|
||||
//
|
||||
// For examples of how these are used, see the comments in ./transformers/generators.ts
|
||||
const generatorHelper = `
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;
|
||||
return { next: verb(0), "throw": verb(1), "return": verb(2) };
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};`;
|
||||
|
||||
// emit output for the __export helper function
|
||||
const exportStarHelper = `
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}`;
|
||||
|
||||
// emit output for the UMD helper function.
|
||||
const umdHelper = `
|
||||
(function (dependencies, factory) {
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
var v = factory(require, exports); if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
define(dependencies, factory);
|
||||
}
|
||||
})`;
|
||||
|
||||
const superHelper = `
|
||||
const _super = name => super[name];`;
|
||||
|
||||
const advancedSuperHelper = `
|
||||
const _super = (function (geti, seti) {
|
||||
const cache = Object.create(null);
|
||||
return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });
|
||||
})(name => super[name], (name, value) => super[name] = value);`;
|
||||
|
||||
const compilerOptions = host.getCompilerOptions();
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
const moduleKind = getEmitModuleKind(compilerOptions);
|
||||
@@ -224,11 +56,7 @@ const _super = (function (geti, seti) {
|
||||
let currentSourceFile: SourceFile;
|
||||
let currentText: string;
|
||||
let currentFileIdentifiers: Map<string>;
|
||||
let extendsEmitted: boolean;
|
||||
let assignEmitted: boolean;
|
||||
let decorateEmitted: boolean;
|
||||
let paramEmitted: boolean;
|
||||
let awaiterEmitted: boolean;
|
||||
let bundledHelpers: Map<boolean>;
|
||||
let isOwnFileEmit: boolean;
|
||||
let emitSkipped = false;
|
||||
|
||||
@@ -293,12 +121,13 @@ const _super = (function (geti, seti) {
|
||||
nodeIdToGeneratedName = [];
|
||||
autoGeneratedIdToGeneratedName = [];
|
||||
generatedNameSet = createMap<string>();
|
||||
bundledHelpers = isBundledEmit ? createMap<boolean>() : undefined;
|
||||
isOwnFileEmit = !isBundledEmit;
|
||||
|
||||
// Emit helpers from all the files
|
||||
if (isBundledEmit && moduleKind) {
|
||||
for (const sourceFile of sourceFiles) {
|
||||
emitEmitHelpers(sourceFile);
|
||||
emitHelpers(sourceFile, /*isBundle*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +143,7 @@ const _super = (function (geti, seti) {
|
||||
|
||||
// Write the source map
|
||||
if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) {
|
||||
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false);
|
||||
writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), /*writeByteOrderMark*/ false, sourceFiles);
|
||||
}
|
||||
|
||||
// Record source map data for the test harness.
|
||||
@@ -323,7 +152,7 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
// Write the output file
|
||||
writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM);
|
||||
writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles);
|
||||
|
||||
// Reset state
|
||||
sourceMap.reset();
|
||||
@@ -333,11 +162,6 @@ const _super = (function (geti, seti) {
|
||||
tempFlags = TempFlags.Auto;
|
||||
currentSourceFile = undefined;
|
||||
currentText = undefined;
|
||||
extendsEmitted = false;
|
||||
assignEmitted = false;
|
||||
decorateEmitted = false;
|
||||
paramEmitted = false;
|
||||
awaiterEmitted = false;
|
||||
isOwnFileEmit = false;
|
||||
}
|
||||
|
||||
@@ -504,15 +328,29 @@ const _super = (function (geti, seti) {
|
||||
|
||||
// Contextual keywords
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
case SyntaxKind.AsKeyword:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
case SyntaxKind.AwaitKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.ConstructorKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.IsKeyword:
|
||||
case SyntaxKind.ModuleKeyword:
|
||||
case SyntaxKind.NamespaceKeyword:
|
||||
case SyntaxKind.NeverKeyword:
|
||||
case SyntaxKind.ReadonlyKeyword:
|
||||
case SyntaxKind.RequireKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
case SyntaxKind.TypeKeyword:
|
||||
case SyntaxKind.UndefinedKeyword:
|
||||
case SyntaxKind.FromKeyword:
|
||||
case SyntaxKind.GlobalKeyword:
|
||||
case SyntaxKind.OfKeyword:
|
||||
writeTokenText(kind);
|
||||
return;
|
||||
|
||||
@@ -579,7 +417,13 @@ const _super = (function (geti, seti) {
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return emitExpressionWithTypeArguments(<ExpressionWithTypeArguments>node);
|
||||
case SyntaxKind.ThisType:
|
||||
return emitThisType(<ThisTypeNode>node);
|
||||
return emitThisType();
|
||||
case SyntaxKind.TypeOperator:
|
||||
return emitTypeOperator(<TypeOperatorNode>node);
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return emitIndexedAccessType(<IndexedAccessTypeNode>node);
|
||||
case SyntaxKind.MappedType:
|
||||
return emitMappedType(<MappedTypeNode>node);
|
||||
case SyntaxKind.LiteralType:
|
||||
return emitLiteralType(<LiteralTypeNode>node);
|
||||
|
||||
@@ -595,7 +439,7 @@ const _super = (function (geti, seti) {
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return emitTemplateSpan(<TemplateSpan>node);
|
||||
case SyntaxKind.SemicolonClassElement:
|
||||
return emitSemicolonClassElement(<SemicolonClassElement>node);
|
||||
return emitSemicolonClassElement();
|
||||
|
||||
// Statements
|
||||
case SyntaxKind.Block:
|
||||
@@ -603,7 +447,7 @@ const _super = (function (geti, seti) {
|
||||
case SyntaxKind.VariableStatement:
|
||||
return emitVariableStatement(<VariableStatement>node);
|
||||
case SyntaxKind.EmptyStatement:
|
||||
return emitEmptyStatement(<EmptyStatement>node);
|
||||
return emitEmptyStatement();
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
return emitExpressionStatement(<ExpressionStatement>node);
|
||||
case SyntaxKind.IfStatement:
|
||||
@@ -714,6 +558,8 @@ const _super = (function (geti, seti) {
|
||||
return emitPropertyAssignment(<PropertyAssignment>node);
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
return emitShorthandPropertyAssignment(<ShorthandPropertyAssignment>node);
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
return emitSpreadAssignment(node as SpreadAssignment);
|
||||
|
||||
// Enum
|
||||
case SyntaxKind.EnumMember:
|
||||
@@ -804,8 +650,8 @@ const _super = (function (geti, seti) {
|
||||
return emitTemplateExpression(<TemplateExpression>node);
|
||||
case SyntaxKind.YieldExpression:
|
||||
return emitYieldExpression(<YieldExpression>node);
|
||||
case SyntaxKind.SpreadElementExpression:
|
||||
return emitSpreadElementExpression(<SpreadElementExpression>node);
|
||||
case SyntaxKind.SpreadElement:
|
||||
return emitSpreadExpression(<SpreadElement>node);
|
||||
case SyntaxKind.ClassExpression:
|
||||
return emitClassExpression(<ClassExpression>node);
|
||||
case SyntaxKind.OmittedExpression:
|
||||
@@ -861,12 +707,7 @@ const _super = (function (geti, seti) {
|
||||
//
|
||||
|
||||
function emitIdentifier(node: Identifier) {
|
||||
if (getEmitFlags(node) & EmitFlags.UMDDefine) {
|
||||
writeLines(umdHelper);
|
||||
}
|
||||
else {
|
||||
write(getTextOfNode(node, /*includeTrivia*/ false));
|
||||
}
|
||||
write(getTextOfNode(node, /*includeTrivia*/ false));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1000,7 +841,7 @@ const _super = (function (geti, seti) {
|
||||
write(";");
|
||||
}
|
||||
|
||||
function emitSemicolonClassElement(node: SemicolonClassElement) {
|
||||
function emitSemicolonClassElement() {
|
||||
write(";");
|
||||
}
|
||||
|
||||
@@ -1070,10 +911,46 @@ const _super = (function (geti, seti) {
|
||||
write(")");
|
||||
}
|
||||
|
||||
function emitThisType(node: ThisTypeNode) {
|
||||
function emitThisType() {
|
||||
write("this");
|
||||
}
|
||||
|
||||
function emitTypeOperator(node: TypeOperatorNode) {
|
||||
writeTokenText(node.operator);
|
||||
write(" ");
|
||||
emit(node.type);
|
||||
}
|
||||
|
||||
function emitIndexedAccessType(node: IndexedAccessTypeNode) {
|
||||
emit(node.objectType);
|
||||
write("[");
|
||||
emit(node.indexType);
|
||||
write("]");
|
||||
}
|
||||
|
||||
function emitMappedType(node: MappedTypeNode) {
|
||||
write("{");
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
if (node.readonlyToken) {
|
||||
write("readonly ");
|
||||
}
|
||||
write("[");
|
||||
emit(node.typeParameter.name);
|
||||
write(" in ");
|
||||
emit(node.typeParameter.constraint);
|
||||
write("]");
|
||||
if (node.questionToken) {
|
||||
write("?");
|
||||
}
|
||||
write(": ");
|
||||
emit(node.type);
|
||||
write(";");
|
||||
writeLine();
|
||||
decreaseIndent();
|
||||
write("}");
|
||||
}
|
||||
|
||||
function emitLiteralType(node: LiteralTypeNode) {
|
||||
emitExpression(node.literal);
|
||||
}
|
||||
@@ -1198,12 +1075,14 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function emitCallExpression(node: CallExpression) {
|
||||
emitExpression(node.expression);
|
||||
emitTypeArguments(node, node.typeArguments);
|
||||
emitExpressionList(node, node.arguments, ListFormat.CallExpressionArguments);
|
||||
}
|
||||
|
||||
function emitNewExpression(node: NewExpression) {
|
||||
write("new ");
|
||||
emitExpression(node.expression);
|
||||
emitTypeArguments(node, node.typeArguments);
|
||||
emitExpressionList(node, node.arguments, ListFormat.NewExpressionArguments);
|
||||
}
|
||||
|
||||
@@ -1341,7 +1220,7 @@ const _super = (function (geti, seti) {
|
||||
emitExpressionWithPrefix(" ", node.expression);
|
||||
}
|
||||
|
||||
function emitSpreadElementExpression(node: SpreadElementExpression) {
|
||||
function emitSpreadExpression(node: SpreadElement) {
|
||||
write("...");
|
||||
emitExpression(node.expression);
|
||||
}
|
||||
@@ -1381,7 +1260,7 @@ const _super = (function (geti, seti) {
|
||||
// Statements
|
||||
//
|
||||
|
||||
function emitBlock(node: Block, format?: ListFormat) {
|
||||
function emitBlock(node: Block) {
|
||||
if (isSingleLineEmptyBlock(node)) {
|
||||
writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node);
|
||||
write(" ");
|
||||
@@ -1409,7 +1288,7 @@ const _super = (function (geti, seti) {
|
||||
write(";");
|
||||
}
|
||||
|
||||
function emitEmptyStatement(node: EmptyStatement) {
|
||||
function emitEmptyStatement() {
|
||||
write(";");
|
||||
}
|
||||
|
||||
@@ -1424,28 +1303,28 @@ const _super = (function (geti, seti) {
|
||||
writeToken(SyntaxKind.OpenParenToken, openParenPos, node);
|
||||
emitExpression(node.expression);
|
||||
writeToken(SyntaxKind.CloseParenToken, node.expression.end, node);
|
||||
emitEmbeddedStatement(node.thenStatement);
|
||||
emitEmbeddedStatement(node, node.thenStatement);
|
||||
if (node.elseStatement) {
|
||||
writeLine();
|
||||
writeLineOrSpace(node);
|
||||
writeToken(SyntaxKind.ElseKeyword, node.thenStatement.end, node);
|
||||
if (node.elseStatement.kind === SyntaxKind.IfStatement) {
|
||||
write(" ");
|
||||
emit(node.elseStatement);
|
||||
}
|
||||
else {
|
||||
emitEmbeddedStatement(node.elseStatement);
|
||||
emitEmbeddedStatement(node, node.elseStatement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitDoStatement(node: DoStatement) {
|
||||
write("do");
|
||||
emitEmbeddedStatement(node.statement);
|
||||
emitEmbeddedStatement(node, node.statement);
|
||||
if (isBlock(node.statement)) {
|
||||
write(" ");
|
||||
}
|
||||
else {
|
||||
writeLine();
|
||||
writeLineOrSpace(node);
|
||||
}
|
||||
|
||||
write("while (");
|
||||
@@ -1457,7 +1336,7 @@ const _super = (function (geti, seti) {
|
||||
write("while (");
|
||||
emitExpression(node.expression);
|
||||
write(")");
|
||||
emitEmbeddedStatement(node.statement);
|
||||
emitEmbeddedStatement(node, node.statement);
|
||||
}
|
||||
|
||||
function emitForStatement(node: ForStatement) {
|
||||
@@ -1470,7 +1349,7 @@ const _super = (function (geti, seti) {
|
||||
write(";");
|
||||
emitExpressionWithPrefix(" ", node.incrementor);
|
||||
write(")");
|
||||
emitEmbeddedStatement(node.statement);
|
||||
emitEmbeddedStatement(node, node.statement);
|
||||
}
|
||||
|
||||
function emitForInStatement(node: ForInStatement) {
|
||||
@@ -1481,7 +1360,7 @@ const _super = (function (geti, seti) {
|
||||
write(" in ");
|
||||
emitExpression(node.expression);
|
||||
writeToken(SyntaxKind.CloseParenToken, node.expression.end);
|
||||
emitEmbeddedStatement(node.statement);
|
||||
emitEmbeddedStatement(node, node.statement);
|
||||
}
|
||||
|
||||
function emitForOfStatement(node: ForOfStatement) {
|
||||
@@ -1492,7 +1371,7 @@ const _super = (function (geti, seti) {
|
||||
write(" of ");
|
||||
emitExpression(node.expression);
|
||||
writeToken(SyntaxKind.CloseParenToken, node.expression.end);
|
||||
emitEmbeddedStatement(node.statement);
|
||||
emitEmbeddedStatement(node, node.statement);
|
||||
}
|
||||
|
||||
function emitForBinding(node: VariableDeclarationList | Expression) {
|
||||
@@ -1528,7 +1407,7 @@ const _super = (function (geti, seti) {
|
||||
write("with (");
|
||||
emitExpression(node.expression);
|
||||
write(")");
|
||||
emitEmbeddedStatement(node.statement);
|
||||
emitEmbeddedStatement(node, node.statement);
|
||||
}
|
||||
|
||||
function emitSwitchStatement(node: SwitchStatement) {
|
||||
@@ -1556,9 +1435,12 @@ const _super = (function (geti, seti) {
|
||||
function emitTryStatement(node: TryStatement) {
|
||||
write("try ");
|
||||
emit(node.tryBlock);
|
||||
emit(node.catchClause);
|
||||
if (node.catchClause) {
|
||||
writeLineOrSpace(node);
|
||||
emit(node.catchClause);
|
||||
}
|
||||
if (node.finallyBlock) {
|
||||
writeLine();
|
||||
writeLineOrSpace(node);
|
||||
write("finally ");
|
||||
emit(node.finallyBlock);
|
||||
}
|
||||
@@ -1575,6 +1457,7 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function emitVariableDeclaration(node: VariableDeclaration) {
|
||||
emit(node.name);
|
||||
emitWithPrefix(": ", node.type);
|
||||
emitExpressionWithPrefix(" = ", node.initializer);
|
||||
}
|
||||
|
||||
@@ -1606,13 +1489,13 @@ const _super = (function (geti, seti) {
|
||||
|
||||
if (getEmitFlags(node) & EmitFlags.ReuseTempVariableScope) {
|
||||
emitSignatureHead(node);
|
||||
emitBlockFunctionBody(node, body);
|
||||
emitBlockFunctionBody(body);
|
||||
}
|
||||
else {
|
||||
const savedTempFlags = tempFlags;
|
||||
tempFlags = 0;
|
||||
emitSignatureHead(node);
|
||||
emitBlockFunctionBody(node, body);
|
||||
emitBlockFunctionBody(body);
|
||||
tempFlags = savedTempFlags;
|
||||
}
|
||||
|
||||
@@ -1639,7 +1522,7 @@ const _super = (function (geti, seti) {
|
||||
emitWithPrefix(": ", node.type);
|
||||
}
|
||||
|
||||
function shouldEmitBlockFunctionBodyOnSingleLine(parentNode: Node, body: Block) {
|
||||
function shouldEmitBlockFunctionBodyOnSingleLine(body: Block) {
|
||||
// We must emit a function body as a single-line body in the following case:
|
||||
// * The body has NodeEmitFlags.SingleLine specified.
|
||||
|
||||
@@ -1677,12 +1560,12 @@ const _super = (function (geti, seti) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function emitBlockFunctionBody(parentNode: Node, body: Block) {
|
||||
function emitBlockFunctionBody(body: Block) {
|
||||
write(" {");
|
||||
increaseIndent();
|
||||
|
||||
emitBodyWithDetachedComments(body, body.statements,
|
||||
shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body)
|
||||
shouldEmitBlockFunctionBodyOnSingleLine(body)
|
||||
? emitBlockFunctionBodyOnSingleLine
|
||||
: emitBlockFunctionBodyWorker);
|
||||
|
||||
@@ -1969,6 +1852,9 @@ const _super = (function (geti, seti) {
|
||||
function emitJsxExpression(node: JsxExpression) {
|
||||
if (node.expression) {
|
||||
write("{");
|
||||
if (node.dotDotDotToken) {
|
||||
write("...");
|
||||
}
|
||||
emitExpression(node.expression);
|
||||
write("}");
|
||||
}
|
||||
@@ -2068,6 +1954,13 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
}
|
||||
|
||||
function emitSpreadAssignment(node: SpreadAssignment) {
|
||||
if (node.expression) {
|
||||
write("...");
|
||||
emitExpression(node.expression);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Enum
|
||||
//
|
||||
@@ -2124,82 +2017,39 @@ const _super = (function (geti, seti) {
|
||||
return statements.length;
|
||||
}
|
||||
|
||||
function emitHelpers(node: Node) {
|
||||
const emitFlags = getEmitFlags(node);
|
||||
let helpersEmitted = false;
|
||||
if (emitFlags & EmitFlags.EmitEmitHelpers) {
|
||||
helpersEmitted = emitEmitHelpers(currentSourceFile);
|
||||
}
|
||||
|
||||
if (emitFlags & EmitFlags.EmitExportStar) {
|
||||
writeLines(exportStarHelper);
|
||||
helpersEmitted = true;
|
||||
}
|
||||
|
||||
if (emitFlags & EmitFlags.EmitSuperHelper) {
|
||||
writeLines(superHelper);
|
||||
helpersEmitted = true;
|
||||
}
|
||||
|
||||
if (emitFlags & EmitFlags.EmitAdvancedSuperHelper) {
|
||||
writeLines(advancedSuperHelper);
|
||||
helpersEmitted = true;
|
||||
}
|
||||
|
||||
return helpersEmitted;
|
||||
}
|
||||
|
||||
function emitEmitHelpers(node: SourceFile) {
|
||||
// Only emit helpers if the user did not say otherwise.
|
||||
if (compilerOptions.noEmitHelpers) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't emit helpers if we can import them.
|
||||
if (compilerOptions.importHelpers
|
||||
&& (isExternalModule(node) || compilerOptions.isolatedModules)) {
|
||||
return false;
|
||||
}
|
||||
function emitHelpers(node: Node, isBundle?: boolean) {
|
||||
const sourceFile = isSourceFile(node) ? node : currentSourceFile;
|
||||
const shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && getExternalHelpersModuleName(sourceFile) !== undefined);
|
||||
const shouldBundle = isSourceFile(node) && !isOwnFileEmit;
|
||||
|
||||
let helpersEmitted = false;
|
||||
const helpers = getEmitHelpers(node);
|
||||
if (helpers) {
|
||||
for (const helper of stableSort(helpers, compareEmitHelpers)) {
|
||||
if (!helper.scoped) {
|
||||
// Skip the helper if it can be skipped and the noEmitHelpers compiler
|
||||
// option is set, or if it can be imported and the importHelpers compiler
|
||||
// option is set.
|
||||
if (shouldSkip) continue;
|
||||
|
||||
// Only Emit __extends function when target ES5.
|
||||
// For target ES6 and above, we can emit classDeclaration as is.
|
||||
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) {
|
||||
writeLines(extendsHelper);
|
||||
extendsEmitted = true;
|
||||
helpersEmitted = true;
|
||||
}
|
||||
// Skip the helper if it can be bundled but hasn't already been emitted and we
|
||||
// are emitting a bundled module.
|
||||
if (shouldBundle) {
|
||||
if (bundledHelpers[helper.name]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (compilerOptions.jsx !== JsxEmit.Preserve && !assignEmitted && (node.flags & NodeFlags.HasJsxSpreadAttributes)) {
|
||||
writeLines(assignHelper);
|
||||
assignEmitted = true;
|
||||
}
|
||||
bundledHelpers[helper.name] = true;
|
||||
}
|
||||
}
|
||||
else if (isBundle) {
|
||||
// Skip the helper if it is scoped and we are emitting bundled helpers
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!decorateEmitted && node.flags & NodeFlags.HasDecorators) {
|
||||
writeLines(decorateHelper);
|
||||
if (compilerOptions.emitDecoratorMetadata) {
|
||||
writeLines(metadataHelper);
|
||||
writeLines(helper.text);
|
||||
helpersEmitted = true;
|
||||
}
|
||||
|
||||
decorateEmitted = true;
|
||||
helpersEmitted = true;
|
||||
}
|
||||
|
||||
if (!paramEmitted && node.flags & NodeFlags.HasParamDecorators) {
|
||||
writeLines(paramHelper);
|
||||
paramEmitted = true;
|
||||
helpersEmitted = true;
|
||||
}
|
||||
|
||||
if (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions) {
|
||||
writeLines(awaiterHelper);
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
writeLines(generatorHelper);
|
||||
}
|
||||
|
||||
awaiterEmitted = true;
|
||||
helpersEmitted = true;
|
||||
}
|
||||
|
||||
if (helpersEmitted) {
|
||||
@@ -2210,9 +2060,10 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
function writeLines(text: string): void {
|
||||
const lines = text.split(/\r\n|\r|\n/g);
|
||||
const lines = text.split(/\r\n?|\n/g);
|
||||
const indentation = guessIndentation(lines);
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
const line = indentation ? lines[i].slice(indentation) : lines[i];
|
||||
if (line.length) {
|
||||
if (i > 0) {
|
||||
writeLine();
|
||||
@@ -2222,6 +2073,21 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
}
|
||||
|
||||
function guessIndentation(lines: string[]) {
|
||||
let indentation: number;
|
||||
for (const line of lines) {
|
||||
for (let i = 0; i < line.length && (indentation === undefined || i < indentation); i++) {
|
||||
if (!isWhiteSpace(line.charCodeAt(i))) {
|
||||
if (indentation === undefined || i < indentation) {
|
||||
indentation = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return indentation;
|
||||
}
|
||||
|
||||
//
|
||||
// Helpers
|
||||
//
|
||||
@@ -2263,8 +2129,8 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
}
|
||||
|
||||
function emitEmbeddedStatement(node: Statement) {
|
||||
if (isBlock(node)) {
|
||||
function emitEmbeddedStatement(parent: Node, node: Statement) {
|
||||
if (isBlock(node) || getEmitFlags(parent) & EmitFlags.SingleLine) {
|
||||
write(" ");
|
||||
emit(node);
|
||||
}
|
||||
@@ -2429,6 +2295,15 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
}
|
||||
|
||||
function writeLineOrSpace(node: Node) {
|
||||
if (getEmitFlags(node) & EmitFlags.SingleLine) {
|
||||
write(" ");
|
||||
}
|
||||
else {
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
|
||||
function writeIfAny(nodes: NodeArray<Node>, text: string) {
|
||||
if (nodes && nodes.length > 0) {
|
||||
write(text);
|
||||
|
||||
+893
-370
File diff suppressed because it is too large
Load Diff
+562
-264
File diff suppressed because it is too large
Load Diff
+198
-46
@@ -74,6 +74,8 @@ namespace ts {
|
||||
visitNode(cbNode, (<ShorthandPropertyAssignment>node).questionToken) ||
|
||||
visitNode(cbNode, (<ShorthandPropertyAssignment>node).equalsToken) ||
|
||||
visitNode(cbNode, (<ShorthandPropertyAssignment>node).objectAssignmentInitializer);
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
return visitNode(cbNode, (<SpreadAssignment>node).expression);
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
@@ -134,7 +136,16 @@ namespace ts {
|
||||
case SyntaxKind.IntersectionType:
|
||||
return visitNodes(cbNodes, (<UnionOrIntersectionTypeNode>node).types);
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return visitNode(cbNode, (<ParenthesizedTypeNode>node).type);
|
||||
case SyntaxKind.TypeOperator:
|
||||
return visitNode(cbNode, (<ParenthesizedTypeNode | TypeOperatorNode>node).type);
|
||||
case SyntaxKind.IndexedAccessType:
|
||||
return visitNode(cbNode, (<IndexedAccessTypeNode>node).objectType) ||
|
||||
visitNode(cbNode, (<IndexedAccessTypeNode>node).indexType);
|
||||
case SyntaxKind.MappedType:
|
||||
return visitNode(cbNode, (<MappedTypeNode>node).readonlyToken) ||
|
||||
visitNode(cbNode, (<MappedTypeNode>node).typeParameter) ||
|
||||
visitNode(cbNode, (<MappedTypeNode>node).questionToken) ||
|
||||
visitNode(cbNode, (<MappedTypeNode>node).type);
|
||||
case SyntaxKind.LiteralType:
|
||||
return visitNode(cbNode, (<LiteralTypeNode>node).literal);
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
@@ -193,8 +204,8 @@ namespace ts {
|
||||
visitNode(cbNode, (<ConditionalExpression>node).whenTrue) ||
|
||||
visitNode(cbNode, (<ConditionalExpression>node).colonToken) ||
|
||||
visitNode(cbNode, (<ConditionalExpression>node).whenFalse);
|
||||
case SyntaxKind.SpreadElementExpression:
|
||||
return visitNode(cbNode, (<SpreadElementExpression>node).expression);
|
||||
case SyntaxKind.SpreadElement:
|
||||
return visitNode(cbNode, (<SpreadElement>node).expression);
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return visitNodes(cbNodes, (<Block>node).statements);
|
||||
@@ -362,7 +373,8 @@ namespace ts {
|
||||
case SyntaxKind.JsxSpreadAttribute:
|
||||
return visitNode(cbNode, (<JsxSpreadAttribute>node).expression);
|
||||
case SyntaxKind.JsxExpression:
|
||||
return visitNode(cbNode, (<JsxExpression>node).expression);
|
||||
return visitNode(cbNode, (node as JsxExpression).dotDotDotToken) ||
|
||||
visitNode(cbNode, (node as JsxExpression).expression);
|
||||
case SyntaxKind.JsxClosingElement:
|
||||
return visitNode(cbNode, (<JsxClosingElement>node).tagName);
|
||||
|
||||
@@ -407,10 +419,13 @@ namespace ts {
|
||||
return visitNode(cbNode, (<JSDocReturnTag>node).typeExpression);
|
||||
case SyntaxKind.JSDocTypeTag:
|
||||
return visitNode(cbNode, (<JSDocTypeTag>node).typeExpression);
|
||||
case SyntaxKind.JSDocAugmentsTag:
|
||||
return visitNode(cbNode, (<JSDocAugmentsTag>node).typeExpression);
|
||||
case SyntaxKind.JSDocTemplateTag:
|
||||
return visitNodes(cbNodes, (<JSDocTemplateTag>node).typeParameters);
|
||||
case SyntaxKind.JSDocTypedefTag:
|
||||
return visitNode(cbNode, (<JSDocTypedefTag>node).typeExpression) ||
|
||||
visitNode(cbNode, (<JSDocTypedefTag>node).fullName) ||
|
||||
visitNode(cbNode, (<JSDocTypedefTag>node).name) ||
|
||||
visitNode(cbNode, (<JSDocTypedefTag>node).jsDocTypeLiteral);
|
||||
case SyntaxKind.JSDocTypeLiteral:
|
||||
@@ -433,6 +448,10 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName {
|
||||
return Parser.parseIsolatedEntityName(text, languageVersion);
|
||||
}
|
||||
|
||||
export function isExternalModule(file: SourceFile): boolean {
|
||||
return file.externalModuleIndicator !== undefined;
|
||||
}
|
||||
@@ -572,10 +591,10 @@ namespace ts {
|
||||
// attached to the EOF token.
|
||||
let parseErrorBeforeNextFinishedNode = false;
|
||||
|
||||
export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
|
||||
export function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
|
||||
scriptKind = ensureScriptKind(fileName, scriptKind);
|
||||
|
||||
initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind);
|
||||
initializeState(sourceText, languageVersion, syntaxCursor, scriptKind);
|
||||
|
||||
const result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind);
|
||||
|
||||
@@ -584,12 +603,22 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function parseIsolatedEntityName(content: string, languageVersion: ScriptTarget): EntityName {
|
||||
initializeState(content, languageVersion, /*syntaxCursor*/ undefined, ScriptKind.JS);
|
||||
// Prime the scanner.
|
||||
nextToken();
|
||||
const entityName = parseEntityName(/*allowReservedWords*/ true);
|
||||
const isInvalid = token() === SyntaxKind.EndOfFileToken && !parseDiagnostics.length;
|
||||
clearState();
|
||||
return isInvalid ? entityName : undefined;
|
||||
}
|
||||
|
||||
function getLanguageVariant(scriptKind: ScriptKind) {
|
||||
// .tsx and .jsx files are treated as jsx language variant.
|
||||
return scriptKind === ScriptKind.TSX || scriptKind === ScriptKind.JSX || scriptKind === ScriptKind.JS ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
}
|
||||
|
||||
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) {
|
||||
function initializeState(_sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) {
|
||||
NodeConstructor = objectAllocator.getNodeConstructor();
|
||||
TokenConstructor = objectAllocator.getTokenConstructor();
|
||||
IdentifierConstructor = objectAllocator.getIdentifierConstructor();
|
||||
@@ -655,7 +684,7 @@ namespace ts {
|
||||
|
||||
|
||||
function addJSDocComment<T extends Node>(node: T): T {
|
||||
const comments = getJsDocCommentsFromText(node, sourceFile.text);
|
||||
const comments = getJSDocCommentRanges(node, sourceFile.text);
|
||||
if (comments) {
|
||||
for (const comment of comments) {
|
||||
const jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos);
|
||||
@@ -663,10 +692,10 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!node.jsDocComments) {
|
||||
node.jsDocComments = [];
|
||||
if (!node.jsDoc) {
|
||||
node.jsDoc = [];
|
||||
}
|
||||
node.jsDocComments.push(jsDoc);
|
||||
node.jsDoc.push(jsDoc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,11 +722,11 @@ namespace ts {
|
||||
const saveParent = parent;
|
||||
parent = n;
|
||||
forEachChild(n, visitNode);
|
||||
if (n.jsDocComments) {
|
||||
for (const jsDocComment of n.jsDocComments) {
|
||||
jsDocComment.parent = n;
|
||||
parent = jsDocComment;
|
||||
forEachChild(jsDocComment, visitNode);
|
||||
if (n.jsDoc) {
|
||||
for (const jsDoc of n.jsDoc) {
|
||||
jsDoc.parent = n;
|
||||
parent = jsDoc;
|
||||
forEachChild(jsDoc, visitNode);
|
||||
}
|
||||
}
|
||||
parent = saveParent;
|
||||
@@ -1142,7 +1171,7 @@ namespace ts {
|
||||
|
||||
function parsePropertyNameWorker(allowComputedPropertyNames: boolean): PropertyName {
|
||||
if (token() === SyntaxKind.StringLiteral || token() === SyntaxKind.NumericLiteral) {
|
||||
return parseLiteralNode(/*internName*/ true);
|
||||
return <StringLiteral | NumericLiteral>parseLiteralNode(/*internName*/ true);
|
||||
}
|
||||
if (allowComputedPropertyNames && token() === SyntaxKind.OpenBracketToken) {
|
||||
return parseComputedPropertyName();
|
||||
@@ -1264,9 +1293,11 @@ namespace ts {
|
||||
// which would be a candidate for improved error reporting.
|
||||
return token() === SyntaxKind.OpenBracketToken || isLiteralPropertyName();
|
||||
case ParsingContext.ObjectLiteralMembers:
|
||||
return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.AsteriskToken || isLiteralPropertyName();
|
||||
return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.AsteriskToken || token() === SyntaxKind.DotDotDotToken || isLiteralPropertyName();
|
||||
case ParsingContext.RestProperties:
|
||||
return isLiteralPropertyName();
|
||||
case ParsingContext.ObjectBindingElements:
|
||||
return token() === SyntaxKind.OpenBracketToken || isLiteralPropertyName();
|
||||
return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.DotDotDotToken || isLiteralPropertyName();
|
||||
case ParsingContext.HeritageClauseElement:
|
||||
// If we see { } then only consume it as an expression if it is followed by , or {
|
||||
// That way we won't consume the body of a class in its heritage clause.
|
||||
@@ -1393,6 +1424,7 @@ namespace ts {
|
||||
case ParsingContext.ArrayBindingElements:
|
||||
return token() === SyntaxKind.CloseBracketToken;
|
||||
case ParsingContext.Parameters:
|
||||
case ParsingContext.RestProperties:
|
||||
// Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery
|
||||
return token() === SyntaxKind.CloseParenToken || token() === SyntaxKind.CloseBracketToken /*|| token === SyntaxKind.OpenBraceToken*/;
|
||||
case ParsingContext.TypeArguments:
|
||||
@@ -1578,6 +1610,9 @@ namespace ts {
|
||||
case ParsingContext.Parameters:
|
||||
return isReusableParameter(node);
|
||||
|
||||
case ParsingContext.RestProperties:
|
||||
return false;
|
||||
|
||||
// Any other lists we do not care about reusing nodes in. But feel free to add if
|
||||
// you can do so safely. Danger areas involve nodes that may involve speculative
|
||||
// parsing. If speculative parsing is involved with the node, then the range the
|
||||
@@ -1644,8 +1679,8 @@ namespace ts {
|
||||
// Method declarations are not necessarily reusable. An object-literal
|
||||
// may have a method calls "constructor(...)" and we must reparse that
|
||||
// into an actual .ConstructorDeclaration.
|
||||
let methodDeclaration = <MethodDeclaration>node;
|
||||
let nameIsConstructor = methodDeclaration.name.kind === SyntaxKind.Identifier &&
|
||||
const methodDeclaration = <MethodDeclaration>node;
|
||||
const nameIsConstructor = methodDeclaration.name.kind === SyntaxKind.Identifier &&
|
||||
(<Identifier>methodDeclaration.name).originalKeywordKind === SyntaxKind.ConstructorKeyword;
|
||||
|
||||
return !nameIsConstructor;
|
||||
@@ -1775,6 +1810,7 @@ namespace ts {
|
||||
case ParsingContext.BlockStatements: return Diagnostics.Declaration_or_statement_expected;
|
||||
case ParsingContext.SwitchClauses: return Diagnostics.case_or_default_expected;
|
||||
case ParsingContext.SwitchClauseStatements: return Diagnostics.Statement_expected;
|
||||
case ParsingContext.RestProperties: // fallthrough
|
||||
case ParsingContext.TypeMembers: return Diagnostics.Property_or_signature_expected;
|
||||
case ParsingContext.ClassMembers: return Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected;
|
||||
case ParsingContext.EnumMembers: return Diagnostics.Enum_member_expected;
|
||||
@@ -2394,6 +2430,36 @@ namespace ts {
|
||||
return members;
|
||||
}
|
||||
|
||||
function isStartOfMappedType() {
|
||||
nextToken();
|
||||
if (token() === SyntaxKind.ReadonlyKeyword) {
|
||||
nextToken();
|
||||
}
|
||||
return token() === SyntaxKind.OpenBracketToken && nextTokenIsIdentifier() && nextToken() === SyntaxKind.InKeyword;
|
||||
}
|
||||
|
||||
function parseMappedTypeParameter() {
|
||||
const node = <TypeParameterDeclaration>createNode(SyntaxKind.TypeParameter);
|
||||
node.name = parseIdentifier();
|
||||
parseExpected(SyntaxKind.InKeyword);
|
||||
node.constraint = parseType();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseMappedType() {
|
||||
const node = <MappedTypeNode>createNode(SyntaxKind.MappedType);
|
||||
parseExpected(SyntaxKind.OpenBraceToken);
|
||||
node.readonlyToken = parseOptionalToken(SyntaxKind.ReadonlyKeyword);
|
||||
parseExpected(SyntaxKind.OpenBracketToken);
|
||||
node.typeParameter = parseMappedTypeParameter();
|
||||
parseExpected(SyntaxKind.CloseBracketToken);
|
||||
node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken);
|
||||
node.type = parseTypeAnnotation();
|
||||
parseSemicolon();
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseTupleType(): TupleTypeNode {
|
||||
const node = <TupleTypeNode>createNode(SyntaxKind.TupleType);
|
||||
node.elementTypes = parseBracketedList(ParsingContext.TupleElementTypes, parseType, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
|
||||
@@ -2467,7 +2533,7 @@ namespace ts {
|
||||
case SyntaxKind.TypeOfKeyword:
|
||||
return parseTypeQuery();
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
return parseTypeLiteral();
|
||||
return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
return parseTupleType();
|
||||
case SyntaxKind.OpenParenToken:
|
||||
@@ -2493,6 +2559,8 @@ namespace ts {
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
case SyntaxKind.LessThanToken:
|
||||
case SyntaxKind.BarToken:
|
||||
case SyntaxKind.AmpersandToken:
|
||||
case SyntaxKind.NewKeyword:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
@@ -2518,15 +2586,41 @@ namespace ts {
|
||||
function parseArrayTypeOrHigher(): TypeNode {
|
||||
let type = parseNonArrayType();
|
||||
while (!scanner.hasPrecedingLineBreak() && parseOptional(SyntaxKind.OpenBracketToken)) {
|
||||
parseExpected(SyntaxKind.CloseBracketToken);
|
||||
const node = <ArrayTypeNode>createNode(SyntaxKind.ArrayType, type.pos);
|
||||
node.elementType = type;
|
||||
type = finishNode(node);
|
||||
if (isStartOfType()) {
|
||||
const node = <IndexedAccessTypeNode>createNode(SyntaxKind.IndexedAccessType, type.pos);
|
||||
node.objectType = type;
|
||||
node.indexType = parseType();
|
||||
parseExpected(SyntaxKind.CloseBracketToken);
|
||||
type = finishNode(node);
|
||||
}
|
||||
else {
|
||||
const node = <ArrayTypeNode>createNode(SyntaxKind.ArrayType, type.pos);
|
||||
node.elementType = type;
|
||||
parseExpected(SyntaxKind.CloseBracketToken);
|
||||
type = finishNode(node);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function parseTypeOperator(operator: SyntaxKind.KeyOfKeyword) {
|
||||
const node = <TypeOperatorNode>createNode(SyntaxKind.TypeOperator);
|
||||
parseExpected(operator);
|
||||
node.operator = operator;
|
||||
node.type = parseTypeOperatorOrHigher();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseTypeOperatorOrHigher(): TypeNode {
|
||||
switch (token()) {
|
||||
case SyntaxKind.KeyOfKeyword:
|
||||
return parseTypeOperator(SyntaxKind.KeyOfKeyword);
|
||||
}
|
||||
return parseArrayTypeOrHigher();
|
||||
}
|
||||
|
||||
function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode {
|
||||
parseOptional(operator);
|
||||
let type = parseConstituentType();
|
||||
if (token() === operator) {
|
||||
const types = createNodeArray<TypeNode>([type], type.pos);
|
||||
@@ -2542,7 +2636,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseIntersectionTypeOrHigher(): TypeNode {
|
||||
return parseUnionOrIntersectionType(SyntaxKind.IntersectionType, parseArrayTypeOrHigher, SyntaxKind.AmpersandToken);
|
||||
return parseUnionOrIntersectionType(SyntaxKind.IntersectionType, parseTypeOperatorOrHigher, SyntaxKind.AmpersandToken);
|
||||
}
|
||||
|
||||
function parseUnionTypeOrHigher(): TypeNode {
|
||||
@@ -3821,6 +3915,7 @@ namespace ts {
|
||||
|
||||
parseExpected(SyntaxKind.OpenBraceToken);
|
||||
if (token() !== SyntaxKind.CloseBraceToken) {
|
||||
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
|
||||
node.expression = parseAssignmentExpressionOrHigher();
|
||||
}
|
||||
if (inExpressionContext) {
|
||||
@@ -4092,7 +4187,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseSpreadElement(): Expression {
|
||||
const node = <SpreadElementExpression>createNode(SyntaxKind.SpreadElementExpression);
|
||||
const node = <SpreadElement>createNode(SyntaxKind.SpreadElement);
|
||||
parseExpected(SyntaxKind.DotDotDotToken);
|
||||
node.expression = parseAssignmentExpressionOrHigher();
|
||||
return finishNode(node);
|
||||
@@ -4132,6 +4227,12 @@ namespace ts {
|
||||
|
||||
function parseObjectLiteralElement(): ObjectLiteralElementLike {
|
||||
const fullStart = scanner.getStartPos();
|
||||
const dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
|
||||
if (dotDotDotToken) {
|
||||
const spreadElement = <SpreadAssignment>createNode(SyntaxKind.SpreadAssignment, fullStart);
|
||||
spreadElement.expression = parseAssignmentExpressionOrHigher();
|
||||
return addJSDocComment(finishNode(spreadElement));
|
||||
}
|
||||
const decorators = parseDecorators();
|
||||
const modifiers = parseModifiers();
|
||||
|
||||
@@ -4835,6 +4936,7 @@ namespace ts {
|
||||
|
||||
function parseObjectBindingElement(): BindingElement {
|
||||
const node = <BindingElement>createNode(SyntaxKind.BindingElement);
|
||||
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
|
||||
const tokenIsIdentifier = isIdentifier();
|
||||
const propertyName = parsePropertyName();
|
||||
if (tokenIsIdentifier && token() !== SyntaxKind.ColonToken) {
|
||||
@@ -5259,7 +5361,7 @@ namespace ts {
|
||||
parseExpected(SyntaxKind.ClassKeyword);
|
||||
node.name = parseNameOfClassDeclarationOrExpression();
|
||||
node.typeParameters = parseTypeParameters();
|
||||
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true);
|
||||
node.heritageClauses = parseHeritageClauses();
|
||||
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
// ClassTail[Yield,Await] : (Modified) See 14.5
|
||||
@@ -5289,7 +5391,7 @@ namespace ts {
|
||||
return token() === SyntaxKind.ImplementsKeyword && lookAhead(nextTokenIsIdentifierOrKeyword);
|
||||
}
|
||||
|
||||
function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray<HeritageClause> {
|
||||
function parseHeritageClauses(): NodeArray<HeritageClause> {
|
||||
// ClassTail[Yield,Await] : (Modified) See 14.5
|
||||
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
|
||||
|
||||
@@ -5337,7 +5439,7 @@ namespace ts {
|
||||
parseExpected(SyntaxKind.InterfaceKeyword);
|
||||
node.name = parseIdentifier();
|
||||
node.typeParameters = parseTypeParameters();
|
||||
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false);
|
||||
node.heritageClauses = parseHeritageClauses();
|
||||
node.members = parseObjectTypeMembers();
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
@@ -5419,7 +5521,7 @@ namespace ts {
|
||||
node.flags |= NodeFlags.GlobalAugmentation;
|
||||
}
|
||||
else {
|
||||
node.name = parseLiteralNode(/*internName*/ true);
|
||||
node.name = <StringLiteral>parseLiteralNode(/*internName*/ true);
|
||||
}
|
||||
|
||||
if (token() === SyntaxKind.OpenBraceToken) {
|
||||
@@ -5472,7 +5574,7 @@ namespace ts {
|
||||
|
||||
exportDeclaration.name = parseIdentifier();
|
||||
|
||||
parseExpected(SyntaxKind.SemicolonToken);
|
||||
parseSemicolon();
|
||||
|
||||
return finishNode(exportDeclaration);
|
||||
}
|
||||
@@ -5779,6 +5881,7 @@ namespace ts {
|
||||
JsxChildren, // Things between opening and closing JSX tags
|
||||
ArrayLiteralMembers, // Members in array literal
|
||||
Parameters, // Parameters in parameter list
|
||||
RestProperties, // Property names in a rest type list
|
||||
TypeParameters, // Type parameters in type parameter list
|
||||
TypeArguments, // Type arguments in type argument list
|
||||
TupleElementTypes, // Element types in tuple element type list
|
||||
@@ -5817,7 +5920,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) {
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
sourceFile = createSourceFile("file.js", ScriptTarget.Latest, ScriptKind.JS);
|
||||
scanner.setText(content, start, length);
|
||||
currentToken = scanner.scan();
|
||||
@@ -6134,7 +6237,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parseIsolatedJSDocComment(content: string, start: number, length: number) {
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
sourceFile = <SourceFile>{ languageVariant: LanguageVariant.Standard, text: content };
|
||||
const jsDoc = parseJSDocCommentWorker(start, length);
|
||||
const diagnostics = parseDiagnostics;
|
||||
@@ -6208,6 +6311,7 @@ namespace ts {
|
||||
}
|
||||
if (token() === SyntaxKind.NewLineTrivia) {
|
||||
state = JSDocState.BeginningOfLine;
|
||||
indent = 0;
|
||||
nextJSDocToken();
|
||||
}
|
||||
while (token() !== SyntaxKind.EndOfFileToken) {
|
||||
@@ -6235,7 +6339,7 @@ namespace ts {
|
||||
break;
|
||||
case SyntaxKind.AsteriskToken:
|
||||
const asterisk = scanner.getTokenText();
|
||||
if (state === JSDocState.SawAsterisk) {
|
||||
if (state === JSDocState.SawAsterisk || state === JSDocState.SavingComments) {
|
||||
// If we've already seen an asterisk, then we can no longer parse a tag on this line
|
||||
state = JSDocState.SavingComments;
|
||||
pushComment(asterisk);
|
||||
@@ -6256,7 +6360,10 @@ namespace ts {
|
||||
case SyntaxKind.WhitespaceTrivia:
|
||||
// only collect whitespace if we're already saving comments or have just crossed the comment indent margin
|
||||
const whitespace = scanner.getTokenText();
|
||||
if (state === JSDocState.SavingComments || margin !== undefined && indent + whitespace.length > margin) {
|
||||
if (state === JSDocState.SavingComments) {
|
||||
comments.push(whitespace);
|
||||
}
|
||||
else if (margin !== undefined && indent + whitespace.length > margin) {
|
||||
comments.push(whitespace.slice(margin - indent - 1));
|
||||
}
|
||||
indent += whitespace.length;
|
||||
@@ -6264,6 +6371,8 @@ namespace ts {
|
||||
case SyntaxKind.EndOfFileToken:
|
||||
break;
|
||||
default:
|
||||
// anything other than whitespace or asterisk at the beginning of the line starts the comment text
|
||||
state = JSDocState.SavingComments;
|
||||
pushComment(scanner.getTokenText());
|
||||
break;
|
||||
}
|
||||
@@ -6329,6 +6438,9 @@ namespace ts {
|
||||
let tag: JSDocTag;
|
||||
if (tagName) {
|
||||
switch (tagName.text) {
|
||||
case "augments":
|
||||
tag = parseAugmentsTag(atToken, tagName);
|
||||
break;
|
||||
case "param":
|
||||
tag = parseParamTag(atToken, tagName);
|
||||
break;
|
||||
@@ -6545,6 +6657,16 @@ namespace ts {
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseAugmentsTag(atToken: AtToken, tagName: Identifier): JSDocAugmentsTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
|
||||
const result = <JSDocAugmentsTag>createNode(SyntaxKind.JSDocAugmentsTag, atToken.pos);
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
result.typeExpression = typeExpression;
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseTypedefTag(atToken: AtToken, tagName: Identifier): JSDocTypedefTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
@@ -6552,7 +6674,14 @@ namespace ts {
|
||||
const typedefTag = <JSDocTypedefTag>createNode(SyntaxKind.JSDocTypedefTag, atToken.pos);
|
||||
typedefTag.atToken = atToken;
|
||||
typedefTag.tagName = tagName;
|
||||
typedefTag.name = parseJSDocIdentifierName();
|
||||
typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0);
|
||||
if (typedefTag.fullName) {
|
||||
let rightNode = typedefTag.fullName;
|
||||
while (rightNode.kind !== SyntaxKind.Identifier) {
|
||||
rightNode = rightNode.body;
|
||||
}
|
||||
typedefTag.name = rightNode;
|
||||
}
|
||||
typedefTag.typeExpression = typeExpression;
|
||||
skipWhitespace();
|
||||
|
||||
@@ -6615,8 +6744,27 @@ namespace ts {
|
||||
scanner.setTextPos(resumePos);
|
||||
return finishNode(jsDocTypeLiteral);
|
||||
}
|
||||
|
||||
function parseJSDocTypeNameWithNamespace(flags: NodeFlags) {
|
||||
const pos = scanner.getTokenPos();
|
||||
const typeNameOrNamespaceName = parseJSDocIdentifierName();
|
||||
|
||||
if (typeNameOrNamespaceName && parseOptional(SyntaxKind.DotToken)) {
|
||||
const jsDocNamespaceNode = <JSDocNamespaceDeclaration>createNode(SyntaxKind.ModuleDeclaration, pos);
|
||||
jsDocNamespaceNode.flags |= flags;
|
||||
jsDocNamespaceNode.name = typeNameOrNamespaceName;
|
||||
jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(NodeFlags.NestedNamespace);
|
||||
return jsDocNamespaceNode;
|
||||
}
|
||||
|
||||
if (typeNameOrNamespaceName && flags & NodeFlags.NestedNamespace) {
|
||||
typeNameOrNamespaceName.isInJSDocNamespace = true;
|
||||
}
|
||||
return typeNameOrNamespaceName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function tryParseChildTag(parentTag: JSDocTypeLiteral): boolean {
|
||||
Debug.assert(token() === SyntaxKind.AtToken);
|
||||
const atToken = <AtToken>createNode(SyntaxKind.AtToken, scanner.getStartPos());
|
||||
@@ -6639,12 +6787,16 @@ namespace ts {
|
||||
return true;
|
||||
case "prop":
|
||||
case "property":
|
||||
if (!parentTag.jsDocPropertyTags) {
|
||||
parentTag.jsDocPropertyTags = <NodeArray<JSDocPropertyTag>>[];
|
||||
}
|
||||
const propertyTag = parsePropertyTag(atToken, tagName);
|
||||
parentTag.jsDocPropertyTags.push(propertyTag);
|
||||
return true;
|
||||
if (propertyTag) {
|
||||
if (!parentTag.jsDocPropertyTags) {
|
||||
parentTag.jsDocPropertyTags = <NodeArray<JSDocPropertyTag>>[];
|
||||
}
|
||||
parentTag.jsDocPropertyTags.push(propertyTag);
|
||||
return true;
|
||||
}
|
||||
// Error parsing property tag
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -6827,8 +6979,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
forEachChild(node, visitNode, visitArray);
|
||||
if (node.jsDocComments) {
|
||||
for (const jsDocComment of node.jsDocComments) {
|
||||
if (node.jsDoc) {
|
||||
for (const jsDocComment of node.jsDoc) {
|
||||
forEachChild(jsDocComment, visitNode, visitArray);
|
||||
}
|
||||
}
|
||||
@@ -7254,7 +7406,7 @@ namespace ts {
|
||||
if (position >= array.pos && position < array.end) {
|
||||
// position was in this array. Search through this array to see if we find a
|
||||
// viable element.
|
||||
for (let i = 0, n = array.length; i < n; i++) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const child = array[i];
|
||||
if (child) {
|
||||
if (child.pos === position) {
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ts.performance {
|
||||
|
||||
const profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true
|
||||
? onProfilerEvent
|
||||
: (markName: string) => { };
|
||||
: (_markName: string) => { };
|
||||
|
||||
let enabled = false;
|
||||
let profilerStart = 0;
|
||||
|
||||
+473
-273
File diff suppressed because it is too large
Load Diff
+10
-6
@@ -90,6 +90,7 @@ namespace ts {
|
||||
"instanceof": SyntaxKind.InstanceOfKeyword,
|
||||
"interface": SyntaxKind.InterfaceKeyword,
|
||||
"is": SyntaxKind.IsKeyword,
|
||||
"keyof": SyntaxKind.KeyOfKeyword,
|
||||
"let": SyntaxKind.LetKeyword,
|
||||
"module": SyntaxKind.ModuleKeyword,
|
||||
"namespace": SyntaxKind.NamespaceKeyword,
|
||||
@@ -530,7 +531,7 @@ namespace ts {
|
||||
const ch = text.charCodeAt(pos);
|
||||
|
||||
if ((pos + mergeConflictMarkerLength) < text.length) {
|
||||
for (let i = 0, n = mergeConflictMarkerLength; i < n; i++) {
|
||||
for (let i = 0; i < mergeConflictMarkerLength; i++) {
|
||||
if (text.charCodeAt(pos + i) !== ch) {
|
||||
return false;
|
||||
}
|
||||
@@ -642,7 +643,7 @@ namespace ts {
|
||||
pos++;
|
||||
continue;
|
||||
case CharacterCodes.slash:
|
||||
let nextChar = text.charCodeAt(pos + 1);
|
||||
const nextChar = text.charCodeAt(pos + 1);
|
||||
let hasTrailingNewLine = false;
|
||||
if (nextChar === CharacterCodes.slash || nextChar === CharacterCodes.asterisk) {
|
||||
const kind = nextChar === CharacterCodes.slash ? SyntaxKind.SingleLineCommentTrivia : SyntaxKind.MultiLineCommentTrivia;
|
||||
@@ -723,7 +724,7 @@ namespace ts {
|
||||
return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial);
|
||||
}
|
||||
|
||||
function appendCommentRange(pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: any, comments: CommentRange[]) {
|
||||
function appendCommentRange(pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, _state: any, comments: CommentRange[]) {
|
||||
if (!comments) {
|
||||
comments = [];
|
||||
}
|
||||
@@ -765,7 +766,7 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let i = 1, n = name.length; i < n; i++) {
|
||||
for (let i = 1; i < name.length; i++) {
|
||||
if (!isIdentifierPart(name.charCodeAt(i), languageVersion)) {
|
||||
return false;
|
||||
}
|
||||
@@ -1190,7 +1191,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function scanBinaryOrOctalDigits(base: number): number {
|
||||
Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8");
|
||||
Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8");
|
||||
|
||||
let value = 0;
|
||||
// For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b.
|
||||
@@ -1562,7 +1563,7 @@ namespace ts {
|
||||
pos++;
|
||||
return token = SyntaxKind.AtToken;
|
||||
case CharacterCodes.backslash:
|
||||
let cookedChar = peekUnicodeEscape();
|
||||
const cookedChar = peekUnicodeEscape();
|
||||
if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
|
||||
pos += 6;
|
||||
tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
|
||||
@@ -1799,6 +1800,9 @@ namespace ts {
|
||||
case CharacterCodes.comma:
|
||||
pos++;
|
||||
return token = SyntaxKind.CommaToken;
|
||||
case CharacterCodes.dot:
|
||||
pos++;
|
||||
return token = SyntaxKind.DotToken;
|
||||
}
|
||||
|
||||
if (isIdentifierStart(ch, ScriptTarget.Latest)) {
|
||||
|
||||
@@ -427,7 +427,7 @@ namespace ts {
|
||||
|
||||
encodeLastRecordedSourceMapSpan();
|
||||
|
||||
return stringify({
|
||||
return JSON.stringify({
|
||||
version: 3,
|
||||
file: sourceMapData.sourceMapFile,
|
||||
sourceRoot: sourceMapData.sourceMapSourceRoot,
|
||||
|
||||
+22
-13
@@ -17,7 +17,11 @@ namespace ts {
|
||||
readFile(path: string, encoding?: string): string;
|
||||
getFileSize?(path: string): number;
|
||||
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
|
||||
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
|
||||
/**
|
||||
* @pollingInterval - this parameter is used in polling-based watchers and ignored in watchers that
|
||||
* use native OS file watching
|
||||
*/
|
||||
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher;
|
||||
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
|
||||
resolvePath(path: string): string;
|
||||
fileExists(path: string): boolean;
|
||||
@@ -34,6 +38,8 @@ namespace ts {
|
||||
realpath?(path: string): string;
|
||||
/*@internal*/ getEnvironmentVariable(name: string): string;
|
||||
/*@internal*/ tryEnableSourceMapsForHost?(): void;
|
||||
setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
|
||||
clearTimeout?(timeoutId: any): void;
|
||||
}
|
||||
|
||||
export interface FileWatcher {
|
||||
@@ -46,13 +52,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
declare var require: any;
|
||||
declare var module: any;
|
||||
declare var process: any;
|
||||
declare var global: any;
|
||||
declare var __filename: string;
|
||||
declare var Buffer: {
|
||||
new (str: string, encoding?: string): any;
|
||||
};
|
||||
|
||||
declare class Enumerator {
|
||||
public atEnd(): boolean;
|
||||
@@ -158,7 +160,7 @@ namespace ts {
|
||||
|
||||
function getNames(collection: any): string[] {
|
||||
const result: string[] = [];
|
||||
for (let e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
for (const e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
result.push(e.item().Name);
|
||||
}
|
||||
return result.sort();
|
||||
@@ -324,7 +326,7 @@ namespace ts {
|
||||
const platform: string = _os.platform();
|
||||
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
|
||||
|
||||
function readFile(fileName: string, encoding?: string): string {
|
||||
function readFile(fileName: string, _encoding?: string): string {
|
||||
if (!fileExists(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -441,6 +443,7 @@ namespace ts {
|
||||
return filter<string>(_fs.readdirSync(path), dir => fileSystemEntryExists(combinePaths(path, dir), FileSystemEntryKind.Directory));
|
||||
}
|
||||
|
||||
const noOpFileWatcher: FileWatcher = { close: noop };
|
||||
const nodeSystem: System = {
|
||||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
@@ -450,7 +453,7 @@ namespace ts {
|
||||
},
|
||||
readFile,
|
||||
writeFile,
|
||||
watchFile: (fileName, callback) => {
|
||||
watchFile: (fileName, callback, pollingInterval) => {
|
||||
if (useNonPollingWatchers) {
|
||||
const watchedFile = watchedFileSet.addFile(fileName, callback);
|
||||
return {
|
||||
@@ -458,7 +461,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
else {
|
||||
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
|
||||
_fs.watchFile(fileName, { persistent: true, interval: pollingInterval || 250 }, fileChanged);
|
||||
return {
|
||||
close: () => _fs.unwatchFile(fileName, fileChanged)
|
||||
};
|
||||
@@ -476,6 +479,10 @@ namespace ts {
|
||||
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
||||
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
||||
let options: any;
|
||||
if (!directoryExists(directoryName)) {
|
||||
return noOpFileWatcher;
|
||||
}
|
||||
|
||||
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
|
||||
options = { persistent: true, recursive: !!recursive };
|
||||
}
|
||||
@@ -560,7 +567,9 @@ namespace ts {
|
||||
catch (e) {
|
||||
// Could not enable source maps.
|
||||
}
|
||||
}
|
||||
},
|
||||
setTimeout,
|
||||
clearTimeout
|
||||
};
|
||||
return nodeSystem;
|
||||
}
|
||||
@@ -572,7 +581,7 @@ namespace ts {
|
||||
args: ChakraHost.args,
|
||||
useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames,
|
||||
write: ChakraHost.echo,
|
||||
readFile(path: string, encoding?: string) {
|
||||
readFile(path: string, _encoding?: string) {
|
||||
// encoding is automatically handled by the implementation in ChakraHost
|
||||
return ChakraHost.readFile(path);
|
||||
},
|
||||
@@ -591,9 +600,9 @@ namespace ts {
|
||||
getExecutingFilePath: () => ChakraHost.executingFile,
|
||||
getCurrentDirectory: () => ChakraHost.currentDirectory,
|
||||
getDirectories: ChakraHost.getDirectories,
|
||||
getEnvironmentVariable: ChakraHost.getEnvironmentVariable || ((name: string) => ""),
|
||||
getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (() => ""),
|
||||
readDirectory: (path: string, extensions?: string[], excludes?: string[], includes?: string[]) => {
|
||||
const pattern = getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory);
|
||||
const pattern = getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory);
|
||||
return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern);
|
||||
},
|
||||
exit: ChakraHost.quit,
|
||||
|
||||
+95
-112
@@ -1,17 +1,20 @@
|
||||
/// <reference path="visitor.ts" />
|
||||
/// <reference path="transformers/ts.ts" />
|
||||
/// <reference path="transformers/jsx.ts" />
|
||||
/// <reference path="transformers/es7.ts" />
|
||||
/// <reference path="transformers/es6.ts" />
|
||||
/// <reference path="transformers/esnext.ts" />
|
||||
/// <reference path="transformers/es2017.ts" />
|
||||
/// <reference path="transformers/es2016.ts" />
|
||||
/// <reference path="transformers/es2015.ts" />
|
||||
/// <reference path="transformers/generators.ts" />
|
||||
/// <reference path="transformers/es5.ts" />
|
||||
/// <reference path="transformers/module/module.ts" />
|
||||
/// <reference path="transformers/module/system.ts" />
|
||||
/// <reference path="transformers/module/es6.ts" />
|
||||
/// <reference path="transformers/module/es2015.ts" />
|
||||
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
const moduleTransformerMap = createMap<Transformer>({
|
||||
[ModuleKind.ES6]: transformES6Module,
|
||||
[ModuleKind.ES2015]: transformES2015Module,
|
||||
[ModuleKind.System]: transformSystemModule,
|
||||
[ModuleKind.AMD]: transformModule,
|
||||
[ModuleKind.CommonJS]: transformModule,
|
||||
@@ -24,84 +27,6 @@ namespace ts {
|
||||
EmitNotifications = 1 << 1,
|
||||
}
|
||||
|
||||
export interface TransformationResult {
|
||||
/**
|
||||
* Gets the transformed source files.
|
||||
*/
|
||||
transformed: SourceFile[];
|
||||
|
||||
/**
|
||||
* Emits the substitute for a node, if one is available; otherwise, emits the node.
|
||||
*
|
||||
* @param emitContext The current emit context.
|
||||
* @param node The node to substitute.
|
||||
* @param emitCallback A callback used to emit the node or its substitute.
|
||||
*/
|
||||
emitNodeWithSubstitution(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void;
|
||||
|
||||
/**
|
||||
* Emits a node with possible notification.
|
||||
*
|
||||
* @param emitContext The current emit context.
|
||||
* @param node The node to emit.
|
||||
* @param emitCallback A callback used to emit the node.
|
||||
*/
|
||||
emitNodeWithNotification(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void;
|
||||
}
|
||||
|
||||
export interface TransformationContext extends LexicalEnvironment {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getEmitResolver(): EmitResolver;
|
||||
getEmitHost(): EmitHost;
|
||||
|
||||
/**
|
||||
* Hoists a function declaration to the containing scope.
|
||||
*/
|
||||
hoistFunctionDeclaration(node: FunctionDeclaration): void;
|
||||
|
||||
/**
|
||||
* Hoists a variable declaration to the containing scope.
|
||||
*/
|
||||
hoistVariableDeclaration(node: Identifier): void;
|
||||
|
||||
/**
|
||||
* Enables expression substitutions in the pretty printer for the provided SyntaxKind.
|
||||
*/
|
||||
enableSubstitution(kind: SyntaxKind): void;
|
||||
|
||||
/**
|
||||
* Determines whether expression substitutions are enabled for the provided node.
|
||||
*/
|
||||
isSubstitutionEnabled(node: Node): boolean;
|
||||
|
||||
/**
|
||||
* Hook used by transformers to substitute expressions just before they
|
||||
* are emitted by the pretty printer.
|
||||
*/
|
||||
onSubstituteNode?: (emitContext: EmitContext, node: Node) => Node;
|
||||
|
||||
/**
|
||||
* Enables before/after emit notifications in the pretty printer for the provided
|
||||
* SyntaxKind.
|
||||
*/
|
||||
enableEmitNotification(kind: SyntaxKind): void;
|
||||
|
||||
/**
|
||||
* Determines whether before/after emit notifications should be raised in the pretty
|
||||
* printer when it emits a node.
|
||||
*/
|
||||
isEmitNotificationEnabled(node: Node): boolean;
|
||||
|
||||
/**
|
||||
* Hook used to allow transformers to capture state before or after
|
||||
* the printer emits a node.
|
||||
*/
|
||||
onEmitNode?: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile;
|
||||
|
||||
export function getTransformers(compilerOptions: CompilerOptions) {
|
||||
const jsx = compilerOptions.jsx;
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
@@ -109,19 +34,36 @@ namespace ts {
|
||||
const transformers: Transformer[] = [];
|
||||
|
||||
transformers.push(transformTypeScript);
|
||||
transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ModuleKind.None]);
|
||||
|
||||
if (jsx === JsxEmit.React) {
|
||||
transformers.push(transformJsx);
|
||||
}
|
||||
|
||||
transformers.push(transformES7);
|
||||
if (languageVersion < ScriptTarget.ESNext) {
|
||||
transformers.push(transformESNext);
|
||||
}
|
||||
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
transformers.push(transformES6);
|
||||
if (languageVersion < ScriptTarget.ES2017) {
|
||||
transformers.push(transformES2017);
|
||||
}
|
||||
|
||||
if (languageVersion < ScriptTarget.ES2016) {
|
||||
transformers.push(transformES2016);
|
||||
}
|
||||
|
||||
if (languageVersion < ScriptTarget.ES2015) {
|
||||
transformers.push(transformES2015);
|
||||
transformers.push(transformGenerators);
|
||||
}
|
||||
|
||||
transformers.push(moduleTransformerMap[moduleKind] || moduleTransformerMap[ModuleKind.None]);
|
||||
|
||||
// The ES5 transformer is last so that it can substitute expressions like `exports.default`
|
||||
// for ES3.
|
||||
if (languageVersion < ScriptTarget.ES5) {
|
||||
transformers.push(transformES5);
|
||||
}
|
||||
|
||||
return transformers;
|
||||
}
|
||||
|
||||
@@ -134,14 +76,18 @@ namespace ts {
|
||||
* @param transforms An array of Transformers.
|
||||
*/
|
||||
export function transformFiles(resolver: EmitResolver, host: EmitHost, sourceFiles: SourceFile[], transformers: Transformer[]): TransformationResult {
|
||||
const lexicalEnvironmentVariableDeclarationsStack: VariableDeclaration[][] = [];
|
||||
const lexicalEnvironmentFunctionDeclarationsStack: FunctionDeclaration[][] = [];
|
||||
const enabledSyntaxKindFeatures = new Array<SyntaxKindFeatureFlags>(SyntaxKind.Count);
|
||||
|
||||
let lexicalEnvironmentDisabled = false;
|
||||
|
||||
let lexicalEnvironmentVariableDeclarations: VariableDeclaration[];
|
||||
let lexicalEnvironmentFunctionDeclarations: FunctionDeclaration[];
|
||||
let lexicalEnvironmentVariableDeclarationsStack: VariableDeclaration[][] = [];
|
||||
let lexicalEnvironmentFunctionDeclarationsStack: FunctionDeclaration[][] = [];
|
||||
let lexicalEnvironmentStackOffset = 0;
|
||||
let hoistedVariableDeclarations: VariableDeclaration[];
|
||||
let hoistedFunctionDeclarations: FunctionDeclaration[];
|
||||
let lexicalEnvironmentDisabled: boolean;
|
||||
let lexicalEnvironmentSuspended = false;
|
||||
|
||||
let emitHelpers: EmitHelper[];
|
||||
|
||||
// The transformation context is provided to each transformer as part of transformer
|
||||
// initialization.
|
||||
@@ -149,11 +95,15 @@ namespace ts {
|
||||
getCompilerOptions: () => host.getCompilerOptions(),
|
||||
getEmitResolver: () => resolver,
|
||||
getEmitHost: () => host,
|
||||
startLexicalEnvironment,
|
||||
suspendLexicalEnvironment,
|
||||
resumeLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
hoistVariableDeclaration,
|
||||
hoistFunctionDeclaration,
|
||||
startLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
onSubstituteNode: (emitContext, node) => node,
|
||||
requestEmitHelper,
|
||||
readEmitHelpers,
|
||||
onSubstituteNode: (_emitContext, node) => node,
|
||||
enableSubstitution,
|
||||
isSubstitutionEnabled,
|
||||
onEmitNode: (node, emitContext, emitCallback) => emitCallback(node, emitContext),
|
||||
@@ -265,11 +215,11 @@ namespace ts {
|
||||
function hoistVariableDeclaration(name: Identifier): void {
|
||||
Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase.");
|
||||
const decl = createVariableDeclaration(name);
|
||||
if (!hoistedVariableDeclarations) {
|
||||
hoistedVariableDeclarations = [decl];
|
||||
if (!lexicalEnvironmentVariableDeclarations) {
|
||||
lexicalEnvironmentVariableDeclarations = [decl];
|
||||
}
|
||||
else {
|
||||
hoistedVariableDeclarations.push(decl);
|
||||
lexicalEnvironmentVariableDeclarations.push(decl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,11 +228,11 @@ namespace ts {
|
||||
*/
|
||||
function hoistFunctionDeclaration(func: FunctionDeclaration): void {
|
||||
Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase.");
|
||||
if (!hoistedFunctionDeclarations) {
|
||||
hoistedFunctionDeclarations = [func];
|
||||
if (!lexicalEnvironmentFunctionDeclarations) {
|
||||
lexicalEnvironmentFunctionDeclarations = [func];
|
||||
}
|
||||
else {
|
||||
hoistedFunctionDeclarations.push(func);
|
||||
lexicalEnvironmentFunctionDeclarations.push(func);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,16 +242,31 @@ namespace ts {
|
||||
*/
|
||||
function startLexicalEnvironment(): void {
|
||||
Debug.assert(!lexicalEnvironmentDisabled, "Cannot start a lexical environment during the print phase.");
|
||||
Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
|
||||
|
||||
// Save the current lexical environment. Rather than resizing the array we adjust the
|
||||
// stack size variable. This allows us to reuse existing array slots we've
|
||||
// already allocated between transformations to avoid allocation and GC overhead during
|
||||
// transformation.
|
||||
lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = hoistedVariableDeclarations;
|
||||
lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = hoistedFunctionDeclarations;
|
||||
lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
|
||||
lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
|
||||
lexicalEnvironmentStackOffset++;
|
||||
hoistedVariableDeclarations = undefined;
|
||||
hoistedFunctionDeclarations = undefined;
|
||||
lexicalEnvironmentVariableDeclarations = undefined;
|
||||
lexicalEnvironmentFunctionDeclarations = undefined;
|
||||
}
|
||||
|
||||
/** Suspends the current lexical environment, usually after visiting a parameter list. */
|
||||
function suspendLexicalEnvironment(): void {
|
||||
Debug.assert(!lexicalEnvironmentDisabled, "Cannot suspend a lexical environment during the print phase.");
|
||||
Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended.");
|
||||
lexicalEnvironmentSuspended = true;
|
||||
}
|
||||
|
||||
/** Resumes a suspended lexical environment, usually before visiting a function body. */
|
||||
function resumeLexicalEnvironment(): void {
|
||||
Debug.assert(!lexicalEnvironmentDisabled, "Cannot resume a lexical environment during the print phase.");
|
||||
Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended.");
|
||||
lexicalEnvironmentSuspended = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,17 +275,18 @@ namespace ts {
|
||||
*/
|
||||
function endLexicalEnvironment(): Statement[] {
|
||||
Debug.assert(!lexicalEnvironmentDisabled, "Cannot end a lexical environment during the print phase.");
|
||||
Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
|
||||
|
||||
let statements: Statement[];
|
||||
if (hoistedVariableDeclarations || hoistedFunctionDeclarations) {
|
||||
if (hoistedFunctionDeclarations) {
|
||||
statements = [...hoistedFunctionDeclarations];
|
||||
if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) {
|
||||
if (lexicalEnvironmentFunctionDeclarations) {
|
||||
statements = [...lexicalEnvironmentFunctionDeclarations];
|
||||
}
|
||||
|
||||
if (hoistedVariableDeclarations) {
|
||||
if (lexicalEnvironmentVariableDeclarations) {
|
||||
const statement = createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList(hoistedVariableDeclarations)
|
||||
createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)
|
||||
);
|
||||
|
||||
if (!statements) {
|
||||
@@ -334,9 +300,26 @@ namespace ts {
|
||||
|
||||
// Restore the previous lexical environment.
|
||||
lexicalEnvironmentStackOffset--;
|
||||
hoistedVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
|
||||
hoistedFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
|
||||
lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
|
||||
lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
|
||||
if (lexicalEnvironmentStackOffset === 0) {
|
||||
lexicalEnvironmentVariableDeclarationsStack = [];
|
||||
lexicalEnvironmentFunctionDeclarationsStack = [];
|
||||
}
|
||||
return statements;
|
||||
}
|
||||
|
||||
function requestEmitHelper(helper: EmitHelper): void {
|
||||
Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase.");
|
||||
Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
|
||||
emitHelpers = append(emitHelpers, helper);
|
||||
}
|
||||
|
||||
function readEmitHelpers(): EmitHelper[] | undefined {
|
||||
Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase.");
|
||||
const helpers = emitHelpers;
|
||||
emitHelpers = undefined;
|
||||
return helpers;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,412 +3,397 @@
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
interface FlattenContext {
|
||||
context: TransformationContext;
|
||||
level: FlattenLevel;
|
||||
hoistTempVariables: boolean;
|
||||
emitExpression: (value: Expression) => void;
|
||||
emitBindingOrAssignment: (target: BindingOrAssignmentElementTarget, value: Expression, location: TextRange, original: Node) => void;
|
||||
createArrayBindingOrAssignmentPattern: (elements: BindingOrAssignmentElement[]) => ArrayBindingOrAssignmentPattern;
|
||||
createObjectBindingOrAssignmentPattern: (elements: BindingOrAssignmentElement[]) => ObjectBindingOrAssignmentPattern;
|
||||
createArrayBindingOrAssignmentElement: (node: Identifier) => BindingOrAssignmentElement;
|
||||
visitor?: (node: Node) => VisitResult<Node>;
|
||||
}
|
||||
|
||||
export const enum FlattenLevel {
|
||||
All,
|
||||
ObjectRest,
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens a destructuring assignment expression.
|
||||
* Flattens a DestructuringAssignment or a VariableDeclaration to an expression.
|
||||
*
|
||||
* @param root The destructuring assignment expression.
|
||||
* @param needsValue Indicates whether the value from the right-hand-side of the
|
||||
* destructuring assignment is needed as part of a larger expression.
|
||||
* @param recordTempVariable A callback used to record new temporary variables.
|
||||
* @param visitor An optional visitor to use to visit expressions.
|
||||
* @param node The node to flatten.
|
||||
* @param visitor An optional visitor used to visit initializers.
|
||||
* @param context The transformation context.
|
||||
* @param level Indicates the extent to which flattening should occur.
|
||||
* @param needsValue An optional value indicating whether the value from the right-hand-side of
|
||||
* the destructuring assignment is needed as part of a larger expression.
|
||||
* @param createAssignmentCallback An optional callback used to create the assignment expression.
|
||||
*/
|
||||
export function flattenDestructuringAssignment(
|
||||
node: VariableDeclaration | DestructuringAssignment,
|
||||
visitor: ((node: Node) => VisitResult<Node>) | undefined,
|
||||
context: TransformationContext,
|
||||
node: BinaryExpression,
|
||||
needsValue: boolean,
|
||||
recordTempVariable: (node: Identifier) => void,
|
||||
visitor?: (node: Node) => VisitResult<Node>): Expression {
|
||||
|
||||
if (isEmptyObjectLiteralOrArrayLiteral(node.left)) {
|
||||
const right = node.right;
|
||||
if (isDestructuringAssignment(right)) {
|
||||
return flattenDestructuringAssignment(context, right, needsValue, recordTempVariable, visitor);
|
||||
}
|
||||
else {
|
||||
return node.right;
|
||||
}
|
||||
}
|
||||
|
||||
level: FlattenLevel,
|
||||
needsValue?: boolean,
|
||||
createAssignmentCallback?: (name: Identifier, value: Expression, location?: TextRange) => Expression): Expression {
|
||||
let location: TextRange = node;
|
||||
let value = node.right;
|
||||
const expressions: Expression[] = [];
|
||||
if (needsValue) {
|
||||
// If the right-hand value of the destructuring assignment needs to be preserved (as
|
||||
// is the case when the destructuring assignmen) is part of a larger expression),
|
||||
// then we need to cache the right-hand value.
|
||||
//
|
||||
// The source map location for the assignment should point to the entire binary
|
||||
// expression.
|
||||
value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment, visitor);
|
||||
}
|
||||
else if (nodeIsSynthesized(node)) {
|
||||
// Generally, the source map location for a destructuring assignment is the root
|
||||
// expression.
|
||||
//
|
||||
// However, if the root expression is synthesized (as in the case
|
||||
// of the initializer when transforming a ForOfStatement), then the source map
|
||||
// location should point to the right-hand value of the expression.
|
||||
location = value;
|
||||
let value: Expression;
|
||||
if (isDestructuringAssignment(node)) {
|
||||
value = node.right;
|
||||
while (isEmptyObjectLiteralOrArrayLiteral(node.left)) {
|
||||
if (isDestructuringAssignment(value)) {
|
||||
location = node = value;
|
||||
value = node.right;
|
||||
}
|
||||
else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
let expressions: Expression[];
|
||||
const flattenContext: FlattenContext = {
|
||||
context,
|
||||
level,
|
||||
hoistTempVariables: true,
|
||||
emitExpression,
|
||||
emitBindingOrAssignment,
|
||||
createArrayBindingOrAssignmentPattern: makeArrayAssignmentPattern,
|
||||
createObjectBindingOrAssignmentPattern: makeObjectAssignmentPattern,
|
||||
createArrayBindingOrAssignmentElement: makeAssignmentElement,
|
||||
visitor
|
||||
};
|
||||
|
||||
if (value) {
|
||||
value = visitNode(value, visitor, isExpression);
|
||||
if (needsValue) {
|
||||
// If the right-hand value of the destructuring assignment needs to be preserved (as
|
||||
// is the case when the destructuring assignment is part of a larger expression),
|
||||
// then we need to cache the right-hand value.
|
||||
//
|
||||
// The source map location for the assignment should point to the entire binary
|
||||
// expression.
|
||||
value = ensureIdentifier(flattenContext, value, /*reuseIdentifierExpressions*/ true, location);
|
||||
}
|
||||
else if (nodeIsSynthesized(node)) {
|
||||
// Generally, the source map location for a destructuring assignment is the root
|
||||
// expression.
|
||||
//
|
||||
// However, if the root expression is synthesized (as in the case
|
||||
// of the initializer when transforming a ForOfStatement), then the source map
|
||||
// location should point to the right-hand value of the expression.
|
||||
location = value;
|
||||
}
|
||||
}
|
||||
|
||||
flattenBindingOrAssignmentElement(flattenContext, node, value, location, /*skipInitializer*/ isDestructuringAssignment(node));
|
||||
|
||||
if (value && needsValue) {
|
||||
if (!some(expressions)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (needsValue) {
|
||||
expressions.push(value);
|
||||
}
|
||||
|
||||
const expression = inlineExpressions(expressions);
|
||||
aggregateTransformFlags(expression);
|
||||
return expression;
|
||||
|
||||
function emitAssignment(name: Identifier, value: Expression, location: TextRange) {
|
||||
const expression = createAssignment(name, value, location);
|
||||
return aggregateTransformFlags(inlineExpressions(expressions)) || createOmittedExpression();
|
||||
|
||||
function emitExpression(expression: Expression) {
|
||||
// NOTE: this completely disables source maps, but aligns with the behavior of
|
||||
// `emitAssignment` in the old emitter.
|
||||
setEmitFlags(expression, EmitFlags.NoNestedSourceMaps);
|
||||
|
||||
aggregateTransformFlags(expression);
|
||||
expressions.push(expression);
|
||||
expressions = append(expressions, expression);
|
||||
}
|
||||
|
||||
function emitTempVariableAssignment(value: Expression, location: TextRange) {
|
||||
const name = createTempVariable(recordTempVariable);
|
||||
emitAssignment(name, value, location);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens binding patterns in a parameter declaration.
|
||||
*
|
||||
* @param node The ParameterDeclaration to flatten.
|
||||
* @param value The rhs value for the binding pattern.
|
||||
* @param visitor An optional visitor to use to visit expressions.
|
||||
*/
|
||||
export function flattenParameterDestructuring(
|
||||
context: TransformationContext,
|
||||
node: ParameterDeclaration,
|
||||
value: Expression,
|
||||
visitor?: (node: Node) => VisitResult<Node>) {
|
||||
const declarations: VariableDeclaration[] = [];
|
||||
|
||||
flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
|
||||
return declarations;
|
||||
|
||||
function emitAssignment(name: Identifier, value: Expression, location: TextRange) {
|
||||
const declaration = createVariableDeclaration(name, /*type*/ undefined, value, location);
|
||||
|
||||
// NOTE: this completely disables source maps, but aligns with the behavior of
|
||||
// `emitAssignment` in the old emitter.
|
||||
setEmitFlags(declaration, EmitFlags.NoNestedSourceMaps);
|
||||
|
||||
aggregateTransformFlags(declaration);
|
||||
declarations.push(declaration);
|
||||
}
|
||||
|
||||
function emitTempVariableAssignment(value: Expression, location: TextRange) {
|
||||
const name = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
emitAssignment(name, value, location);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens binding patterns in a variable declaration.
|
||||
*
|
||||
* @param node The VariableDeclaration to flatten.
|
||||
* @param value An optional rhs value for the binding pattern.
|
||||
* @param visitor An optional visitor to use to visit expressions.
|
||||
*/
|
||||
export function flattenVariableDestructuring(
|
||||
context: TransformationContext,
|
||||
node: VariableDeclaration,
|
||||
value?: Expression,
|
||||
visitor?: (node: Node) => VisitResult<Node>,
|
||||
recordTempVariable?: (node: Identifier) => void) {
|
||||
const declarations: VariableDeclaration[] = [];
|
||||
|
||||
let pendingAssignments: Expression[];
|
||||
flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
|
||||
return declarations;
|
||||
|
||||
function emitAssignment(name: Identifier, value: Expression, location: TextRange, original: Node) {
|
||||
if (pendingAssignments) {
|
||||
pendingAssignments.push(value);
|
||||
value = inlineExpressions(pendingAssignments);
|
||||
pendingAssignments = undefined;
|
||||
}
|
||||
|
||||
const declaration = createVariableDeclaration(name, /*type*/ undefined, value, location);
|
||||
declaration.original = original;
|
||||
|
||||
// NOTE: this completely disables source maps, but aligns with the behavior of
|
||||
// `emitAssignment` in the old emitter.
|
||||
setEmitFlags(declaration, EmitFlags.NoNestedSourceMaps);
|
||||
|
||||
declarations.push(declaration);
|
||||
aggregateTransformFlags(declaration);
|
||||
}
|
||||
|
||||
function emitTempVariableAssignment(value: Expression, location: TextRange) {
|
||||
const name = createTempVariable(recordTempVariable);
|
||||
if (recordTempVariable) {
|
||||
const assignment = createAssignment(name, value, location);
|
||||
if (pendingAssignments) {
|
||||
pendingAssignments.push(assignment);
|
||||
}
|
||||
else {
|
||||
pendingAssignments = [assignment];
|
||||
}
|
||||
}
|
||||
else {
|
||||
emitAssignment(name, value, location, /*original*/ undefined);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens binding patterns in a variable declaration and transforms them into an expression.
|
||||
*
|
||||
* @param node The VariableDeclaration to flatten.
|
||||
* @param recordTempVariable A callback used to record new temporary variables.
|
||||
* @param nameSubstitution An optional callback used to substitute binding names.
|
||||
* @param visitor An optional visitor to use to visit expressions.
|
||||
*/
|
||||
export function flattenVariableDestructuringToExpression(
|
||||
context: TransformationContext,
|
||||
node: VariableDeclaration,
|
||||
recordTempVariable: (name: Identifier) => void,
|
||||
nameSubstitution?: (name: Identifier) => Expression,
|
||||
visitor?: (node: Node) => VisitResult<Node>) {
|
||||
|
||||
const pendingAssignments: Expression[] = [];
|
||||
|
||||
flattenDestructuring(context, node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
|
||||
const expression = inlineExpressions(pendingAssignments);
|
||||
aggregateTransformFlags(expression);
|
||||
return expression;
|
||||
|
||||
function emitAssignment(name: Identifier, value: Expression, location: TextRange, original: Node) {
|
||||
const left = nameSubstitution && nameSubstitution(name) || name;
|
||||
emitPendingAssignment(left, value, location, original);
|
||||
}
|
||||
|
||||
function emitTempVariableAssignment(value: Expression, location: TextRange) {
|
||||
const name = createTempVariable(recordTempVariable);
|
||||
emitPendingAssignment(name, value, location, /*original*/ undefined);
|
||||
return name;
|
||||
}
|
||||
|
||||
function emitPendingAssignment(name: Expression, value: Expression, location: TextRange, original: Node) {
|
||||
const expression = createAssignment(name, value, location);
|
||||
function emitBindingOrAssignment(target: BindingOrAssignmentElementTarget, value: Expression, location: TextRange, original: Node) {
|
||||
Debug.assertNode(target, createAssignmentCallback ? isIdentifier : isExpression);
|
||||
const expression = createAssignmentCallback
|
||||
? createAssignmentCallback(<Identifier>target, value, location)
|
||||
: createAssignment(visitNode(<Expression>target, visitor, isExpression), value, location);
|
||||
expression.original = original;
|
||||
|
||||
// NOTE: this completely disables source maps, but aligns with the behavior of
|
||||
// `emitAssignment` in the old emitter.
|
||||
setEmitFlags(expression, EmitFlags.NoNestedSourceMaps);
|
||||
|
||||
pendingAssignments.push(expression);
|
||||
return expression;
|
||||
emitExpression(expression);
|
||||
}
|
||||
}
|
||||
|
||||
function flattenDestructuring(
|
||||
/**
|
||||
* Flattens a VariableDeclaration or ParameterDeclaration to one or more variable declarations.
|
||||
*
|
||||
* @param node The node to flatten.
|
||||
* @param visitor An optional visitor used to visit initializers.
|
||||
* @param context The transformation context.
|
||||
* @param boundValue The value bound to the declaration.
|
||||
* @param skipInitializer A value indicating whether to ignore the initializer of `node`.
|
||||
* @param hoistTempVariables Indicates whether temporary variables should not be recorded in-line.
|
||||
* @param level Indicates the extent to which flattening should occur.
|
||||
*/
|
||||
export function flattenDestructuringBinding(
|
||||
node: VariableDeclaration | ParameterDeclaration,
|
||||
visitor: (node: Node) => VisitResult<Node>,
|
||||
context: TransformationContext,
|
||||
root: VariableDeclaration | ParameterDeclaration | BindingElement | BinaryExpression,
|
||||
value: Expression,
|
||||
level: FlattenLevel,
|
||||
rval?: Expression,
|
||||
hoistTempVariables?: boolean,
|
||||
skipInitializer?: boolean): VariableDeclaration[] {
|
||||
let pendingExpressions: Expression[];
|
||||
const pendingDeclarations: { pendingExpressions?: Expression[], name: BindingName, value: Expression, location?: TextRange, original?: Node; }[] = [];
|
||||
const declarations: VariableDeclaration[] = [];
|
||||
const flattenContext: FlattenContext = {
|
||||
context,
|
||||
level,
|
||||
hoistTempVariables,
|
||||
emitExpression,
|
||||
emitBindingOrAssignment,
|
||||
createArrayBindingOrAssignmentPattern: makeArrayBindingPattern,
|
||||
createObjectBindingOrAssignmentPattern: makeObjectBindingPattern,
|
||||
createArrayBindingOrAssignmentElement: makeBindingElement,
|
||||
visitor
|
||||
};
|
||||
flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer);
|
||||
if (pendingExpressions) {
|
||||
const temp = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
if (hoistTempVariables) {
|
||||
const value = inlineExpressions(pendingExpressions);
|
||||
pendingExpressions = undefined;
|
||||
emitBindingOrAssignment(temp, value, /*location*/ undefined, /*original*/ undefined);
|
||||
}
|
||||
else {
|
||||
context.hoistVariableDeclaration(temp);
|
||||
const pendingDeclaration = lastOrUndefined(pendingDeclarations);
|
||||
pendingDeclaration.pendingExpressions = append(
|
||||
pendingDeclaration.pendingExpressions,
|
||||
createAssignment(temp, pendingDeclaration.value)
|
||||
);
|
||||
addRange(pendingDeclaration.pendingExpressions, pendingExpressions);
|
||||
pendingDeclaration.value = temp;
|
||||
}
|
||||
}
|
||||
for (const { pendingExpressions, name, value, location, original } of pendingDeclarations) {
|
||||
const variable = createVariableDeclaration(
|
||||
name,
|
||||
/*type*/ undefined,
|
||||
pendingExpressions ? inlineExpressions(append(pendingExpressions, value)) : value,
|
||||
location);
|
||||
variable.original = original;
|
||||
if (isIdentifier(name)) {
|
||||
setEmitFlags(variable, EmitFlags.NoNestedSourceMaps);
|
||||
}
|
||||
aggregateTransformFlags(variable);
|
||||
declarations.push(variable);
|
||||
}
|
||||
return declarations;
|
||||
|
||||
function emitExpression(value: Expression) {
|
||||
pendingExpressions = append(pendingExpressions, value);
|
||||
}
|
||||
|
||||
function emitBindingOrAssignment(target: BindingOrAssignmentElementTarget, value: Expression, location: TextRange, original: Node) {
|
||||
Debug.assertNode(target, isBindingName);
|
||||
if (pendingExpressions) {
|
||||
value = inlineExpressions(append(pendingExpressions, value));
|
||||
pendingExpressions = undefined;
|
||||
}
|
||||
pendingDeclarations.push({ pendingExpressions, name: <BindingName>target, value, location, original });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens a BindingOrAssignmentElement into zero or more bindings or assignments.
|
||||
*
|
||||
* @param flattenContext Options used to control flattening.
|
||||
* @param element The element to flatten.
|
||||
* @param value The current RHS value to assign to the element.
|
||||
* @param location The location to use for source maps and comments.
|
||||
* @param skipInitializer An optional value indicating whether to include the initializer
|
||||
* for the element.
|
||||
*/
|
||||
function flattenBindingOrAssignmentElement(
|
||||
flattenContext: FlattenContext,
|
||||
element: BindingOrAssignmentElement,
|
||||
value: Expression | undefined,
|
||||
location: TextRange,
|
||||
emitAssignment: (name: Identifier, value: Expression, location: TextRange, original: Node) => void,
|
||||
emitTempVariableAssignment: (value: Expression, location: TextRange) => Identifier,
|
||||
visitor?: (node: Node) => VisitResult<Node>) {
|
||||
if (value && visitor) {
|
||||
value = visitNode(value, visitor, isExpression);
|
||||
}
|
||||
|
||||
if (isBinaryExpression(root)) {
|
||||
emitDestructuringAssignment(root.left, value, location);
|
||||
}
|
||||
else {
|
||||
emitBindingElement(root, value);
|
||||
}
|
||||
|
||||
function emitDestructuringAssignment(bindingTarget: Expression | ShorthandPropertyAssignment, value: Expression, location: TextRange) {
|
||||
// When emitting target = value use source map node to highlight, including any temporary assignments needed for this
|
||||
let target: Expression;
|
||||
if (isShorthandPropertyAssignment(bindingTarget)) {
|
||||
const initializer = visitor
|
||||
? visitNode(bindingTarget.objectAssignmentInitializer, visitor, isExpression)
|
||||
: bindingTarget.objectAssignmentInitializer;
|
||||
|
||||
if (initializer) {
|
||||
value = createDefaultValueCheck(value, initializer, location);
|
||||
}
|
||||
|
||||
target = bindingTarget.name;
|
||||
}
|
||||
else if (isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === SyntaxKind.EqualsToken) {
|
||||
const initializer = visitor
|
||||
? visitNode(bindingTarget.right, visitor, isExpression)
|
||||
: bindingTarget.right;
|
||||
|
||||
value = createDefaultValueCheck(value, initializer, location);
|
||||
target = bindingTarget.left;
|
||||
}
|
||||
else {
|
||||
target = bindingTarget;
|
||||
}
|
||||
|
||||
if (target.kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
emitObjectLiteralAssignment(<ObjectLiteralExpression>target, value, location);
|
||||
}
|
||||
else if (target.kind === SyntaxKind.ArrayLiteralExpression) {
|
||||
emitArrayLiteralAssignment(<ArrayLiteralExpression>target, value, location);
|
||||
}
|
||||
else {
|
||||
const name = getMutableClone(<Identifier>target);
|
||||
setSourceMapRange(name, target);
|
||||
setCommentRange(name, target);
|
||||
emitAssignment(name, value, location, /*original*/ undefined);
|
||||
}
|
||||
}
|
||||
|
||||
function emitObjectLiteralAssignment(target: ObjectLiteralExpression, value: Expression, location: TextRange) {
|
||||
const properties = target.properties;
|
||||
if (properties.length !== 1) {
|
||||
// For anything but a single element destructuring we need to generate a temporary
|
||||
// to ensure value is evaluated exactly once.
|
||||
// When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment
|
||||
value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment);
|
||||
}
|
||||
|
||||
for (const p of properties) {
|
||||
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
const propName = <Identifier | LiteralExpression>(<PropertyAssignment>p).name;
|
||||
const target = p.kind === SyntaxKind.ShorthandPropertyAssignment ? <ShorthandPropertyAssignment>p : (<PropertyAssignment>p).initializer || propName;
|
||||
// Assignment for target = value.propName should highligh whole property, hence use p as source map node
|
||||
emitDestructuringAssignment(target, createDestructuringPropertyAccess(value, propName), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitArrayLiteralAssignment(target: ArrayLiteralExpression, value: Expression, location: TextRange) {
|
||||
const elements = target.elements;
|
||||
const numElements = elements.length;
|
||||
if (numElements !== 1) {
|
||||
// For anything but a single element destructuring we need to generate a temporary
|
||||
// to ensure value is evaluated exactly once.
|
||||
// When doing so we want to hightlight the passed in source map node since thats the one needing this temp assignment
|
||||
value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment);
|
||||
}
|
||||
|
||||
for (let i = 0; i < numElements; i++) {
|
||||
const e = elements[i];
|
||||
if (e.kind !== SyntaxKind.OmittedExpression) {
|
||||
// Assignment for target = value.propName should highligh whole property, hence use e as source map node
|
||||
if (e.kind !== SyntaxKind.SpreadElementExpression) {
|
||||
emitDestructuringAssignment(e, createElementAccess(value, createLiteral(i)), e);
|
||||
}
|
||||
else if (i === numElements - 1) {
|
||||
emitDestructuringAssignment((<SpreadElementExpression>e).expression, createArraySlice(value, i), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitBindingElement(target: VariableDeclaration | ParameterDeclaration | BindingElement, value: Expression) {
|
||||
// Any temporary assignments needed to emit target = value should point to target
|
||||
const initializer = visitor ? visitNode(target.initializer, visitor, isExpression) : target.initializer;
|
||||
skipInitializer?: boolean) {
|
||||
if (!skipInitializer) {
|
||||
const initializer = visitNode(getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, isExpression);
|
||||
if (initializer) {
|
||||
// Combine value and initializer
|
||||
value = value ? createDefaultValueCheck(value, initializer, target) : initializer;
|
||||
value = value ? createDefaultValueCheck(flattenContext, value, initializer, location) : initializer;
|
||||
}
|
||||
else if (!value) {
|
||||
// Use 'void 0' in absence of value and initializer
|
||||
value = createVoidZero();
|
||||
}
|
||||
|
||||
const name = target.name;
|
||||
if (isBindingPattern(name)) {
|
||||
const elements = name.elements;
|
||||
const numElements = elements.length;
|
||||
if (numElements !== 1) {
|
||||
// For anything other than a single-element destructuring we need to generate a temporary
|
||||
// to ensure value is evaluated exactly once. Additionally, if we have zero elements
|
||||
// we need to emit *something* to ensure that in case a 'var' keyword was already emitted,
|
||||
// so in that case, we'll intentionally create that temporary.
|
||||
value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ numElements !== 0, target, emitTempVariableAssignment);
|
||||
}
|
||||
for (let i = 0; i < numElements; i++) {
|
||||
const element = elements[i];
|
||||
if (isOmittedExpression(element)) {
|
||||
continue;
|
||||
}
|
||||
else if (name.kind === SyntaxKind.ObjectBindingPattern) {
|
||||
// Rewrite element to a declaration with an initializer that fetches property
|
||||
const propName = element.propertyName || <Identifier>element.name;
|
||||
emitBindingElement(element, createDestructuringPropertyAccess(value, propName));
|
||||
}
|
||||
else {
|
||||
if (!element.dotDotDotToken) {
|
||||
// Rewrite element to a declaration that accesses array element at index i
|
||||
emitBindingElement(element, createElementAccess(value, i));
|
||||
}
|
||||
else if (i === numElements - 1) {
|
||||
emitBindingElement(element, createArraySlice(value, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
emitAssignment(name, value, target, target);
|
||||
}
|
||||
}
|
||||
|
||||
function createDefaultValueCheck(value: Expression, defaultValue: Expression, location: TextRange): Expression {
|
||||
value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true, location, emitTempVariableAssignment);
|
||||
return createConditional(
|
||||
createStrictEquality(value, createVoidZero()),
|
||||
createToken(SyntaxKind.QuestionToken),
|
||||
defaultValue,
|
||||
createToken(SyntaxKind.ColonToken),
|
||||
value
|
||||
);
|
||||
const bindingTarget = getTargetOfBindingOrAssignmentElement(element);
|
||||
if (isObjectBindingOrAssignmentPattern(bindingTarget)) {
|
||||
flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
|
||||
}
|
||||
else if (isArrayBindingOrAssignmentPattern(bindingTarget)) {
|
||||
flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
|
||||
}
|
||||
else {
|
||||
flattenContext.emitBindingOrAssignment(bindingTarget, value, location, /*original*/ element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates either a PropertyAccessExpression or an ElementAccessExpression for the
|
||||
* right-hand side of a transformed destructuring assignment.
|
||||
*
|
||||
* @param expression The right-hand expression that is the source of the property.
|
||||
* @param propertyName The destructuring property name.
|
||||
*/
|
||||
function createDestructuringPropertyAccess(expression: Expression, propertyName: PropertyName): LeftHandSideExpression {
|
||||
if (isComputedPropertyName(propertyName)) {
|
||||
return createElementAccess(
|
||||
expression,
|
||||
ensureIdentifier(propertyName.expression, /*reuseIdentifierExpressions*/ false, /*location*/ propertyName, emitTempVariableAssignment)
|
||||
);
|
||||
}
|
||||
else if (isLiteralExpression(propertyName)) {
|
||||
const clone = getSynthesizedClone(propertyName);
|
||||
clone.text = unescapeIdentifier(clone.text);
|
||||
return createElementAccess(expression, clone);
|
||||
}
|
||||
else {
|
||||
if (isGeneratedIdentifier(propertyName)) {
|
||||
const clone = getSynthesizedClone(propertyName);
|
||||
clone.text = unescapeIdentifier(clone.text);
|
||||
return createPropertyAccess(expression, clone);
|
||||
/**
|
||||
* Flattens an ObjectBindingOrAssignmentPattern into zero or more bindings or assignments.
|
||||
*
|
||||
* @param flattenContext Options used to control flattening.
|
||||
* @param parent The parent element of the pattern.
|
||||
* @param pattern The ObjectBindingOrAssignmentPattern to flatten.
|
||||
* @param value The current RHS value to assign to the element.
|
||||
* @param location The location to use for source maps and comments.
|
||||
*/
|
||||
function flattenObjectBindingOrAssignmentPattern(flattenContext: FlattenContext, parent: BindingOrAssignmentElement, pattern: ObjectBindingOrAssignmentPattern, value: Expression, location: TextRange) {
|
||||
const elements = getElementsOfBindingOrAssignmentPattern(pattern);
|
||||
const numElements = elements.length;
|
||||
if (numElements !== 1) {
|
||||
// For anything other than a single-element destructuring we need to generate a temporary
|
||||
// to ensure value is evaluated exactly once. Additionally, if we have zero elements
|
||||
// we need to emit *something* to ensure that in case a 'var' keyword was already emitted,
|
||||
// so in that case, we'll intentionally create that temporary.
|
||||
const reuseIdentifierExpressions = !isDeclarationBindingElement(parent) || numElements !== 0;
|
||||
value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
|
||||
}
|
||||
let bindingElements: BindingOrAssignmentElement[];
|
||||
let computedTempVariables: Expression[];
|
||||
for (let i = 0; i < numElements; i++) {
|
||||
const element = elements[i];
|
||||
if (!getRestIndicatorOfBindingOrAssignmentElement(element)) {
|
||||
const propertyName = getPropertyNameOfBindingOrAssignmentElement(element);
|
||||
if (flattenContext.level >= FlattenLevel.ObjectRest
|
||||
&& !(element.transformFlags & (TransformFlags.ContainsRest | TransformFlags.ContainsObjectRest))
|
||||
&& !(getTargetOfBindingOrAssignmentElement(element).transformFlags & (TransformFlags.ContainsRest | TransformFlags.ContainsObjectRest))
|
||||
&& !isComputedPropertyName(propertyName)) {
|
||||
bindingElements = append(bindingElements, element);
|
||||
}
|
||||
else {
|
||||
return createPropertyAccess(expression, createIdentifier(unescapeIdentifier(propertyName.text)));
|
||||
if (bindingElements) {
|
||||
flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
|
||||
bindingElements = undefined;
|
||||
}
|
||||
const rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName);
|
||||
if (isComputedPropertyName(propertyName)) {
|
||||
computedTempVariables = append(computedTempVariables, (rhsValue as ElementAccessExpression).argumentExpression);
|
||||
}
|
||||
flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, /*location*/ element);
|
||||
}
|
||||
}
|
||||
else if (i === numElements - 1) {
|
||||
if (bindingElements) {
|
||||
flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
|
||||
bindingElements = undefined;
|
||||
}
|
||||
const rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern);
|
||||
flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
|
||||
}
|
||||
}
|
||||
if (bindingElements) {
|
||||
flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens an ArrayBindingOrAssignmentPattern into zero or more bindings or assignments.
|
||||
*
|
||||
* @param flattenContext Options used to control flattening.
|
||||
* @param parent The parent element of the pattern.
|
||||
* @param pattern The ArrayBindingOrAssignmentPattern to flatten.
|
||||
* @param value The current RHS value to assign to the element.
|
||||
* @param location The location to use for source maps and comments.
|
||||
*/
|
||||
function flattenArrayBindingOrAssignmentPattern(flattenContext: FlattenContext, parent: BindingOrAssignmentElement, pattern: ArrayBindingOrAssignmentPattern, value: Expression, location: TextRange) {
|
||||
const elements = getElementsOfBindingOrAssignmentPattern(pattern);
|
||||
const numElements = elements.length;
|
||||
if (numElements !== 1 && (flattenContext.level < FlattenLevel.ObjectRest || numElements === 0)) {
|
||||
// For anything other than a single-element destructuring we need to generate a temporary
|
||||
// to ensure value is evaluated exactly once. Additionally, if we have zero elements
|
||||
// we need to emit *something* to ensure that in case a 'var' keyword was already emitted,
|
||||
// so in that case, we'll intentionally create that temporary.
|
||||
const reuseIdentifierExpressions = !isDeclarationBindingElement(parent) || numElements !== 0;
|
||||
value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
|
||||
}
|
||||
let bindingElements: BindingOrAssignmentElement[];
|
||||
let restContainingElements: [Identifier, BindingOrAssignmentElement][];
|
||||
for (let i = 0; i < numElements; i++) {
|
||||
const element = elements[i];
|
||||
if (flattenContext.level >= FlattenLevel.ObjectRest) {
|
||||
// If an array pattern contains an ObjectRest, we must cache the result so that we
|
||||
// can perform the ObjectRest destructuring in a different declaration
|
||||
if (element.transformFlags & TransformFlags.ContainsObjectRest) {
|
||||
const temp = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
if (flattenContext.hoistTempVariables) {
|
||||
flattenContext.context.hoistVariableDeclaration(temp);
|
||||
}
|
||||
|
||||
restContainingElements = append(restContainingElements, <[Identifier, BindingOrAssignmentElement]>[temp, element]);
|
||||
bindingElements = append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp));
|
||||
}
|
||||
else {
|
||||
bindingElements = append(bindingElements, element);
|
||||
}
|
||||
}
|
||||
else if (isOmittedExpression(element)) {
|
||||
continue;
|
||||
}
|
||||
else if (!getRestIndicatorOfBindingOrAssignmentElement(element)) {
|
||||
const rhsValue = createElementAccess(value, i);
|
||||
flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, /*location*/ element);
|
||||
}
|
||||
else if (i === numElements - 1) {
|
||||
const rhsValue = createArraySlice(value, i);
|
||||
flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, /*location*/ element);
|
||||
}
|
||||
}
|
||||
if (bindingElements) {
|
||||
flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern);
|
||||
}
|
||||
if (restContainingElements) {
|
||||
for (const [id, element] of restContainingElements) {
|
||||
flattenBindingOrAssignmentElement(flattenContext, element, id, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an expression used to provide a default value if a value is `undefined` at runtime.
|
||||
*
|
||||
* @param flattenContext Options used to control flattening.
|
||||
* @param value The RHS value to test.
|
||||
* @param defaultValue The default value to use if `value` is `undefined` at runtime.
|
||||
* @param location The location to use for source maps and comments.
|
||||
*/
|
||||
function createDefaultValueCheck(flattenContext: FlattenContext, value: Expression, defaultValue: Expression, location: TextRange): Expression {
|
||||
value = ensureIdentifier(flattenContext, value, /*reuseIdentifierExpressions*/ true, location);
|
||||
return createConditional(createTypeCheck(value, "undefined"), defaultValue, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates either a PropertyAccessExpression or an ElementAccessExpression for the
|
||||
* right-hand side of a transformed destructuring assignment.
|
||||
*
|
||||
* @link https://tc39.github.io/ecma262/#sec-runtime-semantics-keyeddestructuringassignmentevaluation
|
||||
*
|
||||
* @param flattenContext Options used to control flattening.
|
||||
* @param value The RHS value that is the source of the property.
|
||||
* @param propertyName The destructuring property name.
|
||||
*/
|
||||
function createDestructuringPropertyAccess(flattenContext: FlattenContext, value: Expression, propertyName: PropertyName): LeftHandSideExpression {
|
||||
if (isComputedPropertyName(propertyName)) {
|
||||
const argumentExpression = ensureIdentifier(flattenContext, propertyName.expression, /*reuseIdentifierExpressions*/ false, /*location*/ propertyName);
|
||||
return createElementAccess(value, argumentExpression);
|
||||
}
|
||||
else if (isStringOrNumericLiteral(propertyName)) {
|
||||
const argumentExpression = getSynthesizedClone(propertyName);
|
||||
argumentExpression.text = unescapeIdentifier(argumentExpression.text);
|
||||
return createElementAccess(value, argumentExpression);
|
||||
}
|
||||
else {
|
||||
const name = createIdentifier(unescapeIdentifier(propertyName.text));
|
||||
return createPropertyAccess(value, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,29 +402,96 @@ namespace ts {
|
||||
* This function is useful to ensure that the expression's value can be read from in subsequent expressions.
|
||||
* Unless 'reuseIdentifierExpressions' is false, 'value' will be returned if it is just an identifier.
|
||||
*
|
||||
* @param flattenContext Options used to control flattening.
|
||||
* @param value the expression whose value needs to be bound.
|
||||
* @param reuseIdentifierExpressions true if identifier expressions can simply be returned;
|
||||
* false if it is necessary to always emit an identifier.
|
||||
* false if it is necessary to always emit an identifier.
|
||||
* @param location The location to use for source maps and comments.
|
||||
* @param emitTempVariableAssignment A callback used to emit a temporary variable.
|
||||
* @param visitor An optional callback used to visit the value.
|
||||
*/
|
||||
function ensureIdentifier(
|
||||
value: Expression,
|
||||
reuseIdentifierExpressions: boolean,
|
||||
location: TextRange,
|
||||
emitTempVariableAssignment: (value: Expression, location: TextRange) => Identifier,
|
||||
visitor?: (node: Node) => VisitResult<Node>) {
|
||||
|
||||
function ensureIdentifier(flattenContext: FlattenContext, value: Expression, reuseIdentifierExpressions: boolean, location: TextRange) {
|
||||
if (isIdentifier(value) && reuseIdentifierExpressions) {
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
if (visitor) {
|
||||
value = visitNode(value, visitor, isExpression);
|
||||
const temp = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
if (flattenContext.hoistTempVariables) {
|
||||
flattenContext.context.hoistVariableDeclaration(temp);
|
||||
flattenContext.emitExpression(createAssignment(temp, value, location));
|
||||
}
|
||||
|
||||
return emitTempVariableAssignment(value, location);
|
||||
else {
|
||||
flattenContext.emitBindingOrAssignment(temp, value, location, /*original*/ undefined);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
function makeArrayBindingPattern(elements: BindingOrAssignmentElement[]) {
|
||||
Debug.assertEachNode(elements, isArrayBindingElement);
|
||||
return createArrayBindingPattern(<ArrayBindingElement[]>elements);
|
||||
}
|
||||
|
||||
function makeArrayAssignmentPattern(elements: BindingOrAssignmentElement[]) {
|
||||
return createArrayLiteral(map(elements, convertToArrayAssignmentElement));
|
||||
}
|
||||
|
||||
function makeObjectBindingPattern(elements: BindingOrAssignmentElement[]) {
|
||||
Debug.assertEachNode(elements, isBindingElement);
|
||||
return createObjectBindingPattern(<BindingElement[]>elements);
|
||||
}
|
||||
|
||||
function makeObjectAssignmentPattern(elements: BindingOrAssignmentElement[]) {
|
||||
return createObjectLiteral(map(elements, convertToObjectAssignmentElement));
|
||||
}
|
||||
|
||||
function makeBindingElement(name: Identifier) {
|
||||
return createBindingElement(/*propertyName*/ undefined, /*dotDotDotToken*/ undefined, name);
|
||||
}
|
||||
|
||||
function makeAssignmentElement(name: Identifier) {
|
||||
return name;
|
||||
}
|
||||
|
||||
const restHelper: EmitHelper = {
|
||||
name: "typescript:rest",
|
||||
scoped: false,
|
||||
text: `
|
||||
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;
|
||||
};`
|
||||
};
|
||||
|
||||
/** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement
|
||||
* `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`*/
|
||||
function createRestCall(context: TransformationContext, value: Expression, elements: BindingOrAssignmentElement[], computedTempVariables: Expression[], location: TextRange): Expression {
|
||||
context.requestEmitHelper(restHelper);
|
||||
const propertyNames: Expression[] = [];
|
||||
let computedTempVariableOffset = 0;
|
||||
for (let i = 0; i < elements.length - 1; i++) {
|
||||
const propertyName = getPropertyNameOfBindingOrAssignmentElement(elements[i]);
|
||||
if (propertyName) {
|
||||
if (isComputedPropertyName(propertyName)) {
|
||||
const temp = computedTempVariables[computedTempVariableOffset];
|
||||
computedTempVariableOffset++;
|
||||
// typeof _tmp === "symbol" ? _tmp : _tmp + ""
|
||||
propertyNames.push(
|
||||
createConditional(
|
||||
createTypeCheck(temp, "symbol"),
|
||||
temp,
|
||||
createAdd(temp, createLiteral(""))
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
propertyNames.push(createLiteral(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
return createCall(getHelperName("__rest"), undefined, [value, createArrayLiteral(propertyNames, location)]);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,91 @@
|
||||
/// <reference path="../factory.ts" />
|
||||
/// <reference path="../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function transformES2016(context: TransformationContext) {
|
||||
const { hoistVariableDeclaration } = context;
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
if ((node.transformFlags & TransformFlags.ContainsES2016) === 0) {
|
||||
return node;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return visitBinaryExpression(<BinaryExpression>node);
|
||||
default:
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
|
||||
function visitBinaryExpression(node: BinaryExpression): Expression {
|
||||
switch (node.operatorToken.kind) {
|
||||
case SyntaxKind.AsteriskAsteriskEqualsToken:
|
||||
return visitExponentiationAssignmentExpression(node);
|
||||
case SyntaxKind.AsteriskAsteriskToken:
|
||||
return visitExponentiationExpression(node);
|
||||
default:
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
|
||||
function visitExponentiationAssignmentExpression(node: BinaryExpression) {
|
||||
let target: Expression;
|
||||
let value: Expression;
|
||||
const left = visitNode(node.left, visitor, isExpression);
|
||||
const right = visitNode(node.right, visitor, isExpression);
|
||||
if (isElementAccessExpression(left)) {
|
||||
// Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)`
|
||||
const expressionTemp = createTempVariable(hoistVariableDeclaration);
|
||||
const argumentExpressionTemp = createTempVariable(hoistVariableDeclaration);
|
||||
target = createElementAccess(
|
||||
createAssignment(expressionTemp, left.expression, /*location*/ left.expression),
|
||||
createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression),
|
||||
/*location*/ left
|
||||
);
|
||||
value = createElementAccess(
|
||||
expressionTemp,
|
||||
argumentExpressionTemp,
|
||||
/*location*/ left
|
||||
);
|
||||
}
|
||||
else if (isPropertyAccessExpression(left)) {
|
||||
// Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)`
|
||||
const expressionTemp = createTempVariable(hoistVariableDeclaration);
|
||||
target = createPropertyAccess(
|
||||
createAssignment(expressionTemp, left.expression, /*location*/ left.expression),
|
||||
left.name,
|
||||
/*location*/ left
|
||||
);
|
||||
value = createPropertyAccess(
|
||||
expressionTemp,
|
||||
left.name,
|
||||
/*location*/ left
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Transforms `a **= b` into `a = Math.pow(a, b)`
|
||||
target = left;
|
||||
value = left;
|
||||
}
|
||||
return createAssignment(target, createMathPow(value, right, /*location*/ node), /*location*/ node);
|
||||
}
|
||||
|
||||
function visitExponentiationExpression(node: BinaryExpression) {
|
||||
// Transforms `a ** b` into `Math.pow(a, b)`
|
||||
const left = visitNode(node.left, visitor, isExpression);
|
||||
const right = visitNode(node.right, visitor, isExpression);
|
||||
return createMathPow(left, right, /*location*/ node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,518 @@
|
||||
/// <reference path="../factory.ts" />
|
||||
/// <reference path="../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration;
|
||||
|
||||
const enum ES2017SubstitutionFlags {
|
||||
/** Enables substitutions for async methods with `super` calls. */
|
||||
AsyncMethodsWithSuper = 1 << 0
|
||||
}
|
||||
|
||||
export function transformES2017(context: TransformationContext) {
|
||||
const {
|
||||
startLexicalEnvironment,
|
||||
resumeLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
} = context;
|
||||
|
||||
const resolver = context.getEmitResolver();
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
|
||||
// These variables contain state that changes as we descend into the tree.
|
||||
let currentSourceFile: SourceFile;
|
||||
|
||||
/**
|
||||
* Keeps track of whether expression substitution has been enabled for specific edge cases.
|
||||
* They are persisted between each SourceFile transformation and should not be reset.
|
||||
*/
|
||||
let enabledSubstitutions: ES2017SubstitutionFlags;
|
||||
|
||||
/**
|
||||
* This keeps track of containers where `super` is valid, for use with
|
||||
* just-in-time substitution for `super` expressions inside of async methods.
|
||||
*/
|
||||
let currentSuperContainer: SuperContainer;
|
||||
|
||||
// Save the previous transformation hooks.
|
||||
const previousOnEmitNode = context.onEmitNode;
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
|
||||
// Set new transformation hooks.
|
||||
context.onEmitNode = onEmitNode;
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
currentSourceFile = node;
|
||||
|
||||
const visited = visitEachChild(node, visitor, context);
|
||||
addEmitHelpers(visited, context.readEmitHelpers());
|
||||
|
||||
currentSourceFile = undefined;
|
||||
return visited;
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
if ((node.transformFlags & TransformFlags.ContainsES2017) === 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
// ES2017 async modifier should be elided for targets < ES2017
|
||||
return undefined;
|
||||
|
||||
case SyntaxKind.AwaitExpression:
|
||||
// ES2017 'await' expressions must be transformed for targets < ES2017.
|
||||
return visitAwaitExpression(<AwaitExpression>node);
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
// ES2017 method declarations may be 'async'
|
||||
return visitMethodDeclaration(<MethodDeclaration>node);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
// ES2017 function declarations may be 'async'
|
||||
return visitFunctionDeclaration(<FunctionDeclaration>node);
|
||||
|
||||
case SyntaxKind.FunctionExpression:
|
||||
// ES2017 function expressions may be 'async'
|
||||
return visitFunctionExpression(<FunctionExpression>node);
|
||||
|
||||
case SyntaxKind.ArrowFunction:
|
||||
// ES2017 arrow functions may be 'async'
|
||||
return visitArrowFunction(<ArrowFunction>node);
|
||||
|
||||
default:
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an AwaitExpression node.
|
||||
*
|
||||
* This function will be called any time a ES2017 await expression is encountered.
|
||||
*
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitAwaitExpression(node: AwaitExpression): Expression {
|
||||
return setOriginalNode(
|
||||
createYield(
|
||||
/*asteriskToken*/ undefined,
|
||||
visitNode(node.expression, visitor, isExpression),
|
||||
/*location*/ node
|
||||
),
|
||||
node
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a MethodDeclaration node.
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked as async
|
||||
*
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitMethodDeclaration(node: MethodDeclaration) {
|
||||
return updateMethod(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
visitNodes(node.modifiers, visitor, isModifier),
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
isAsyncFunctionLike(node)
|
||||
? transformAsyncFunctionBody(node)
|
||||
: visitFunctionBody(node.body, visitor, context)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a FunctionDeclaration node.
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked async
|
||||
*
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitFunctionDeclaration(node: FunctionDeclaration): VisitResult<Statement> {
|
||||
return updateFunctionDeclaration(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
visitNodes(node.modifiers, visitor, isModifier),
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
isAsyncFunctionLike(node)
|
||||
? transformAsyncFunctionBody(node)
|
||||
: visitFunctionBody(node.body, visitor, context)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a FunctionExpression node.
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked async
|
||||
*
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitFunctionExpression(node: FunctionExpression): Expression {
|
||||
if (nodeIsMissing(node.body)) {
|
||||
return createOmittedExpression();
|
||||
}
|
||||
return updateFunctionExpression(
|
||||
node,
|
||||
/*modifiers*/ undefined,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
isAsyncFunctionLike(node)
|
||||
? transformAsyncFunctionBody(node)
|
||||
: visitFunctionBody(node.body, visitor, context)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an ArrowFunction.
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked async
|
||||
*
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitArrowFunction(node: ArrowFunction) {
|
||||
return updateArrowFunction(
|
||||
node,
|
||||
visitNodes(node.modifiers, visitor, isModifier),
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
isAsyncFunctionLike(node)
|
||||
? transformAsyncFunctionBody(node)
|
||||
: visitFunctionBody(node.body, visitor, context)
|
||||
);
|
||||
}
|
||||
|
||||
function transformAsyncFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody;
|
||||
function transformAsyncFunctionBody(node: ArrowFunction): ConciseBody;
|
||||
function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody {
|
||||
resumeLexicalEnvironment();
|
||||
|
||||
const original = getOriginalNode(node, isFunctionLike);
|
||||
const nodeType = original.type;
|
||||
const promiseConstructor = languageVersion < ScriptTarget.ES2015 ? getPromiseConstructor(nodeType) : undefined;
|
||||
const isArrowFunction = node.kind === SyntaxKind.ArrowFunction;
|
||||
const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0;
|
||||
|
||||
// An async function is emit as an outer function that calls an inner
|
||||
// generator function. To preserve lexical bindings, we pass the current
|
||||
// `this` and `arguments` objects to `__awaiter`. The generator function
|
||||
// passed to `__awaiter` is executed inside of the callback to the
|
||||
// promise constructor.
|
||||
|
||||
if (!isArrowFunction) {
|
||||
const statements: Statement[] = [];
|
||||
const statementOffset = addPrologueDirectives(statements, (<Block>node.body).statements, /*ensureUseStrict*/ false, visitor);
|
||||
statements.push(
|
||||
createReturn(
|
||||
createAwaiterHelper(
|
||||
context,
|
||||
hasLexicalArguments,
|
||||
promiseConstructor,
|
||||
transformFunctionBodyWorker(<Block>node.body, statementOffset)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
addRange(statements, endLexicalEnvironment());
|
||||
|
||||
const block = createBlock(statements, /*location*/ node.body, /*multiLine*/ true);
|
||||
|
||||
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
||||
// This step isn't needed if we eventually transform this to ES5.
|
||||
if (languageVersion >= ScriptTarget.ES2015) {
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
addEmitHelper(block, advancedAsyncSuperHelper);
|
||||
}
|
||||
else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
addEmitHelper(block, asyncSuperHelper);
|
||||
}
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
else {
|
||||
const expression = createAwaiterHelper(
|
||||
context,
|
||||
hasLexicalArguments,
|
||||
promiseConstructor,
|
||||
transformFunctionBodyWorker(node.body)
|
||||
);
|
||||
|
||||
const declarations = endLexicalEnvironment();
|
||||
if (some(declarations)) {
|
||||
const block = convertToFunctionBody(expression);
|
||||
return updateBlock(block, createNodeArray(concatenate(block.statements, declarations), block.statements));
|
||||
}
|
||||
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
|
||||
function transformFunctionBodyWorker(body: ConciseBody, start?: number) {
|
||||
if (isBlock(body)) {
|
||||
return updateBlock(body, visitLexicalEnvironment(body.statements, visitor, context, start));
|
||||
}
|
||||
else {
|
||||
startLexicalEnvironment();
|
||||
const visited = convertToFunctionBody(visitNode(body, visitor, isConciseBody));
|
||||
const declarations = endLexicalEnvironment();
|
||||
return updateBlock(visited, createNodeArray(concatenate(visited.statements, declarations), visited.statements));
|
||||
}
|
||||
}
|
||||
|
||||
function getPromiseConstructor(type: TypeNode) {
|
||||
const typeName = type && getEntityNameFromTypeNode(type);
|
||||
if (typeName && isEntityName(typeName)) {
|
||||
const serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
|
||||
if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
|
||||
|| serializationKind === TypeReferenceSerializationKind.Unknown) {
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function enableSubstitutionForAsyncMethodsWithSuper() {
|
||||
if ((enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper) === 0) {
|
||||
enabledSubstitutions |= ES2017SubstitutionFlags.AsyncMethodsWithSuper;
|
||||
|
||||
// We need to enable substitutions for call, property access, and element access
|
||||
// if we need to rewrite super calls.
|
||||
context.enableSubstitution(SyntaxKind.CallExpression);
|
||||
context.enableSubstitution(SyntaxKind.PropertyAccessExpression);
|
||||
context.enableSubstitution(SyntaxKind.ElementAccessExpression);
|
||||
|
||||
// We need to be notified when entering and exiting declarations that bind super.
|
||||
context.enableEmitNotification(SyntaxKind.ClassDeclaration);
|
||||
context.enableEmitNotification(SyntaxKind.MethodDeclaration);
|
||||
context.enableEmitNotification(SyntaxKind.GetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.SetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.Constructor);
|
||||
}
|
||||
}
|
||||
|
||||
function substituteExpression(node: Expression) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return substitutePropertyAccessExpression(<PropertyAccessExpression>node);
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return substituteElementAccessExpression(<ElementAccessExpression>node);
|
||||
case SyntaxKind.CallExpression:
|
||||
if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper) {
|
||||
return substituteCallExpression(<CallExpression>node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
const flags = getSuperContainerAsyncMethodFlags();
|
||||
if (flags) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
createLiteral(node.name.text),
|
||||
flags,
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function substituteElementAccessExpression(node: ElementAccessExpression) {
|
||||
if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
const flags = getSuperContainerAsyncMethodFlags();
|
||||
if (flags) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
node.argumentExpression,
|
||||
flags,
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function substituteCallExpression(node: CallExpression): Expression {
|
||||
const expression = node.expression;
|
||||
if (isSuperProperty(expression)) {
|
||||
const flags = getSuperContainerAsyncMethodFlags();
|
||||
if (flags) {
|
||||
const argumentExpression = isPropertyAccessExpression(expression)
|
||||
? substitutePropertyAccessExpression(expression)
|
||||
: substituteElementAccessExpression(expression);
|
||||
return createCall(
|
||||
createPropertyAccess(argumentExpression, "call"),
|
||||
/*typeArguments*/ undefined,
|
||||
[
|
||||
createThis(),
|
||||
...node.arguments
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function isSuperContainer(node: Node): node is SuperContainer {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.ClassDeclaration
|
||||
|| kind === SyntaxKind.Constructor
|
||||
|| kind === SyntaxKind.MethodDeclaration
|
||||
|| kind === SyntaxKind.GetAccessor
|
||||
|| kind === SyntaxKind.SetAccessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for node emit.
|
||||
*
|
||||
* @param node The node to emit.
|
||||
* @param emit A callback used to emit the node in the printer.
|
||||
*/
|
||||
function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void {
|
||||
// If we need to support substitutions for `super` in an async method,
|
||||
// we should track it here.
|
||||
if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) {
|
||||
const savedCurrentSuperContainer = currentSuperContainer;
|
||||
currentSuperContainer = node;
|
||||
previousOnEmitNode(emitContext, node, emitCallback);
|
||||
currentSuperContainer = savedCurrentSuperContainer;
|
||||
}
|
||||
else {
|
||||
previousOnEmitNode(emitContext, node, emitCallback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks node substitutions.
|
||||
*
|
||||
* @param node The node to substitute.
|
||||
* @param isExpression A value indicating whether the node is to be used in an expression
|
||||
* position.
|
||||
*/
|
||||
function onSubstituteNode(emitContext: EmitContext, node: Node) {
|
||||
node = previousOnSubstituteNode(emitContext, node);
|
||||
if (emitContext === EmitContext.Expression) {
|
||||
return substituteExpression(<Expression>node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function createSuperAccessInAsyncMethod(argumentExpression: Expression, flags: NodeCheckFlags, location: TextRange): LeftHandSideExpression {
|
||||
if (flags & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
return createPropertyAccess(
|
||||
createCall(
|
||||
createIdentifier("_super"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression]
|
||||
),
|
||||
"value",
|
||||
location
|
||||
);
|
||||
}
|
||||
else {
|
||||
return createCall(
|
||||
createIdentifier("_super"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression],
|
||||
location
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getSuperContainerAsyncMethodFlags() {
|
||||
return currentSuperContainer !== undefined
|
||||
&& resolver.getNodeCheckFlags(currentSuperContainer) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding);
|
||||
}
|
||||
}
|
||||
|
||||
function createAwaiterHelper(context: TransformationContext, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block) {
|
||||
context.requestEmitHelper(awaiterHelper);
|
||||
const generatorFunc = createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
createToken(SyntaxKind.AsteriskToken),
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
/*parameters*/ [],
|
||||
/*type*/ undefined,
|
||||
body
|
||||
);
|
||||
|
||||
// Mark this node as originally an async function
|
||||
(generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= EmitFlags.AsyncFunctionBody;
|
||||
|
||||
return createCall(
|
||||
getHelperName("__awaiter"),
|
||||
/*typeArguments*/ undefined,
|
||||
[
|
||||
createThis(),
|
||||
hasLexicalArguments ? createIdentifier("arguments") : createVoidZero(),
|
||||
promiseConstructor ? createExpressionFromEntityName(promiseConstructor) : createVoidZero(),
|
||||
generatorFunc
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
const awaiterHelper: EmitHelper = {
|
||||
name: "typescript:awaiter",
|
||||
scoped: false,
|
||||
priority: 5,
|
||||
text: `
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};`
|
||||
};
|
||||
|
||||
const asyncSuperHelper: EmitHelper = {
|
||||
name: "typescript:async-super",
|
||||
scoped: true,
|
||||
text: `
|
||||
const _super = name => super[name];`
|
||||
};
|
||||
|
||||
const advancedAsyncSuperHelper: EmitHelper = {
|
||||
name: "typescript:advanced-async-super",
|
||||
scoped: true,
|
||||
text: `
|
||||
const _super = (function (geti, seti) {
|
||||
const cache = Object.create(null);
|
||||
return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });
|
||||
})(name => super[name], (name, value) => super[name] = value);`
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/// <reference path="../factory.ts" />
|
||||
/// <reference path="../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
/**
|
||||
* Transforms ES5 syntax into ES3 syntax.
|
||||
*
|
||||
* @param context Context and state information for the transformation.
|
||||
*/
|
||||
export function transformES5(context: TransformationContext) {
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
|
||||
// enable emit notification only if using --jsx preserve
|
||||
let previousOnEmitNode: (emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) => void;
|
||||
let noSubstitution: boolean[];
|
||||
if (compilerOptions.jsx === JsxEmit.Preserve) {
|
||||
previousOnEmitNode = context.onEmitNode;
|
||||
context.onEmitNode = onEmitNode;
|
||||
context.enableEmitNotification(SyntaxKind.JsxOpeningElement);
|
||||
context.enableEmitNotification(SyntaxKind.JsxClosingElement);
|
||||
context.enableEmitNotification(SyntaxKind.JsxSelfClosingElement);
|
||||
noSubstitution = [];
|
||||
}
|
||||
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
context.enableSubstitution(SyntaxKind.PropertyAccessExpression);
|
||||
context.enableSubstitution(SyntaxKind.PropertyAssignment);
|
||||
return transformSourceFile;
|
||||
|
||||
/**
|
||||
* Transforms an ES5 source file to ES3.
|
||||
*
|
||||
* @param node A SourceFile
|
||||
*/
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the printer just before a node is printed.
|
||||
*
|
||||
* @param node The node to be printed.
|
||||
*/
|
||||
function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
case SyntaxKind.JsxClosingElement:
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
const tagName = (<JsxOpeningElement | JsxClosingElement | JsxSelfClosingElement>node).tagName;
|
||||
noSubstitution[getOriginalNodeId(tagName)] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
previousOnEmitNode(emitContext, node, emitCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks node substitutions.
|
||||
*
|
||||
* @param emitContext The context for the emitter.
|
||||
* @param node The node to substitute.
|
||||
*/
|
||||
function onSubstituteNode(emitContext: EmitContext, node: Node) {
|
||||
if (node.id && noSubstitution && noSubstitution[node.id]) {
|
||||
return previousOnSubstituteNode(emitContext, node);
|
||||
}
|
||||
|
||||
node = previousOnSubstituteNode(emitContext, node);
|
||||
if (isPropertyAccessExpression(node)) {
|
||||
return substitutePropertyAccessExpression(node);
|
||||
}
|
||||
else if (isPropertyAssignment(node)) {
|
||||
return substitutePropertyAssignment(node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes a PropertyAccessExpression whose name is a reserved word.
|
||||
*
|
||||
* @param node A PropertyAccessExpression
|
||||
*/
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression): Expression {
|
||||
const literalName = trySubstituteReservedName(node.name);
|
||||
if (literalName) {
|
||||
return createElementAccess(node.expression, literalName, /*location*/ node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes a PropertyAssignment whose name is a reserved word.
|
||||
*
|
||||
* @param node A PropertyAssignment
|
||||
*/
|
||||
function substitutePropertyAssignment(node: PropertyAssignment): PropertyAssignment {
|
||||
const literalName = isIdentifier(node.name) && trySubstituteReservedName(node.name);
|
||||
if (literalName) {
|
||||
return updatePropertyAssignment(node, literalName, node.initializer);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* If an identifier name is a reserved word, returns a string literal for the name.
|
||||
*
|
||||
* @param name An Identifier
|
||||
*/
|
||||
function trySubstituteReservedName(name: Identifier) {
|
||||
const token = name.originalKeywordKind || (nodeIsSynthesized(name) ? stringToToken(name.text) : undefined);
|
||||
if (token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord) {
|
||||
return createLiteral(name, /*location*/ name);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/// <reference path="../factory.ts" />
|
||||
/// <reference path="../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function transformES7(context: TransformationContext) {
|
||||
const { hoistVariableDeclaration } = context;
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
if (node.transformFlags & TransformFlags.ES7) {
|
||||
return visitorWorker(node);
|
||||
}
|
||||
else if (node.transformFlags & TransformFlags.ContainsES7) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
else {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
function visitorWorker(node: Node): VisitResult<Node> {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return visitBinaryExpression(<BinaryExpression>node);
|
||||
|
||||
default:
|
||||
Debug.failBadSyntaxKind(node);
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
|
||||
function visitBinaryExpression(node: BinaryExpression): Expression {
|
||||
// We are here because ES7 adds support for the exponentiation operator.
|
||||
const left = visitNode(node.left, visitor, isExpression);
|
||||
const right = visitNode(node.right, visitor, isExpression);
|
||||
if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskEqualsToken) {
|
||||
let target: Expression;
|
||||
let value: Expression;
|
||||
if (isElementAccessExpression(left)) {
|
||||
// Transforms `a[x] **= b` into `(_a = a)[_x = x] = Math.pow(_a[_x], b)`
|
||||
const expressionTemp = createTempVariable(hoistVariableDeclaration);
|
||||
|
||||
const argumentExpressionTemp = createTempVariable(hoistVariableDeclaration);
|
||||
|
||||
target = createElementAccess(
|
||||
createAssignment(expressionTemp, left.expression, /*location*/ left.expression),
|
||||
createAssignment(argumentExpressionTemp, left.argumentExpression, /*location*/ left.argumentExpression),
|
||||
/*location*/ left
|
||||
);
|
||||
|
||||
value = createElementAccess(
|
||||
expressionTemp,
|
||||
argumentExpressionTemp,
|
||||
/*location*/ left
|
||||
);
|
||||
}
|
||||
else if (isPropertyAccessExpression(left)) {
|
||||
// Transforms `a.x **= b` into `(_a = a).x = Math.pow(_a.x, b)`
|
||||
const expressionTemp = createTempVariable(hoistVariableDeclaration);
|
||||
|
||||
target = createPropertyAccess(
|
||||
createAssignment(expressionTemp, left.expression, /*location*/ left.expression),
|
||||
left.name,
|
||||
/*location*/ left
|
||||
);
|
||||
|
||||
value = createPropertyAccess(
|
||||
expressionTemp,
|
||||
left.name,
|
||||
/*location*/ left
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Transforms `a **= b` into `a = Math.pow(a, b)`
|
||||
target = left;
|
||||
value = left;
|
||||
}
|
||||
|
||||
return createAssignment(target, createMathPow(value, right, /*location*/ node), /*location*/ node);
|
||||
}
|
||||
else if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskToken) {
|
||||
// Transforms `a ** b` into `Math.pow(a, b)`
|
||||
return createMathPow(left, right, /*location*/ node);
|
||||
}
|
||||
else {
|
||||
Debug.failBadSyntaxKind(node);
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
/// <reference path="../factory.ts" />
|
||||
/// <reference path="../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function transformESNext(context: TransformationContext) {
|
||||
const {
|
||||
resumeLexicalEnvironment,
|
||||
endLexicalEnvironment
|
||||
} = context;
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
const visited = visitEachChild(node, visitor, context);
|
||||
addEmitHelpers(visited, context.readEmitHelpers());
|
||||
return visited;
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
return visitorWorker(node, /*noDestructuringValue*/ false);
|
||||
}
|
||||
|
||||
function visitorNoDestructuringValue(node: Node): VisitResult<Node> {
|
||||
return visitorWorker(node, /*noDestructuringValue*/ true);
|
||||
}
|
||||
|
||||
function visitorWorker(node: Node, noDestructuringValue: boolean): VisitResult<Node> {
|
||||
if ((node.transformFlags & TransformFlags.ContainsESNext) === 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return visitObjectLiteralExpression(node as ObjectLiteralExpression);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return visitBinaryExpression(node as BinaryExpression, noDestructuringValue);
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return visitVariableDeclaration(node as VariableDeclaration);
|
||||
case SyntaxKind.ForOfStatement:
|
||||
return visitForOfStatement(node as ForOfStatement);
|
||||
case SyntaxKind.ForStatement:
|
||||
return visitForStatement(node as ForStatement);
|
||||
case SyntaxKind.VoidExpression:
|
||||
return visitVoidExpression(node as VoidExpression);
|
||||
case SyntaxKind.Constructor:
|
||||
return visitConstructorDeclaration(node as ConstructorDeclaration);
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
return visitMethodDeclaration(node as MethodDeclaration);
|
||||
case SyntaxKind.GetAccessor:
|
||||
return visitGetAccessorDeclaration(node as GetAccessorDeclaration);
|
||||
case SyntaxKind.SetAccessor:
|
||||
return visitSetAccessorDeclaration(node as SetAccessorDeclaration);
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return visitFunctionDeclaration(node as FunctionDeclaration);
|
||||
case SyntaxKind.FunctionExpression:
|
||||
return visitFunctionExpression(node as FunctionExpression);
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return visitArrowFunction(node as ArrowFunction);
|
||||
case SyntaxKind.Parameter:
|
||||
return visitParameter(node as ParameterDeclaration);
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
return visitExpressionStatement(node as ExpressionStatement);
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return visitParenthesizedExpression(node as ParenthesizedExpression, noDestructuringValue);
|
||||
default:
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
|
||||
function chunkObjectLiteralElements(elements: ObjectLiteralElement[]): Expression[] {
|
||||
let chunkObject: (ShorthandPropertyAssignment | PropertyAssignment)[];
|
||||
const objects: Expression[] = [];
|
||||
for (const e of elements) {
|
||||
if (e.kind === SyntaxKind.SpreadAssignment) {
|
||||
if (chunkObject) {
|
||||
objects.push(createObjectLiteral(chunkObject));
|
||||
chunkObject = undefined;
|
||||
}
|
||||
const target = (e as SpreadAssignment).expression;
|
||||
objects.push(visitNode(target, visitor, isExpression));
|
||||
}
|
||||
else {
|
||||
if (!chunkObject) {
|
||||
chunkObject = [];
|
||||
}
|
||||
if (e.kind === SyntaxKind.PropertyAssignment) {
|
||||
const p = e as PropertyAssignment;
|
||||
chunkObject.push(createPropertyAssignment(p.name, visitNode(p.initializer, visitor, isExpression)));
|
||||
}
|
||||
else {
|
||||
chunkObject.push(e as ShorthandPropertyAssignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (chunkObject) {
|
||||
objects.push(createObjectLiteral(chunkObject));
|
||||
}
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
function visitObjectLiteralExpression(node: ObjectLiteralExpression): Expression {
|
||||
if (node.transformFlags & TransformFlags.ContainsObjectSpread) {
|
||||
// spread elements emit like so:
|
||||
// non-spread elements are chunked together into object literals, and then all are passed to __assign:
|
||||
// { a, ...o, b } => __assign({a}, o, {b});
|
||||
// If the first element is a spread element, then the first argument to __assign is {}:
|
||||
// { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2)
|
||||
const objects = chunkObjectLiteralElements(node.properties);
|
||||
if (objects.length && objects[0].kind !== SyntaxKind.ObjectLiteralExpression) {
|
||||
objects.unshift(createObjectLiteral());
|
||||
}
|
||||
return createAssignHelper(context, objects);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitExpressionStatement(node: ExpressionStatement): ExpressionStatement {
|
||||
return visitEachChild(node, visitorNoDestructuringValue, context);
|
||||
}
|
||||
|
||||
function visitParenthesizedExpression(node: ParenthesizedExpression, noDestructuringValue: boolean): ParenthesizedExpression {
|
||||
return visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a BinaryExpression that contains a destructuring assignment.
|
||||
*
|
||||
* @param node A BinaryExpression node.
|
||||
*/
|
||||
function visitBinaryExpression(node: BinaryExpression, noDestructuringValue: boolean): Expression {
|
||||
if (isDestructuringAssignment(node) && node.left.transformFlags & TransformFlags.ContainsObjectRest) {
|
||||
return flattenDestructuringAssignment(
|
||||
node,
|
||||
visitor,
|
||||
context,
|
||||
FlattenLevel.ObjectRest,
|
||||
!noDestructuringValue
|
||||
);
|
||||
}
|
||||
else if (node.operatorToken.kind === SyntaxKind.CommaToken) {
|
||||
return updateBinary(
|
||||
node,
|
||||
visitNode(node.left, visitorNoDestructuringValue, isExpression),
|
||||
visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, isExpression)
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a VariableDeclaration node with a binding pattern.
|
||||
*
|
||||
* @param node A VariableDeclaration node.
|
||||
*/
|
||||
function visitVariableDeclaration(node: VariableDeclaration): VisitResult<VariableDeclaration> {
|
||||
// If we are here it is because the name contains a binding pattern with a rest somewhere in it.
|
||||
if (isBindingPattern(node.name) && node.name.transformFlags & TransformFlags.ContainsObjectRest) {
|
||||
return flattenDestructuringBinding(
|
||||
node,
|
||||
visitor,
|
||||
context,
|
||||
FlattenLevel.ObjectRest
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitForStatement(node: ForStatement): VisitResult<Statement> {
|
||||
return updateFor(
|
||||
node,
|
||||
visitNode(node.initializer, visitorNoDestructuringValue, isForInitializer),
|
||||
visitNode(node.condition, visitor, isExpression),
|
||||
visitNode(node.incrementor, visitor, isExpression),
|
||||
visitNode(node.statement, visitor, isStatement)
|
||||
);
|
||||
}
|
||||
|
||||
function visitVoidExpression(node: VoidExpression) {
|
||||
return visitEachChild(node, visitorNoDestructuringValue, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a ForOfStatement and converts it into a ES2015-compatible ForOfStatement.
|
||||
*
|
||||
* @param node A ForOfStatement.
|
||||
*/
|
||||
function visitForOfStatement(node: ForOfStatement): VisitResult<Statement> {
|
||||
let leadingStatements: Statement[];
|
||||
let temp: Identifier;
|
||||
const initializer = skipParentheses(node.initializer);
|
||||
if (initializer.transformFlags & TransformFlags.ContainsObjectRest) {
|
||||
if (isVariableDeclarationList(initializer)) {
|
||||
temp = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
const firstDeclaration = firstOrUndefined(initializer.declarations);
|
||||
const declarations = flattenDestructuringBinding(
|
||||
firstDeclaration,
|
||||
visitor,
|
||||
context,
|
||||
FlattenLevel.ObjectRest,
|
||||
temp,
|
||||
/*doNotRecordTempVariablesInLine*/ false,
|
||||
/*skipInitializer*/ true,
|
||||
);
|
||||
if (some(declarations)) {
|
||||
const statement = createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
updateVariableDeclarationList(initializer, declarations),
|
||||
/*location*/ initializer
|
||||
);
|
||||
leadingStatements = append(leadingStatements, statement);
|
||||
}
|
||||
}
|
||||
else if (isAssignmentPattern(initializer)) {
|
||||
temp = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
const expression = flattenDestructuringAssignment(
|
||||
aggregateTransformFlags(createAssignment(initializer, temp, /*location*/ node.initializer)),
|
||||
visitor,
|
||||
context,
|
||||
FlattenLevel.ObjectRest
|
||||
);
|
||||
leadingStatements = append(leadingStatements, createStatement(expression, /*location*/ node.initializer));
|
||||
}
|
||||
}
|
||||
if (temp) {
|
||||
const expression = visitNode(node.expression, visitor, isExpression);
|
||||
const statement = visitNode(node.statement, visitor, isStatement);
|
||||
const block = isBlock(statement)
|
||||
? updateBlock(statement, createNodeArray(concatenate(leadingStatements, statement.statements), statement.statements))
|
||||
: createBlock(append(leadingStatements, statement), statement, /*multiLine*/ true);
|
||||
return updateForOf(
|
||||
node,
|
||||
createVariableDeclarationList(
|
||||
[
|
||||
createVariableDeclaration(temp, /*type*/ undefined, /*initializer*/ undefined, node.initializer)
|
||||
],
|
||||
node.initializer,
|
||||
NodeFlags.Let
|
||||
),
|
||||
expression,
|
||||
block
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitParameter(node: ParameterDeclaration): ParameterDeclaration {
|
||||
if (node.transformFlags & TransformFlags.ContainsObjectRest) {
|
||||
// Binding patterns are converted into a generated name and are
|
||||
// evaluated inside the function body.
|
||||
return updateParameter(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
node.dotDotDotToken,
|
||||
getGeneratedNameForNode(node),
|
||||
/*type*/ undefined,
|
||||
visitNode(node.initializer, visitor, isExpression)
|
||||
);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitConstructorDeclaration(node: ConstructorDeclaration) {
|
||||
return updateConstructor(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
node.modifiers,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
transformFunctionBody(node)
|
||||
);
|
||||
}
|
||||
|
||||
function visitGetAccessorDeclaration(node: GetAccessorDeclaration) {
|
||||
return updateGetAccessor(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
node.modifiers,
|
||||
visitNode(node.name, visitor, isPropertyName),
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
transformFunctionBody(node)
|
||||
);
|
||||
}
|
||||
|
||||
function visitSetAccessorDeclaration(node: SetAccessorDeclaration) {
|
||||
return updateSetAccessor(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
node.modifiers,
|
||||
visitNode(node.name, visitor, isPropertyName),
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
transformFunctionBody(node)
|
||||
);
|
||||
}
|
||||
|
||||
function visitMethodDeclaration(node: MethodDeclaration) {
|
||||
return updateMethod(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
node.modifiers,
|
||||
visitNode(node.name, visitor, isPropertyName),
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
transformFunctionBody(node)
|
||||
);
|
||||
}
|
||||
|
||||
function visitFunctionDeclaration(node: FunctionDeclaration) {
|
||||
return updateFunctionDeclaration(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
node.modifiers,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
transformFunctionBody(node)
|
||||
);
|
||||
}
|
||||
|
||||
function visitArrowFunction(node: ArrowFunction) {
|
||||
return updateArrowFunction(
|
||||
node,
|
||||
node.modifiers,
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
transformFunctionBody(node)
|
||||
);
|
||||
}
|
||||
|
||||
function visitFunctionExpression(node: FunctionExpression) {
|
||||
return updateFunctionExpression(
|
||||
node,
|
||||
node.modifiers,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
transformFunctionBody(node)
|
||||
);
|
||||
}
|
||||
|
||||
function transformFunctionBody(node: FunctionDeclaration | FunctionExpression | ConstructorDeclaration | MethodDeclaration | AccessorDeclaration): FunctionBody;
|
||||
function transformFunctionBody(node: ArrowFunction): ConciseBody;
|
||||
function transformFunctionBody(node: FunctionLikeDeclaration): ConciseBody {
|
||||
resumeLexicalEnvironment();
|
||||
let leadingStatements: Statement[];
|
||||
for (const parameter of node.parameters) {
|
||||
if (parameter.transformFlags & TransformFlags.ContainsObjectRest) {
|
||||
const temp = getGeneratedNameForNode(parameter);
|
||||
const declarations = flattenDestructuringBinding(
|
||||
parameter,
|
||||
visitor,
|
||||
context,
|
||||
FlattenLevel.ObjectRest,
|
||||
temp,
|
||||
/*doNotRecordTempVariablesInLine*/ false,
|
||||
/*skipInitializer*/ true,
|
||||
);
|
||||
if (some(declarations)) {
|
||||
const statement = createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList(
|
||||
declarations
|
||||
)
|
||||
);
|
||||
setEmitFlags(statement, EmitFlags.CustomPrologue);
|
||||
leadingStatements = append(leadingStatements, statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
const body = visitNode(node.body, visitor, isConciseBody);
|
||||
const trailingStatements = endLexicalEnvironment();
|
||||
if (some(leadingStatements) || some(trailingStatements)) {
|
||||
const block = convertToFunctionBody(body, /*multiLine*/ true);
|
||||
return updateBlock(block, createNodeArray(concatenate(concatenate(leadingStatements, block.statements), trailingStatements), block.statements));
|
||||
}
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
const assignHelper: EmitHelper = {
|
||||
name: "typescript:assign",
|
||||
scoped: false,
|
||||
priority: 1,
|
||||
text: `
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};`
|
||||
};
|
||||
|
||||
export function createAssignHelper(context: TransformationContext, attributesSegments: Expression[]) {
|
||||
context.requestEmitHelper(assignHelper);
|
||||
return createCall(
|
||||
getHelperName("__assign"),
|
||||
/*typeArguments*/ undefined,
|
||||
attributesSegments
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ namespace ts {
|
||||
|
||||
export function transformGenerators(context: TransformationContext) {
|
||||
const {
|
||||
startLexicalEnvironment,
|
||||
resumeLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
hoistFunctionDeclaration,
|
||||
hoistVariableDeclaration,
|
||||
@@ -291,17 +291,18 @@ namespace ts {
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
if (isDeclarationFile(node)
|
||||
|| (node.transformFlags & TransformFlags.ContainsGenerator) === 0) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (node.transformFlags & TransformFlags.ContainsGenerator) {
|
||||
currentSourceFile = node;
|
||||
node = visitEachChild(node, visitor, context);
|
||||
currentSourceFile = undefined;
|
||||
}
|
||||
currentSourceFile = node;
|
||||
|
||||
return node;
|
||||
const visited = visitEachChild(node, visitor, context);
|
||||
addEmitHelpers(visited, context.readEmitHelpers());
|
||||
|
||||
currentSourceFile = undefined;
|
||||
return visited;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,11 +450,11 @@ namespace ts {
|
||||
node = setOriginalNode(
|
||||
createFunctionDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
node.modifiers,
|
||||
/*asteriskToken*/ undefined,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
node.parameters,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
transformGeneratorFunctionBody(node.body),
|
||||
/*location*/ node
|
||||
@@ -496,10 +497,11 @@ namespace ts {
|
||||
if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
|
||||
node = setOriginalNode(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
node.parameters,
|
||||
visitParameterList(node.parameters, visitor, context),
|
||||
/*type*/ undefined,
|
||||
transformGeneratorFunctionBody(node.body),
|
||||
/*location*/ node
|
||||
@@ -577,7 +579,7 @@ namespace ts {
|
||||
state = createTempVariable(/*recordTempVariable*/ undefined);
|
||||
|
||||
// Build the generator
|
||||
startLexicalEnvironment();
|
||||
resumeLexicalEnvironment();
|
||||
|
||||
const statementOffset = addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor);
|
||||
|
||||
@@ -936,7 +938,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
markLabel(resumeLabel);
|
||||
return createGeneratorResume();
|
||||
return createGeneratorResume(/*location*/ node);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -945,7 +947,7 @@ namespace ts {
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function visitArrayLiteralExpression(node: ArrayLiteralExpression) {
|
||||
return visitElements(node.elements, node.multiLine);
|
||||
return visitElements(node.elements, /*leadingElement*/ undefined, /*location*/ undefined, node.multiLine);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -955,7 +957,7 @@ namespace ts {
|
||||
* @param elements The elements to visit.
|
||||
* @param multiLine Whether array literals created should be emitted on multiple lines.
|
||||
*/
|
||||
function visitElements(elements: NodeArray<Expression>, multiLine: boolean) {
|
||||
function visitElements(elements: NodeArray<Expression>, leadingElement?: Expression, location?: TextRange, multiLine?: boolean) {
|
||||
// [source]
|
||||
// ar = [1, yield, 2];
|
||||
//
|
||||
@@ -970,18 +972,22 @@ namespace ts {
|
||||
const temp = declareLocal();
|
||||
let hasAssignedTemp = false;
|
||||
if (numInitialElements > 0) {
|
||||
const initialElements = visitNodes(elements, visitor, isExpression, 0, numInitialElements);
|
||||
emitAssignment(temp,
|
||||
createArrayLiteral(
|
||||
visitNodes(elements, visitor, isExpression, 0, numInitialElements)
|
||||
leadingElement
|
||||
? [leadingElement, ...initialElements]
|
||||
: initialElements
|
||||
)
|
||||
);
|
||||
leadingElement = undefined;
|
||||
hasAssignedTemp = true;
|
||||
}
|
||||
|
||||
const expressions = reduceLeft(elements, reduceElement, <Expression[]>[], numInitialElements);
|
||||
return hasAssignedTemp
|
||||
? createArrayConcat(temp, [createArrayLiteral(expressions)])
|
||||
: createArrayLiteral(expressions);
|
||||
? createArrayConcat(temp, [createArrayLiteral(expressions, /*location*/ undefined, multiLine)])
|
||||
: createArrayLiteral(leadingElement ? [leadingElement, ...expressions] : expressions, location, multiLine);
|
||||
|
||||
function reduceElement(expressions: Expression[], element: Expression) {
|
||||
if (containsYield(element) && expressions.length > 0) {
|
||||
@@ -990,11 +996,16 @@ namespace ts {
|
||||
hasAssignedTemp
|
||||
? createArrayConcat(
|
||||
temp,
|
||||
[createArrayLiteral(expressions)]
|
||||
[createArrayLiteral(expressions, /*location*/ undefined, multiLine)]
|
||||
)
|
||||
: createArrayLiteral(
|
||||
leadingElement ? [leadingElement, ...expressions] : expressions,
|
||||
/*location*/ undefined,
|
||||
multiLine
|
||||
)
|
||||
: createArrayLiteral(expressions)
|
||||
);
|
||||
hasAssignedTemp = true;
|
||||
leadingElement = undefined;
|
||||
expressions = [];
|
||||
}
|
||||
|
||||
@@ -1101,7 +1112,7 @@ namespace ts {
|
||||
createFunctionApply(
|
||||
cacheExpression(visitNode(target, visitor, isLeftHandSideExpression)),
|
||||
thisArg,
|
||||
visitElements(node.arguments, /*multiLine*/ false),
|
||||
visitElements(node.arguments),
|
||||
/*location*/ node
|
||||
),
|
||||
node
|
||||
@@ -1130,7 +1141,10 @@ namespace ts {
|
||||
createFunctionApply(
|
||||
cacheExpression(visitNode(target, visitor, isExpression)),
|
||||
thisArg,
|
||||
visitElements(node.arguments, /*multiLine*/ false)
|
||||
visitElements(
|
||||
node.arguments,
|
||||
/*leadingElement*/ createVoidZero()
|
||||
)
|
||||
),
|
||||
/*typeArguments*/ undefined,
|
||||
[],
|
||||
@@ -1220,7 +1234,9 @@ namespace ts {
|
||||
|
||||
function transformAndEmitVariableDeclarationList(node: VariableDeclarationList): VariableDeclarationList {
|
||||
for (const variable of node.declarations) {
|
||||
hoistVariableDeclaration(<Identifier>variable.name);
|
||||
const name = getSynthesizedClone(<Identifier>variable.name);
|
||||
setCommentRange(name, variable.name);
|
||||
hoistVariableDeclaration(name);
|
||||
}
|
||||
|
||||
const variables = getInitializedVariables(node);
|
||||
@@ -1273,7 +1289,7 @@ namespace ts {
|
||||
if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) {
|
||||
const endLabel = defineLabel();
|
||||
const elseLabel = node.elseStatement ? defineLabel() : undefined;
|
||||
emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, visitNode(node.expression, visitor, isExpression));
|
||||
emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, visitNode(node.expression, visitor, isExpression), /*location*/ node.expression);
|
||||
transformAndEmitEmbeddedStatement(node.thenStatement);
|
||||
if (node.elseStatement) {
|
||||
emitBreak(endLabel);
|
||||
@@ -2368,7 +2384,7 @@ namespace ts {
|
||||
labelExpressions = [];
|
||||
}
|
||||
|
||||
const expression = <LiteralExpression>createSynthesizedNode(SyntaxKind.NumericLiteral);
|
||||
const expression = createLiteral(-1);
|
||||
if (labelExpressions[label] === undefined) {
|
||||
labelExpressions[label] = [expression];
|
||||
}
|
||||
@@ -2379,7 +2395,7 @@ namespace ts {
|
||||
return expression;
|
||||
}
|
||||
|
||||
return <OmittedExpression>createNode(SyntaxKind.OmittedExpression);
|
||||
return createOmittedExpression();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2584,27 +2600,24 @@ namespace ts {
|
||||
withBlockStack = undefined;
|
||||
|
||||
const buildResult = buildStatements();
|
||||
return createCall(
|
||||
createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"),
|
||||
/*typeArguments*/ undefined,
|
||||
[
|
||||
createThis(),
|
||||
setEmitFlags(
|
||||
createFunctionExpression(
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
[createParameter(state)],
|
||||
/*type*/ undefined,
|
||||
createBlock(
|
||||
buildResult,
|
||||
/*location*/ undefined,
|
||||
/*multiLine*/ buildResult.length > 0
|
||||
)
|
||||
),
|
||||
EmitFlags.ReuseTempVariableScope
|
||||
)
|
||||
]
|
||||
return createGeneratorHelper(
|
||||
context,
|
||||
setEmitFlags(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
[createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)],
|
||||
/*type*/ undefined,
|
||||
createBlock(
|
||||
buildResult,
|
||||
/*location*/ undefined,
|
||||
/*multiLine*/ buildResult.length > 0
|
||||
)
|
||||
),
|
||||
EmitFlags.ReuseTempVariableScope
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2954,12 +2967,15 @@ namespace ts {
|
||||
lastOperationWasAbrupt = true;
|
||||
lastOperationWasCompletion = true;
|
||||
writeStatement(
|
||||
createReturn(
|
||||
createArrayLiteral(expression
|
||||
? [createInstruction(Instruction.Return), expression]
|
||||
: [createInstruction(Instruction.Return)]
|
||||
setEmitFlags(
|
||||
createReturn(
|
||||
createArrayLiteral(expression
|
||||
? [createInstruction(Instruction.Return), expression]
|
||||
: [createInstruction(Instruction.Return)]
|
||||
),
|
||||
operationLocation
|
||||
),
|
||||
operationLocation
|
||||
EmitFlags.NoTokenSourceMaps
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -2973,12 +2989,15 @@ namespace ts {
|
||||
function writeBreak(label: Label, operationLocation: TextRange): void {
|
||||
lastOperationWasAbrupt = true;
|
||||
writeStatement(
|
||||
createReturn(
|
||||
createArrayLiteral([
|
||||
createInstruction(Instruction.Break),
|
||||
createLabel(label)
|
||||
]),
|
||||
operationLocation
|
||||
setEmitFlags(
|
||||
createReturn(
|
||||
createArrayLiteral([
|
||||
createInstruction(Instruction.Break),
|
||||
createLabel(label)
|
||||
]),
|
||||
operationLocation
|
||||
),
|
||||
EmitFlags.NoTokenSourceMaps
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -2992,15 +3011,21 @@ namespace ts {
|
||||
*/
|
||||
function writeBreakWhenTrue(label: Label, condition: Expression, operationLocation: TextRange): void {
|
||||
writeStatement(
|
||||
createIf(
|
||||
condition,
|
||||
createReturn(
|
||||
createArrayLiteral([
|
||||
createInstruction(Instruction.Break),
|
||||
createLabel(label)
|
||||
]),
|
||||
operationLocation
|
||||
)
|
||||
setEmitFlags(
|
||||
createIf(
|
||||
condition,
|
||||
setEmitFlags(
|
||||
createReturn(
|
||||
createArrayLiteral([
|
||||
createInstruction(Instruction.Break),
|
||||
createLabel(label)
|
||||
]),
|
||||
operationLocation
|
||||
),
|
||||
EmitFlags.NoTokenSourceMaps
|
||||
)
|
||||
),
|
||||
EmitFlags.SingleLine
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -3014,15 +3039,21 @@ namespace ts {
|
||||
*/
|
||||
function writeBreakWhenFalse(label: Label, condition: Expression, operationLocation: TextRange): void {
|
||||
writeStatement(
|
||||
createIf(
|
||||
createLogicalNot(condition),
|
||||
createReturn(
|
||||
createArrayLiteral([
|
||||
createInstruction(Instruction.Break),
|
||||
createLabel(label)
|
||||
]),
|
||||
operationLocation
|
||||
)
|
||||
setEmitFlags(
|
||||
createIf(
|
||||
createLogicalNot(condition),
|
||||
setEmitFlags(
|
||||
createReturn(
|
||||
createArrayLiteral([
|
||||
createInstruction(Instruction.Break),
|
||||
createLabel(label)
|
||||
]),
|
||||
operationLocation
|
||||
),
|
||||
EmitFlags.NoTokenSourceMaps
|
||||
)
|
||||
),
|
||||
EmitFlags.SingleLine
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -3036,13 +3067,16 @@ namespace ts {
|
||||
function writeYield(expression: Expression, operationLocation: TextRange): void {
|
||||
lastOperationWasAbrupt = true;
|
||||
writeStatement(
|
||||
createReturn(
|
||||
createArrayLiteral(
|
||||
expression
|
||||
? [createInstruction(Instruction.Yield), expression]
|
||||
: [createInstruction(Instruction.Yield)]
|
||||
setEmitFlags(
|
||||
createReturn(
|
||||
createArrayLiteral(
|
||||
expression
|
||||
? [createInstruction(Instruction.Yield), expression]
|
||||
: [createInstruction(Instruction.Yield)]
|
||||
),
|
||||
operationLocation
|
||||
),
|
||||
operationLocation
|
||||
EmitFlags.NoTokenSourceMaps
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -3056,12 +3090,15 @@ namespace ts {
|
||||
function writeYieldStar(expression: Expression, operationLocation: TextRange): void {
|
||||
lastOperationWasAbrupt = true;
|
||||
writeStatement(
|
||||
createReturn(
|
||||
createArrayLiteral([
|
||||
createInstruction(Instruction.YieldStar),
|
||||
expression
|
||||
]),
|
||||
operationLocation
|
||||
setEmitFlags(
|
||||
createReturn(
|
||||
createArrayLiteral([
|
||||
createInstruction(Instruction.YieldStar),
|
||||
expression
|
||||
]),
|
||||
operationLocation
|
||||
),
|
||||
EmitFlags.NoTokenSourceMaps
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -3080,4 +3117,105 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createGeneratorHelper(context: TransformationContext, body: FunctionExpression) {
|
||||
context.requestEmitHelper(generatorHelper);
|
||||
return createCall(
|
||||
getHelperName("__generator"),
|
||||
/*typeArguments*/ undefined,
|
||||
[createThis(), body]);
|
||||
}
|
||||
|
||||
// The __generator helper is used by down-level transformations to emulate the runtime
|
||||
// semantics of an ES2015 generator function. When called, this helper returns an
|
||||
// object that implements the Iterator protocol, in that it has `next`, `return`, and
|
||||
// `throw` methods that step through the generator when invoked.
|
||||
//
|
||||
// parameters:
|
||||
// thisArg The value to use as the `this` binding for the transformed generator body.
|
||||
// body A function that acts as the transformed generator body.
|
||||
//
|
||||
// variables:
|
||||
// _ Persistent state for the generator that is shared between the helper and the
|
||||
// generator body. The state object has the following members:
|
||||
// sent() - A method that returns or throws the current completion value.
|
||||
// label - The next point at which to resume evaluation of the generator body.
|
||||
// trys - A stack of protected regions (try/catch/finally blocks).
|
||||
// ops - A stack of pending instructions when inside of a finally block.
|
||||
// f A value indicating whether the generator is executing.
|
||||
// y An iterator to delegate for a yield*.
|
||||
// t A temporary variable that holds one of the following values (note that these
|
||||
// cases do not overlap):
|
||||
// - The completion value when resuming from a `yield` or `yield*`.
|
||||
// - The error value for a catch block.
|
||||
// - The current protected region (array of try/catch/finally/end labels).
|
||||
// - The verb (`next`, `throw`, or `return` method) to delegate to the expression
|
||||
// of a `yield*`.
|
||||
// - The result of evaluating the verb delegated to the expression of a `yield*`.
|
||||
//
|
||||
// functions:
|
||||
// verb(n) Creates a bound callback to the `step` function for opcode `n`.
|
||||
// step(op) Evaluates opcodes in a generator body until execution is suspended or
|
||||
// completed.
|
||||
//
|
||||
// The __generator helper understands a limited set of instructions:
|
||||
// 0: next(value?) - Start or resume the generator with the specified value.
|
||||
// 1: throw(error) - Resume the generator with an exception. If the generator is
|
||||
// suspended inside of one or more protected regions, evaluates
|
||||
// any intervening finally blocks between the current label and
|
||||
// the nearest catch block or function boundary. If uncaught, the
|
||||
// exception is thrown to the caller.
|
||||
// 2: return(value?) - Resume the generator as if with a return. If the generator is
|
||||
// suspended inside of one or more protected regions, evaluates any
|
||||
// intervening finally blocks.
|
||||
// 3: break(label) - Jump to the specified label. If the label is outside of the
|
||||
// current protected region, evaluates any intervening finally
|
||||
// blocks.
|
||||
// 4: yield(value?) - Yield execution to the caller with an optional value. When
|
||||
// resumed, the generator will continue at the next label.
|
||||
// 5: yield*(value) - Delegates evaluation to the supplied iterator. When
|
||||
// delegation completes, the generator will continue at the next
|
||||
// label.
|
||||
// 6: catch(error) - Handles an exception thrown from within the generator body. If
|
||||
// the current label is inside of one or more protected regions,
|
||||
// evaluates any intervening finally blocks between the current
|
||||
// label and the nearest catch block or function boundary. If
|
||||
// uncaught, the exception is thrown to the caller.
|
||||
// 7: endfinally - Ends a finally block, resuming the last instruction prior to
|
||||
// entering a finally block.
|
||||
//
|
||||
// For examples of how these are used, see the comments in ./transformers/generators.ts
|
||||
const generatorHelper: EmitHelper = {
|
||||
name: "typescript:generator",
|
||||
scoped: false,
|
||||
priority: 6,
|
||||
text: `
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;
|
||||
return { next: verb(0), "throw": verb(1), "return": verb(2) };
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};`
|
||||
};
|
||||
}
|
||||
|
||||
+270
-270
@@ -1,13 +1,13 @@
|
||||
/// <reference path="../factory.ts" />
|
||||
/// <reference path="../visitor.ts" />
|
||||
/// <reference path="./esnext.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
const entities: Map<number> = createEntitiesMap();
|
||||
|
||||
export function transformJsx(context: TransformationContext) {
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
let currentSourceFile: SourceFile;
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
/**
|
||||
@@ -21,18 +21,18 @@ namespace ts {
|
||||
}
|
||||
|
||||
currentSourceFile = node;
|
||||
node = visitEachChild(node, visitor, context);
|
||||
|
||||
const visited = visitEachChild(node, visitor, context);
|
||||
addEmitHelpers(visited, context.readEmitHelpers());
|
||||
|
||||
currentSourceFile = undefined;
|
||||
return node;
|
||||
return visited;
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
if (node.transformFlags & TransformFlags.Jsx) {
|
||||
if (node.transformFlags & TransformFlags.ContainsJsx) {
|
||||
return visitorWorker(node);
|
||||
}
|
||||
else if (node.transformFlags & TransformFlags.ContainsJsx) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
else {
|
||||
return node;
|
||||
}
|
||||
@@ -50,8 +50,7 @@ namespace ts {
|
||||
return visitJsxExpression(<JsxExpression>node);
|
||||
|
||||
default:
|
||||
Debug.failBadSyntaxKind(node);
|
||||
return undefined;
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,11 +108,14 @@ namespace ts {
|
||||
|
||||
// Either emit one big object literal (no spread attribs), or
|
||||
// a call to the __assign helper.
|
||||
objectProperties = singleOrUndefined(segments)
|
||||
|| createAssignHelper(currentSourceFile.externalHelpersModuleName, segments);
|
||||
objectProperties = singleOrUndefined(segments);
|
||||
if (!objectProperties) {
|
||||
objectProperties = createAssignHelper(context, segments);
|
||||
}
|
||||
}
|
||||
|
||||
const element = createReactCreateElement(
|
||||
const element = createExpressionForJsxElement(
|
||||
context.getEmitResolver().getJsxFactoryEntity(),
|
||||
compilerOptions.reactNamespace,
|
||||
tagName,
|
||||
objectProperties,
|
||||
@@ -275,261 +277,259 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function createEntitiesMap(): Map<number> {
|
||||
return createMap<number>({
|
||||
"quot": 0x0022,
|
||||
"amp": 0x0026,
|
||||
"apos": 0x0027,
|
||||
"lt": 0x003C,
|
||||
"gt": 0x003E,
|
||||
"nbsp": 0x00A0,
|
||||
"iexcl": 0x00A1,
|
||||
"cent": 0x00A2,
|
||||
"pound": 0x00A3,
|
||||
"curren": 0x00A4,
|
||||
"yen": 0x00A5,
|
||||
"brvbar": 0x00A6,
|
||||
"sect": 0x00A7,
|
||||
"uml": 0x00A8,
|
||||
"copy": 0x00A9,
|
||||
"ordf": 0x00AA,
|
||||
"laquo": 0x00AB,
|
||||
"not": 0x00AC,
|
||||
"shy": 0x00AD,
|
||||
"reg": 0x00AE,
|
||||
"macr": 0x00AF,
|
||||
"deg": 0x00B0,
|
||||
"plusmn": 0x00B1,
|
||||
"sup2": 0x00B2,
|
||||
"sup3": 0x00B3,
|
||||
"acute": 0x00B4,
|
||||
"micro": 0x00B5,
|
||||
"para": 0x00B6,
|
||||
"middot": 0x00B7,
|
||||
"cedil": 0x00B8,
|
||||
"sup1": 0x00B9,
|
||||
"ordm": 0x00BA,
|
||||
"raquo": 0x00BB,
|
||||
"frac14": 0x00BC,
|
||||
"frac12": 0x00BD,
|
||||
"frac34": 0x00BE,
|
||||
"iquest": 0x00BF,
|
||||
"Agrave": 0x00C0,
|
||||
"Aacute": 0x00C1,
|
||||
"Acirc": 0x00C2,
|
||||
"Atilde": 0x00C3,
|
||||
"Auml": 0x00C4,
|
||||
"Aring": 0x00C5,
|
||||
"AElig": 0x00C6,
|
||||
"Ccedil": 0x00C7,
|
||||
"Egrave": 0x00C8,
|
||||
"Eacute": 0x00C9,
|
||||
"Ecirc": 0x00CA,
|
||||
"Euml": 0x00CB,
|
||||
"Igrave": 0x00CC,
|
||||
"Iacute": 0x00CD,
|
||||
"Icirc": 0x00CE,
|
||||
"Iuml": 0x00CF,
|
||||
"ETH": 0x00D0,
|
||||
"Ntilde": 0x00D1,
|
||||
"Ograve": 0x00D2,
|
||||
"Oacute": 0x00D3,
|
||||
"Ocirc": 0x00D4,
|
||||
"Otilde": 0x00D5,
|
||||
"Ouml": 0x00D6,
|
||||
"times": 0x00D7,
|
||||
"Oslash": 0x00D8,
|
||||
"Ugrave": 0x00D9,
|
||||
"Uacute": 0x00DA,
|
||||
"Ucirc": 0x00DB,
|
||||
"Uuml": 0x00DC,
|
||||
"Yacute": 0x00DD,
|
||||
"THORN": 0x00DE,
|
||||
"szlig": 0x00DF,
|
||||
"agrave": 0x00E0,
|
||||
"aacute": 0x00E1,
|
||||
"acirc": 0x00E2,
|
||||
"atilde": 0x00E3,
|
||||
"auml": 0x00E4,
|
||||
"aring": 0x00E5,
|
||||
"aelig": 0x00E6,
|
||||
"ccedil": 0x00E7,
|
||||
"egrave": 0x00E8,
|
||||
"eacute": 0x00E9,
|
||||
"ecirc": 0x00EA,
|
||||
"euml": 0x00EB,
|
||||
"igrave": 0x00EC,
|
||||
"iacute": 0x00ED,
|
||||
"icirc": 0x00EE,
|
||||
"iuml": 0x00EF,
|
||||
"eth": 0x00F0,
|
||||
"ntilde": 0x00F1,
|
||||
"ograve": 0x00F2,
|
||||
"oacute": 0x00F3,
|
||||
"ocirc": 0x00F4,
|
||||
"otilde": 0x00F5,
|
||||
"ouml": 0x00F6,
|
||||
"divide": 0x00F7,
|
||||
"oslash": 0x00F8,
|
||||
"ugrave": 0x00F9,
|
||||
"uacute": 0x00FA,
|
||||
"ucirc": 0x00FB,
|
||||
"uuml": 0x00FC,
|
||||
"yacute": 0x00FD,
|
||||
"thorn": 0x00FE,
|
||||
"yuml": 0x00FF,
|
||||
"OElig": 0x0152,
|
||||
"oelig": 0x0153,
|
||||
"Scaron": 0x0160,
|
||||
"scaron": 0x0161,
|
||||
"Yuml": 0x0178,
|
||||
"fnof": 0x0192,
|
||||
"circ": 0x02C6,
|
||||
"tilde": 0x02DC,
|
||||
"Alpha": 0x0391,
|
||||
"Beta": 0x0392,
|
||||
"Gamma": 0x0393,
|
||||
"Delta": 0x0394,
|
||||
"Epsilon": 0x0395,
|
||||
"Zeta": 0x0396,
|
||||
"Eta": 0x0397,
|
||||
"Theta": 0x0398,
|
||||
"Iota": 0x0399,
|
||||
"Kappa": 0x039A,
|
||||
"Lambda": 0x039B,
|
||||
"Mu": 0x039C,
|
||||
"Nu": 0x039D,
|
||||
"Xi": 0x039E,
|
||||
"Omicron": 0x039F,
|
||||
"Pi": 0x03A0,
|
||||
"Rho": 0x03A1,
|
||||
"Sigma": 0x03A3,
|
||||
"Tau": 0x03A4,
|
||||
"Upsilon": 0x03A5,
|
||||
"Phi": 0x03A6,
|
||||
"Chi": 0x03A7,
|
||||
"Psi": 0x03A8,
|
||||
"Omega": 0x03A9,
|
||||
"alpha": 0x03B1,
|
||||
"beta": 0x03B2,
|
||||
"gamma": 0x03B3,
|
||||
"delta": 0x03B4,
|
||||
"epsilon": 0x03B5,
|
||||
"zeta": 0x03B6,
|
||||
"eta": 0x03B7,
|
||||
"theta": 0x03B8,
|
||||
"iota": 0x03B9,
|
||||
"kappa": 0x03BA,
|
||||
"lambda": 0x03BB,
|
||||
"mu": 0x03BC,
|
||||
"nu": 0x03BD,
|
||||
"xi": 0x03BE,
|
||||
"omicron": 0x03BF,
|
||||
"pi": 0x03C0,
|
||||
"rho": 0x03C1,
|
||||
"sigmaf": 0x03C2,
|
||||
"sigma": 0x03C3,
|
||||
"tau": 0x03C4,
|
||||
"upsilon": 0x03C5,
|
||||
"phi": 0x03C6,
|
||||
"chi": 0x03C7,
|
||||
"psi": 0x03C8,
|
||||
"omega": 0x03C9,
|
||||
"thetasym": 0x03D1,
|
||||
"upsih": 0x03D2,
|
||||
"piv": 0x03D6,
|
||||
"ensp": 0x2002,
|
||||
"emsp": 0x2003,
|
||||
"thinsp": 0x2009,
|
||||
"zwnj": 0x200C,
|
||||
"zwj": 0x200D,
|
||||
"lrm": 0x200E,
|
||||
"rlm": 0x200F,
|
||||
"ndash": 0x2013,
|
||||
"mdash": 0x2014,
|
||||
"lsquo": 0x2018,
|
||||
"rsquo": 0x2019,
|
||||
"sbquo": 0x201A,
|
||||
"ldquo": 0x201C,
|
||||
"rdquo": 0x201D,
|
||||
"bdquo": 0x201E,
|
||||
"dagger": 0x2020,
|
||||
"Dagger": 0x2021,
|
||||
"bull": 0x2022,
|
||||
"hellip": 0x2026,
|
||||
"permil": 0x2030,
|
||||
"prime": 0x2032,
|
||||
"Prime": 0x2033,
|
||||
"lsaquo": 0x2039,
|
||||
"rsaquo": 0x203A,
|
||||
"oline": 0x203E,
|
||||
"frasl": 0x2044,
|
||||
"euro": 0x20AC,
|
||||
"image": 0x2111,
|
||||
"weierp": 0x2118,
|
||||
"real": 0x211C,
|
||||
"trade": 0x2122,
|
||||
"alefsym": 0x2135,
|
||||
"larr": 0x2190,
|
||||
"uarr": 0x2191,
|
||||
"rarr": 0x2192,
|
||||
"darr": 0x2193,
|
||||
"harr": 0x2194,
|
||||
"crarr": 0x21B5,
|
||||
"lArr": 0x21D0,
|
||||
"uArr": 0x21D1,
|
||||
"rArr": 0x21D2,
|
||||
"dArr": 0x21D3,
|
||||
"hArr": 0x21D4,
|
||||
"forall": 0x2200,
|
||||
"part": 0x2202,
|
||||
"exist": 0x2203,
|
||||
"empty": 0x2205,
|
||||
"nabla": 0x2207,
|
||||
"isin": 0x2208,
|
||||
"notin": 0x2209,
|
||||
"ni": 0x220B,
|
||||
"prod": 0x220F,
|
||||
"sum": 0x2211,
|
||||
"minus": 0x2212,
|
||||
"lowast": 0x2217,
|
||||
"radic": 0x221A,
|
||||
"prop": 0x221D,
|
||||
"infin": 0x221E,
|
||||
"ang": 0x2220,
|
||||
"and": 0x2227,
|
||||
"or": 0x2228,
|
||||
"cap": 0x2229,
|
||||
"cup": 0x222A,
|
||||
"int": 0x222B,
|
||||
"there4": 0x2234,
|
||||
"sim": 0x223C,
|
||||
"cong": 0x2245,
|
||||
"asymp": 0x2248,
|
||||
"ne": 0x2260,
|
||||
"equiv": 0x2261,
|
||||
"le": 0x2264,
|
||||
"ge": 0x2265,
|
||||
"sub": 0x2282,
|
||||
"sup": 0x2283,
|
||||
"nsub": 0x2284,
|
||||
"sube": 0x2286,
|
||||
"supe": 0x2287,
|
||||
"oplus": 0x2295,
|
||||
"otimes": 0x2297,
|
||||
"perp": 0x22A5,
|
||||
"sdot": 0x22C5,
|
||||
"lceil": 0x2308,
|
||||
"rceil": 0x2309,
|
||||
"lfloor": 0x230A,
|
||||
"rfloor": 0x230B,
|
||||
"lang": 0x2329,
|
||||
"rang": 0x232A,
|
||||
"loz": 0x25CA,
|
||||
"spades": 0x2660,
|
||||
"clubs": 0x2663,
|
||||
"hearts": 0x2665,
|
||||
"diams": 0x2666
|
||||
});
|
||||
}
|
||||
const entities = createMap<number>({
|
||||
"quot": 0x0022,
|
||||
"amp": 0x0026,
|
||||
"apos": 0x0027,
|
||||
"lt": 0x003C,
|
||||
"gt": 0x003E,
|
||||
"nbsp": 0x00A0,
|
||||
"iexcl": 0x00A1,
|
||||
"cent": 0x00A2,
|
||||
"pound": 0x00A3,
|
||||
"curren": 0x00A4,
|
||||
"yen": 0x00A5,
|
||||
"brvbar": 0x00A6,
|
||||
"sect": 0x00A7,
|
||||
"uml": 0x00A8,
|
||||
"copy": 0x00A9,
|
||||
"ordf": 0x00AA,
|
||||
"laquo": 0x00AB,
|
||||
"not": 0x00AC,
|
||||
"shy": 0x00AD,
|
||||
"reg": 0x00AE,
|
||||
"macr": 0x00AF,
|
||||
"deg": 0x00B0,
|
||||
"plusmn": 0x00B1,
|
||||
"sup2": 0x00B2,
|
||||
"sup3": 0x00B3,
|
||||
"acute": 0x00B4,
|
||||
"micro": 0x00B5,
|
||||
"para": 0x00B6,
|
||||
"middot": 0x00B7,
|
||||
"cedil": 0x00B8,
|
||||
"sup1": 0x00B9,
|
||||
"ordm": 0x00BA,
|
||||
"raquo": 0x00BB,
|
||||
"frac14": 0x00BC,
|
||||
"frac12": 0x00BD,
|
||||
"frac34": 0x00BE,
|
||||
"iquest": 0x00BF,
|
||||
"Agrave": 0x00C0,
|
||||
"Aacute": 0x00C1,
|
||||
"Acirc": 0x00C2,
|
||||
"Atilde": 0x00C3,
|
||||
"Auml": 0x00C4,
|
||||
"Aring": 0x00C5,
|
||||
"AElig": 0x00C6,
|
||||
"Ccedil": 0x00C7,
|
||||
"Egrave": 0x00C8,
|
||||
"Eacute": 0x00C9,
|
||||
"Ecirc": 0x00CA,
|
||||
"Euml": 0x00CB,
|
||||
"Igrave": 0x00CC,
|
||||
"Iacute": 0x00CD,
|
||||
"Icirc": 0x00CE,
|
||||
"Iuml": 0x00CF,
|
||||
"ETH": 0x00D0,
|
||||
"Ntilde": 0x00D1,
|
||||
"Ograve": 0x00D2,
|
||||
"Oacute": 0x00D3,
|
||||
"Ocirc": 0x00D4,
|
||||
"Otilde": 0x00D5,
|
||||
"Ouml": 0x00D6,
|
||||
"times": 0x00D7,
|
||||
"Oslash": 0x00D8,
|
||||
"Ugrave": 0x00D9,
|
||||
"Uacute": 0x00DA,
|
||||
"Ucirc": 0x00DB,
|
||||
"Uuml": 0x00DC,
|
||||
"Yacute": 0x00DD,
|
||||
"THORN": 0x00DE,
|
||||
"szlig": 0x00DF,
|
||||
"agrave": 0x00E0,
|
||||
"aacute": 0x00E1,
|
||||
"acirc": 0x00E2,
|
||||
"atilde": 0x00E3,
|
||||
"auml": 0x00E4,
|
||||
"aring": 0x00E5,
|
||||
"aelig": 0x00E6,
|
||||
"ccedil": 0x00E7,
|
||||
"egrave": 0x00E8,
|
||||
"eacute": 0x00E9,
|
||||
"ecirc": 0x00EA,
|
||||
"euml": 0x00EB,
|
||||
"igrave": 0x00EC,
|
||||
"iacute": 0x00ED,
|
||||
"icirc": 0x00EE,
|
||||
"iuml": 0x00EF,
|
||||
"eth": 0x00F0,
|
||||
"ntilde": 0x00F1,
|
||||
"ograve": 0x00F2,
|
||||
"oacute": 0x00F3,
|
||||
"ocirc": 0x00F4,
|
||||
"otilde": 0x00F5,
|
||||
"ouml": 0x00F6,
|
||||
"divide": 0x00F7,
|
||||
"oslash": 0x00F8,
|
||||
"ugrave": 0x00F9,
|
||||
"uacute": 0x00FA,
|
||||
"ucirc": 0x00FB,
|
||||
"uuml": 0x00FC,
|
||||
"yacute": 0x00FD,
|
||||
"thorn": 0x00FE,
|
||||
"yuml": 0x00FF,
|
||||
"OElig": 0x0152,
|
||||
"oelig": 0x0153,
|
||||
"Scaron": 0x0160,
|
||||
"scaron": 0x0161,
|
||||
"Yuml": 0x0178,
|
||||
"fnof": 0x0192,
|
||||
"circ": 0x02C6,
|
||||
"tilde": 0x02DC,
|
||||
"Alpha": 0x0391,
|
||||
"Beta": 0x0392,
|
||||
"Gamma": 0x0393,
|
||||
"Delta": 0x0394,
|
||||
"Epsilon": 0x0395,
|
||||
"Zeta": 0x0396,
|
||||
"Eta": 0x0397,
|
||||
"Theta": 0x0398,
|
||||
"Iota": 0x0399,
|
||||
"Kappa": 0x039A,
|
||||
"Lambda": 0x039B,
|
||||
"Mu": 0x039C,
|
||||
"Nu": 0x039D,
|
||||
"Xi": 0x039E,
|
||||
"Omicron": 0x039F,
|
||||
"Pi": 0x03A0,
|
||||
"Rho": 0x03A1,
|
||||
"Sigma": 0x03A3,
|
||||
"Tau": 0x03A4,
|
||||
"Upsilon": 0x03A5,
|
||||
"Phi": 0x03A6,
|
||||
"Chi": 0x03A7,
|
||||
"Psi": 0x03A8,
|
||||
"Omega": 0x03A9,
|
||||
"alpha": 0x03B1,
|
||||
"beta": 0x03B2,
|
||||
"gamma": 0x03B3,
|
||||
"delta": 0x03B4,
|
||||
"epsilon": 0x03B5,
|
||||
"zeta": 0x03B6,
|
||||
"eta": 0x03B7,
|
||||
"theta": 0x03B8,
|
||||
"iota": 0x03B9,
|
||||
"kappa": 0x03BA,
|
||||
"lambda": 0x03BB,
|
||||
"mu": 0x03BC,
|
||||
"nu": 0x03BD,
|
||||
"xi": 0x03BE,
|
||||
"omicron": 0x03BF,
|
||||
"pi": 0x03C0,
|
||||
"rho": 0x03C1,
|
||||
"sigmaf": 0x03C2,
|
||||
"sigma": 0x03C3,
|
||||
"tau": 0x03C4,
|
||||
"upsilon": 0x03C5,
|
||||
"phi": 0x03C6,
|
||||
"chi": 0x03C7,
|
||||
"psi": 0x03C8,
|
||||
"omega": 0x03C9,
|
||||
"thetasym": 0x03D1,
|
||||
"upsih": 0x03D2,
|
||||
"piv": 0x03D6,
|
||||
"ensp": 0x2002,
|
||||
"emsp": 0x2003,
|
||||
"thinsp": 0x2009,
|
||||
"zwnj": 0x200C,
|
||||
"zwj": 0x200D,
|
||||
"lrm": 0x200E,
|
||||
"rlm": 0x200F,
|
||||
"ndash": 0x2013,
|
||||
"mdash": 0x2014,
|
||||
"lsquo": 0x2018,
|
||||
"rsquo": 0x2019,
|
||||
"sbquo": 0x201A,
|
||||
"ldquo": 0x201C,
|
||||
"rdquo": 0x201D,
|
||||
"bdquo": 0x201E,
|
||||
"dagger": 0x2020,
|
||||
"Dagger": 0x2021,
|
||||
"bull": 0x2022,
|
||||
"hellip": 0x2026,
|
||||
"permil": 0x2030,
|
||||
"prime": 0x2032,
|
||||
"Prime": 0x2033,
|
||||
"lsaquo": 0x2039,
|
||||
"rsaquo": 0x203A,
|
||||
"oline": 0x203E,
|
||||
"frasl": 0x2044,
|
||||
"euro": 0x20AC,
|
||||
"image": 0x2111,
|
||||
"weierp": 0x2118,
|
||||
"real": 0x211C,
|
||||
"trade": 0x2122,
|
||||
"alefsym": 0x2135,
|
||||
"larr": 0x2190,
|
||||
"uarr": 0x2191,
|
||||
"rarr": 0x2192,
|
||||
"darr": 0x2193,
|
||||
"harr": 0x2194,
|
||||
"crarr": 0x21B5,
|
||||
"lArr": 0x21D0,
|
||||
"uArr": 0x21D1,
|
||||
"rArr": 0x21D2,
|
||||
"dArr": 0x21D3,
|
||||
"hArr": 0x21D4,
|
||||
"forall": 0x2200,
|
||||
"part": 0x2202,
|
||||
"exist": 0x2203,
|
||||
"empty": 0x2205,
|
||||
"nabla": 0x2207,
|
||||
"isin": 0x2208,
|
||||
"notin": 0x2209,
|
||||
"ni": 0x220B,
|
||||
"prod": 0x220F,
|
||||
"sum": 0x2211,
|
||||
"minus": 0x2212,
|
||||
"lowast": 0x2217,
|
||||
"radic": 0x221A,
|
||||
"prop": 0x221D,
|
||||
"infin": 0x221E,
|
||||
"ang": 0x2220,
|
||||
"and": 0x2227,
|
||||
"or": 0x2228,
|
||||
"cap": 0x2229,
|
||||
"cup": 0x222A,
|
||||
"int": 0x222B,
|
||||
"there4": 0x2234,
|
||||
"sim": 0x223C,
|
||||
"cong": 0x2245,
|
||||
"asymp": 0x2248,
|
||||
"ne": 0x2260,
|
||||
"equiv": 0x2261,
|
||||
"le": 0x2264,
|
||||
"ge": 0x2265,
|
||||
"sub": 0x2282,
|
||||
"sup": 0x2283,
|
||||
"nsub": 0x2284,
|
||||
"sube": 0x2286,
|
||||
"supe": 0x2287,
|
||||
"oplus": 0x2295,
|
||||
"otimes": 0x2297,
|
||||
"perp": 0x22A5,
|
||||
"sdot": 0x22C5,
|
||||
"lceil": 0x2308,
|
||||
"rceil": 0x2309,
|
||||
"lfloor": 0x230A,
|
||||
"rfloor": 0x230B,
|
||||
"lang": 0x2329,
|
||||
"rang": 0x232A,
|
||||
"loz": 0x25CA,
|
||||
"spades": 0x2660,
|
||||
"clubs": 0x2663,
|
||||
"hearts": 0x2665,
|
||||
"diams": 0x2666
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/// <reference path="../../factory.ts" />
|
||||
/// <reference path="../../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function transformES2015Module(context: TransformationContext) {
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const previousOnEmitNode = context.onEmitNode;
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
context.onEmitNode = onEmitNode;
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
context.enableEmitNotification(SyntaxKind.SourceFile);
|
||||
context.enableSubstitution(SyntaxKind.Identifier);
|
||||
|
||||
let currentSourceFile: SourceFile;
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
const externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions);
|
||||
if (externalHelpersModuleName) {
|
||||
const statements: Statement[] = [];
|
||||
const statementOffset = addPrologueDirectives(statements, node.statements);
|
||||
append(statements,
|
||||
createImportDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)),
|
||||
createLiteral(externalHelpersModuleNameText)
|
||||
)
|
||||
);
|
||||
|
||||
addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset));
|
||||
return updateSourceFileNode(
|
||||
node,
|
||||
createNodeArray(statements, node.statements));
|
||||
}
|
||||
else {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
// Elide `import=` as it is not legal with --module ES6
|
||||
return undefined;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return visitExportAssignment(<ExportAssignment>node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): VisitResult<ExportAssignment> {
|
||||
// Elide `export=` as it is not legal with --module ES6
|
||||
return node.isExportEquals ? undefined : node;
|
||||
}
|
||||
|
||||
//
|
||||
// Emit Notification
|
||||
//
|
||||
|
||||
/**
|
||||
* Hook for node emit.
|
||||
*
|
||||
* @param emitContext A context hint for the emitter.
|
||||
* @param node The node to emit.
|
||||
* @param emit A callback used to emit the node in the printer.
|
||||
*/
|
||||
function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void {
|
||||
if (isSourceFile(node)) {
|
||||
currentSourceFile = node;
|
||||
previousOnEmitNode(emitContext, node, emitCallback);
|
||||
currentSourceFile = undefined;
|
||||
}
|
||||
else {
|
||||
previousOnEmitNode(emitContext, node, emitCallback);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Substitutions
|
||||
//
|
||||
|
||||
/**
|
||||
* Hooks node substitutions.
|
||||
*
|
||||
* @param emitContext A context hint for the emitter.
|
||||
* @param node The node to substitute.
|
||||
*/
|
||||
function onSubstituteNode(emitContext: EmitContext, node: Node) {
|
||||
node = previousOnSubstituteNode(emitContext, node);
|
||||
if (isIdentifier(node) && emitContext === EmitContext.Expression) {
|
||||
return substituteExpressionIdentifier(node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function substituteExpressionIdentifier(node: Identifier): Expression {
|
||||
if (getEmitFlags(node) & EmitFlags.HelperName) {
|
||||
const externalHelpersModuleName = getExternalHelpersModuleName(currentSourceFile);
|
||||
if (externalHelpersModuleName) {
|
||||
return createPropertyAccess(externalHelpersModuleName, node);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/// <reference path="../../factory.ts" />
|
||||
/// <reference path="../../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function transformES6Module(context: TransformationContext) {
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const resolver = context.getEmitResolver();
|
||||
|
||||
let currentSourceFile: SourceFile;
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
currentSourceFile = node;
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return visitImportDeclaration(<ImportDeclaration>node);
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return visitImportEqualsDeclaration(<ImportEqualsDeclaration>node);
|
||||
case SyntaxKind.ImportClause:
|
||||
return visitImportClause(<ImportClause>node);
|
||||
case SyntaxKind.NamedImports:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return visitNamedBindings(<NamedImportBindings>node);
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
return visitImportSpecifier(<ImportSpecifier>node);
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return visitExportAssignment(<ExportAssignment>node);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return visitExportDeclaration(<ExportDeclaration>node);
|
||||
case SyntaxKind.NamedExports:
|
||||
return visitNamedExports(<NamedExports>node);
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return visitExportSpecifier(<ExportSpecifier>node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): ExportAssignment {
|
||||
if (node.isExportEquals) {
|
||||
return undefined; // do not emit export equals for ES6
|
||||
}
|
||||
const original = getOriginalNode(node);
|
||||
return nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined;
|
||||
}
|
||||
|
||||
function visitExportDeclaration(node: ExportDeclaration): ExportDeclaration {
|
||||
if (!node.exportClause) {
|
||||
return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined;
|
||||
}
|
||||
if (!resolver.isValueAliasDeclaration(node)) {
|
||||
return undefined;
|
||||
}
|
||||
const newExportClause = visitNode(node.exportClause, visitor, isNamedExports, /*optional*/ true);
|
||||
if (node.exportClause === newExportClause) {
|
||||
return node;
|
||||
}
|
||||
return newExportClause
|
||||
? createExportDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
newExportClause,
|
||||
node.moduleSpecifier)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function visitNamedExports(node: NamedExports): NamedExports {
|
||||
const newExports = visitNodes(node.elements, visitor, isExportSpecifier);
|
||||
if (node.elements === newExports) {
|
||||
return node;
|
||||
}
|
||||
return newExports.length ? createNamedExports(newExports) : undefined;
|
||||
}
|
||||
|
||||
function visitExportSpecifier(node: ExportSpecifier): ExportSpecifier {
|
||||
return resolver.isValueAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
|
||||
function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): ImportEqualsDeclaration {
|
||||
return !isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
|
||||
function visitImportDeclaration(node: ImportDeclaration) {
|
||||
if (node.importClause) {
|
||||
const newImportClause = visitNode(node.importClause, visitor, isImportClause);
|
||||
if (!newImportClause.name && !newImportClause.namedBindings) {
|
||||
return undefined;
|
||||
}
|
||||
else if (newImportClause !== node.importClause) {
|
||||
return createImportDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
newImportClause,
|
||||
node.moduleSpecifier);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitImportClause(node: ImportClause): ImportClause {
|
||||
let newDefaultImport = node.name;
|
||||
if (!resolver.isReferencedAliasDeclaration(node)) {
|
||||
newDefaultImport = undefined;
|
||||
}
|
||||
const newNamedBindings = visitNode(node.namedBindings, visitor, isNamedImportBindings, /*optional*/ true);
|
||||
return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings
|
||||
? createImportClause(newDefaultImport, newNamedBindings)
|
||||
: node;
|
||||
}
|
||||
|
||||
function visitNamedBindings(node: NamedImportBindings): VisitResult<NamedImportBindings> {
|
||||
if (node.kind === SyntaxKind.NamespaceImport) {
|
||||
return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
else {
|
||||
const newNamedImportElements = visitNodes((<NamedImports>node).elements, visitor, isImportSpecifier);
|
||||
if (!newNamedImportElements || newNamedImportElements.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
if (newNamedImportElements === (<NamedImports>node).elements) {
|
||||
return node;
|
||||
}
|
||||
return createNamedImports(newNamedImportElements);
|
||||
}
|
||||
}
|
||||
|
||||
function visitImportSpecifier(node: ImportSpecifier) {
|
||||
return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+723
-892
File diff suppressed because it is too large
Load Diff
+21
-73
@@ -29,7 +29,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function reportEmittedFiles(files: string[], host: CompilerHost): void {
|
||||
function reportEmittedFiles(files: string[]): void {
|
||||
if (!files || files.length == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -43,66 +43,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the locale is in the appropriate format,
|
||||
* and if it is, attempts to set the appropriate language.
|
||||
*/
|
||||
function validateLocaleAndSetLanguage(locale: string, errors: Diagnostic[]): boolean {
|
||||
const matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
|
||||
if (!matchResult) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
|
||||
return false;
|
||||
}
|
||||
|
||||
const language = matchResult[1];
|
||||
const territory = matchResult[3];
|
||||
|
||||
// First try the entire locale, then fall back to just language if that's all we have.
|
||||
// Either ways do not fail, and fallback to the English diagnostic strings.
|
||||
if (!trySetLanguageAndTerritory(language, territory, errors)) {
|
||||
trySetLanguageAndTerritory(language, undefined, errors);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function trySetLanguageAndTerritory(language: string, territory: string, errors: Diagnostic[]): boolean {
|
||||
const compilerFilePath = normalizePath(sys.getExecutingFilePath());
|
||||
const containingDirectoryPath = getDirectoryPath(compilerFilePath);
|
||||
|
||||
let filePath = combinePaths(containingDirectoryPath, language);
|
||||
|
||||
if (territory) {
|
||||
filePath = filePath + "-" + territory;
|
||||
}
|
||||
|
||||
filePath = sys.resolvePath(combinePaths(filePath, "diagnosticMessages.generated.json"));
|
||||
|
||||
if (!sys.fileExists(filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Add codePage support for readFile?
|
||||
let fileContents = "";
|
||||
try {
|
||||
fileContents = sys.readFile(filePath);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath));
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
ts.localizedDiagnosticMessages = JSON.parse(fileContents);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Corrupted_locale_file_0, filePath));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function countLines(program: Program): number {
|
||||
let count = 0;
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
@@ -111,7 +51,7 @@ namespace ts {
|
||||
return count;
|
||||
}
|
||||
|
||||
function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string {
|
||||
function getDiagnosticText(_message: DiagnosticMessage, ..._args: any[]): string {
|
||||
const diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
return <string>diagnostic.messageText;
|
||||
}
|
||||
@@ -250,8 +190,8 @@ namespace ts {
|
||||
let compilerOptions: CompilerOptions; // Compiler options for compilation
|
||||
let compilerHost: CompilerHost; // Compiler host
|
||||
let hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
|
||||
let timerHandleForRecompilation: number; // Handle for 0.25s wait timer to trigger recompilation
|
||||
let timerHandleForDirectoryChanges: number; // Handle for 0.25s wait timer to trigger directory change handler
|
||||
let timerHandleForRecompilation: any; // Handle for 0.25s wait timer to trigger recompilation
|
||||
let timerHandleForDirectoryChanges: any; // Handle for 0.25s wait timer to trigger directory change handler
|
||||
|
||||
// This map stores and reuses results of fileExists check that happen inside 'createProgram'
|
||||
// This allows to save time in module resolution heavy scenarios when existence of the same file might be checked multiple times.
|
||||
@@ -263,7 +203,7 @@ namespace ts {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"), /* host */ undefined);
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
}
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
|
||||
}
|
||||
|
||||
// If there are any errors due to command line parsing and/or
|
||||
@@ -456,7 +396,7 @@ namespace ts {
|
||||
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
if (sourceFile && isWatchSet(compilerOptions) && sys.watchFile) {
|
||||
// Attach a file watcher
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (_fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
|
||||
}
|
||||
return sourceFile;
|
||||
}
|
||||
@@ -503,10 +443,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function startTimerForHandlingDirectoryChanges() {
|
||||
if (timerHandleForDirectoryChanges) {
|
||||
clearTimeout(timerHandleForDirectoryChanges);
|
||||
if (!sys.setTimeout || !sys.clearTimeout) {
|
||||
return;
|
||||
}
|
||||
timerHandleForDirectoryChanges = setTimeout(directoryChangeHandler, 250);
|
||||
|
||||
if (timerHandleForDirectoryChanges) {
|
||||
sys.clearTimeout(timerHandleForDirectoryChanges);
|
||||
}
|
||||
timerHandleForDirectoryChanges = sys.setTimeout(directoryChangeHandler, 250);
|
||||
}
|
||||
|
||||
function directoryChangeHandler() {
|
||||
@@ -525,10 +469,14 @@ namespace ts {
|
||||
// operations (such as saving all modified files in an editor) a chance to complete before we kick
|
||||
// off a new compilation.
|
||||
function startTimerForRecompilation() {
|
||||
if (timerHandleForRecompilation) {
|
||||
clearTimeout(timerHandleForRecompilation);
|
||||
if (!sys.setTimeout || !sys.clearTimeout) {
|
||||
return;
|
||||
}
|
||||
timerHandleForRecompilation = setTimeout(recompile, 250);
|
||||
|
||||
if (timerHandleForRecompilation) {
|
||||
sys.clearTimeout(timerHandleForRecompilation);
|
||||
}
|
||||
timerHandleForRecompilation = sys.setTimeout(recompile, 250);
|
||||
}
|
||||
|
||||
function recompile() {
|
||||
@@ -617,7 +565,7 @@ namespace ts {
|
||||
|
||||
reportDiagnostics(sortAndDeduplicateDiagnostics(diagnostics), compilerHost);
|
||||
|
||||
reportEmittedFiles(emitOutput.emittedFiles, compilerHost);
|
||||
reportEmittedFiles(emitOutput.emittedFiles);
|
||||
|
||||
if (emitOutput.emitSkipped && diagnostics.length > 0) {
|
||||
// If the emitter didn't emit anything, then pass that value along.
|
||||
|
||||
@@ -8,7 +8,11 @@
|
||||
"outFile": "../../built/local/tsc.js",
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"stripInternal": true
|
||||
"stripInternal": true,
|
||||
"target": "es5",
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"types": [ ]
|
||||
},
|
||||
"files": [
|
||||
"core.ts",
|
||||
@@ -24,13 +28,17 @@
|
||||
"visitor.ts",
|
||||
"transformers/ts.ts",
|
||||
"transformers/jsx.ts",
|
||||
"transformers/es7.ts",
|
||||
"transformers/es6.ts",
|
||||
"transformers/esnext.ts",
|
||||
"transformers/es2017.ts",
|
||||
"transformers/es2016.ts",
|
||||
"transformers/es2015.ts",
|
||||
"transformers/es5.ts",
|
||||
"transformers/generators.ts",
|
||||
"transformers/es5.ts",
|
||||
"transformers/destructuring.ts",
|
||||
"transformers/module/module.ts",
|
||||
"transformers/module/system.ts",
|
||||
"transformers/module/es6.ts",
|
||||
"transformers/module/es2015.ts",
|
||||
"transformer.ts",
|
||||
"comments.ts",
|
||||
"sourcemap.ts",
|
||||
|
||||
+544
-154
File diff suppressed because it is too large
Load Diff
+512
-382
File diff suppressed because it is too large
Load Diff
+329
-280
File diff suppressed because it is too large
Load Diff
@@ -170,7 +170,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
});
|
||||
|
||||
it("Correct Sourcemap output for " + fileName, () => {
|
||||
Harness.Compiler.doSourcemapBaseline(justName, options, result);
|
||||
Harness.Compiler.doSourcemapBaseline(justName, options, result, harnessSettings);
|
||||
});
|
||||
|
||||
it("Correct type/symbol baselines for " + fileName, () => {
|
||||
|
||||
+132
-201
@@ -47,19 +47,6 @@ namespace FourSlash {
|
||||
ranges: Range[];
|
||||
}
|
||||
|
||||
interface MemberListData {
|
||||
result: {
|
||||
maybeInaccurate: boolean;
|
||||
isMemberCompletion: boolean;
|
||||
entries: {
|
||||
name: string;
|
||||
type: string;
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
}[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface Marker {
|
||||
fileName: string;
|
||||
position: number;
|
||||
@@ -178,15 +165,9 @@ namespace FourSlash {
|
||||
// Return object may lack some functionalities for other purposes.
|
||||
function createScriptSnapShot(sourceText: string): ts.IScriptSnapshot {
|
||||
return {
|
||||
getText: (start: number, end: number) => {
|
||||
return sourceText.substr(start, end - start);
|
||||
},
|
||||
getLength: () => {
|
||||
return sourceText.length;
|
||||
},
|
||||
getChangeRange: (oldSnapshot: ts.IScriptSnapshot) => {
|
||||
return <ts.TextChangeRange>undefined;
|
||||
}
|
||||
getText: (start: number, end: number) => sourceText.substr(start, end - start),
|
||||
getLength: () => sourceText.length,
|
||||
getChangeRange: () => undefined
|
||||
};
|
||||
}
|
||||
|
||||
@@ -360,6 +341,7 @@ namespace FourSlash {
|
||||
insertSpaceAfterCommaDelimiter: true,
|
||||
insertSpaceAfterSemicolonInForStatements: true,
|
||||
insertSpaceBeforeAndAfterBinaryOperators: true,
|
||||
insertSpaceAfterConstructor: false,
|
||||
insertSpaceAfterKeywordsInControlFlowStatements: true,
|
||||
insertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
|
||||
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
|
||||
@@ -419,9 +401,8 @@ namespace FourSlash {
|
||||
public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) {
|
||||
const startMarker = this.getMarkerByName(startMarkerName);
|
||||
const endMarker = this.getMarkerByName(endMarkerName);
|
||||
const predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
|
||||
return ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false;
|
||||
};
|
||||
const predicate = (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) =>
|
||||
((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false;
|
||||
|
||||
const exists = this.anyErrorInRange(predicate, startMarker, endMarker);
|
||||
|
||||
@@ -458,9 +439,8 @@ namespace FourSlash {
|
||||
private getAllDiagnostics(): ts.Diagnostic[] {
|
||||
const diagnostics: ts.Diagnostic[] = [];
|
||||
|
||||
const fileNames = this.languageServiceAdapterHost.getFilenames();
|
||||
for (let i = 0, n = fileNames.length; i < n; i++) {
|
||||
diagnostics.push.apply(this.getDiagnostics(fileNames[i]));
|
||||
for (const fileName of this.languageServiceAdapterHost.getFilenames()) {
|
||||
diagnostics.push.apply(this.getDiagnostics(fileName));
|
||||
}
|
||||
|
||||
return diagnostics;
|
||||
@@ -471,14 +451,12 @@ namespace FourSlash {
|
||||
let predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean;
|
||||
|
||||
if (after) {
|
||||
predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
|
||||
return ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false;
|
||||
};
|
||||
predicate = (errorMinChar: number, errorLimChar: number, startPos: number) =>
|
||||
((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false;
|
||||
}
|
||||
else {
|
||||
predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
|
||||
return ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false;
|
||||
};
|
||||
predicate = (errorMinChar: number, errorLimChar: number, startPos: number) =>
|
||||
((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false;
|
||||
}
|
||||
|
||||
const exists = this.anyErrorInRange(predicate, marker);
|
||||
@@ -501,7 +479,7 @@ namespace FourSlash {
|
||||
endPos = endMarker.position;
|
||||
}
|
||||
|
||||
errors.forEach(function(error: ts.Diagnostic) {
|
||||
errors.forEach(function (error: ts.Diagnostic) {
|
||||
if (predicate(error.start, error.start + error.length, startPos, endPos)) {
|
||||
exists = true;
|
||||
}
|
||||
@@ -518,7 +496,7 @@ namespace FourSlash {
|
||||
Harness.IO.log("Unexpected error(s) found. Error list is:");
|
||||
}
|
||||
|
||||
errors.forEach(function(error: ts.Diagnostic) {
|
||||
errors.forEach(function (error: ts.Diagnostic) {
|
||||
Harness.IO.log(" minChar: " + error.start +
|
||||
", limChar: " + (error.start + error.length) +
|
||||
", message: " + ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()) + "\n");
|
||||
@@ -602,12 +580,12 @@ namespace FourSlash {
|
||||
this.raiseError(`goToDefinitions failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`);
|
||||
}
|
||||
|
||||
for (let i = 0; i < endMarkers.length; i++) {
|
||||
const marker = this.getMarkerByName(endMarkers[i]), definition = definitions[i];
|
||||
ts.zipWith(endMarkers, definitions, (endMarker, definition, i) => {
|
||||
const marker = this.getMarkerByName(endMarker);
|
||||
if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) {
|
||||
this.raiseError(`goToDefinition failed for definition ${i}: expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public verifyGetEmitOutputForCurrentFile(expected: string): void {
|
||||
@@ -624,29 +602,19 @@ namespace FourSlash {
|
||||
public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
|
||||
const emit = this.languageService.getEmitOutput(this.activeFile.fileName);
|
||||
assert.equal(emit.outputFiles.length, expected.length, "Number of emit output files");
|
||||
for (let i = 0; i < emit.outputFiles.length; i++) {
|
||||
assert.equal(emit.outputFiles[i].name, expected[i].name, "FileName");
|
||||
assert.equal(emit.outputFiles[i].text, expected[i].text, "Content");
|
||||
}
|
||||
ts.zipWith(emit.outputFiles, expected, (outputFile, expected) => {
|
||||
assert.equal(outputFile.name, expected.name, "FileName");
|
||||
assert.equal(outputFile.text, expected.text, "Content");
|
||||
});
|
||||
}
|
||||
|
||||
public verifyMemberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if (members) {
|
||||
this.assertItemInCompletionList(members.entries, symbol, text, documentation, kind);
|
||||
}
|
||||
else {
|
||||
this.raiseError("Expected a member list, but none was provided");
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListCount(expectedCount: number, negative: boolean) {
|
||||
public verifyCompletionListCount(expectedCount: number, negative: boolean) {
|
||||
if (expectedCount === 0 && negative) {
|
||||
this.verifyMemberListIsEmpty(/*negative*/ false);
|
||||
this.verifyCompletionListIsEmpty(/*negative*/ false);
|
||||
return;
|
||||
}
|
||||
|
||||
const members = this.getMemberListAtCaret();
|
||||
const members = this.getCompletionListAtCaret();
|
||||
|
||||
if (members) {
|
||||
const match = members.entries.length === expectedCount;
|
||||
@@ -660,13 +628,6 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListDoesNotContain(symbol: string) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if (members && members.entries.filter(e => e.name === symbol).length !== 0) {
|
||||
this.raiseError(`Member list did contain ${symbol}`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
const itemsCount = completions.entries.length;
|
||||
@@ -690,9 +651,9 @@ namespace FourSlash {
|
||||
|
||||
const entries = this.getCompletionListAtCaret().entries;
|
||||
assert.isTrue(items.length <= entries.length, `Amount of expected items in completion list [ ${items.length} ] is greater than actual number of items in list [ ${entries.length} ]`);
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
assert.equal(entries[i].name, items[i], `Unexpected item in completion list`);
|
||||
}
|
||||
ts.zipWith(entries, items, (entry, item) => {
|
||||
assert.equal(entry.name, item, `Unexpected item in completion list`);
|
||||
});
|
||||
}
|
||||
|
||||
public noItemsWithSameNameButDifferentKind(): void {
|
||||
@@ -708,37 +669,14 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListIsEmpty(negative: boolean) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if ((!members || members.entries.length === 0) && negative) {
|
||||
this.raiseError("Member list is empty at Caret");
|
||||
}
|
||||
else if ((members && members.entries.length !== 0) && !negative) {
|
||||
|
||||
let errorMsg = "\n" + "Member List contains: [" + members.entries[0].name;
|
||||
for (let i = 1; i < members.entries.length; i++) {
|
||||
errorMsg += ", " + members.entries[i].name;
|
||||
}
|
||||
errorMsg += "]\n";
|
||||
|
||||
this.raiseError("Member list is not empty at Caret: " + errorMsg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListIsEmpty(negative: boolean) {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
if ((!completions || completions.entries.length === 0) && negative) {
|
||||
this.raiseError("Completion list is empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition);
|
||||
}
|
||||
else if (completions && completions.entries.length !== 0 && !negative) {
|
||||
let errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name;
|
||||
for (let i = 1; i < completions.entries.length; i++) {
|
||||
errorMsg += ", " + completions.entries[i].name;
|
||||
}
|
||||
errorMsg += "]\n";
|
||||
|
||||
this.raiseError("Completion list is not empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition + errorMsg);
|
||||
this.raiseError(`Completion list is not empty at caret at position ${this.activeFile.fileName} ${this.currentCaretPosition}\n` +
|
||||
`Completion List contains: ${stringify(completions.entries.map(e => e.name))}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,8 +850,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
|
||||
for (let i = 0; i < references.length; i++) {
|
||||
const reference = references[i];
|
||||
for (const reference of references) {
|
||||
if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) {
|
||||
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
|
||||
this.raiseError(`verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${reference.isWriteAccess}, expected: ${isWriteAccess}.`);
|
||||
@@ -929,10 +866,6 @@ namespace FourSlash {
|
||||
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
|
||||
}
|
||||
|
||||
private getMemberListAtCaret() {
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
private getCompletionListAtCaret() {
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
@@ -1030,16 +963,11 @@ namespace FourSlash {
|
||||
ranges = ranges.sort((r1, r2) => r1.start - r2.start);
|
||||
references = references.sort((r1, r2) => r1.textSpan.start - r2.textSpan.start);
|
||||
|
||||
for (let i = 0, n = ranges.length; i < n; i++) {
|
||||
const reference = references[i];
|
||||
const range = ranges[i];
|
||||
|
||||
if (reference.textSpan.start !== range.start ||
|
||||
ts.textSpanEnd(reference.textSpan) !== range.end) {
|
||||
|
||||
ts.zipWith(references, ranges, (reference, range) => {
|
||||
if (reference.textSpan.start !== range.start || ts.textSpanEnd(reference.textSpan) !== range.end) {
|
||||
this.raiseError("Rename location results do not match.\n\nExpected: " + stringify(ranges) + "\n\nActual:" + JSON.stringify(references));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.raiseError("Expected rename to succeed, but it actually failed.");
|
||||
@@ -1068,7 +996,7 @@ namespace FourSlash {
|
||||
ts.displayPartsToString(help.suffixDisplayParts), expected);
|
||||
}
|
||||
|
||||
public verifyCurrentParameterIsletiable(isVariable: boolean) {
|
||||
public verifyCurrentParameterIsVariable(isVariable: boolean) {
|
||||
const signature = this.getActiveSignatureHelpItem();
|
||||
assert.isOk(signature);
|
||||
assert.equal(isVariable, signature.isVariadic);
|
||||
@@ -1095,6 +1023,10 @@ namespace FourSlash {
|
||||
assert.equal(this.getActiveSignatureHelpItem().parameters.length, expectedCount);
|
||||
}
|
||||
|
||||
public verifyCurrentSignatureHelpIsVariadic(expected: boolean) {
|
||||
assert.equal(this.getActiveSignatureHelpItem().isVariadic, expected);
|
||||
}
|
||||
|
||||
public verifyCurrentSignatureHelpDocComment(docComment: string) {
|
||||
const actualDocComment = this.getActiveSignatureHelpItem().documentation;
|
||||
assert.equal(ts.displayPartsToString(actualDocComment), docComment, this.assertionMessageAtLastKnownMarker("current signature help doc comment"));
|
||||
@@ -1179,7 +1111,7 @@ namespace FourSlash {
|
||||
|
||||
private alignmentForExtraInfo = 50;
|
||||
|
||||
private spanInfoToString(pos: number, spanInfo: ts.TextSpan, prefixString: string) {
|
||||
private spanInfoToString(spanInfo: ts.TextSpan, prefixString: string) {
|
||||
let resultString = "SpanInfo: " + JSON.stringify(spanInfo);
|
||||
if (spanInfo) {
|
||||
const spanString = this.activeFile.content.substr(spanInfo.start, spanInfo.length);
|
||||
@@ -1230,7 +1162,7 @@ namespace FourSlash {
|
||||
startColumn = 0;
|
||||
length = 0;
|
||||
}
|
||||
const spanInfo = this.spanInfoToString(pos, getSpanAtPos(pos), prefixString);
|
||||
const spanInfo = this.spanInfoToString(getSpanAtPos(pos), prefixString);
|
||||
if (previousSpanInfo && previousSpanInfo !== spanInfo) {
|
||||
addSpanInfoString();
|
||||
previousSpanInfo = spanInfo;
|
||||
@@ -1269,8 +1201,7 @@ namespace FourSlash {
|
||||
const emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on
|
||||
|
||||
const allFourSlashFiles = this.testData.files;
|
||||
for (let idx = 0; idx < allFourSlashFiles.length; idx++) {
|
||||
const file = allFourSlashFiles[idx];
|
||||
for (const file of allFourSlashFiles) {
|
||||
if (file.fileOptions[metadataOptionNames.emitThisFile] === "true") {
|
||||
// Find a file with the flag emitThisFile turned on
|
||||
emitFiles.push(file);
|
||||
@@ -1295,15 +1226,26 @@ namespace FourSlash {
|
||||
if (emitOutput.emitSkipped) {
|
||||
resultString += "Diagnostics:" + Harness.IO.newLine();
|
||||
const diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram());
|
||||
for (let i = 0, n = diagnostics.length; i < n; i++) {
|
||||
resultString += " " + diagnostics[0].messageText + Harness.IO.newLine();
|
||||
for (const diagnostic of diagnostics) {
|
||||
if (typeof diagnostic.messageText !== "string") {
|
||||
let chainedMessage = <ts.DiagnosticMessageChain>diagnostic.messageText;
|
||||
let indentation = " ";
|
||||
while (chainedMessage) {
|
||||
resultString += indentation + chainedMessage.messageText + Harness.IO.newLine();
|
||||
chainedMessage = chainedMessage.next;
|
||||
indentation = indentation + " ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
resultString += " " + diagnostic.messageText + Harness.IO.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emitOutput.outputFiles.forEach((outputFile, idx, array) => {
|
||||
for (const outputFile of emitOutput.outputFiles) {
|
||||
const fileName = "FileName : " + outputFile.name + Harness.IO.newLine();
|
||||
resultString = resultString + fileName + outputFile.text;
|
||||
});
|
||||
}
|
||||
resultString += Harness.IO.newLine();
|
||||
});
|
||||
|
||||
@@ -1328,7 +1270,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public printBreakpointLocation(pos: number) {
|
||||
Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(pos, this.getBreakpointStatementLocation(pos), " "));
|
||||
Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(this.getBreakpointStatementLocation(pos), " "));
|
||||
}
|
||||
|
||||
public printBreakpointAtCurrentLocation() {
|
||||
@@ -1362,8 +1304,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public printCurrentFileState(makeWhitespaceVisible = false, makeCaretVisible = true) {
|
||||
for (let i = 0; i < this.testData.files.length; i++) {
|
||||
const file = this.testData.files[i];
|
||||
for (const file of this.testData.files) {
|
||||
const active = (this.activeFile === file);
|
||||
Harness.IO.log(`=== Script (${file.fileName}) ${(active ? "(active, cursor at |)" : "")} ===`);
|
||||
let content = this.getFileContent(file.fileName);
|
||||
@@ -1382,11 +1323,6 @@ namespace FourSlash {
|
||||
Harness.IO.log(stringify(sigHelp));
|
||||
}
|
||||
|
||||
public printMemberListMembers() {
|
||||
const members = this.getMemberListAtCaret();
|
||||
this.printMembersOrCompletions(members);
|
||||
}
|
||||
|
||||
public printCompletionListMembers() {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
this.printMembersOrCompletions(completions);
|
||||
@@ -1598,10 +1534,10 @@ namespace FourSlash {
|
||||
edits = edits.sort((a, b) => a.span.start - b.span.start);
|
||||
// Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters
|
||||
const oldContent = this.getFileContent(this.activeFile.fileName);
|
||||
for (let j = 0; j < edits.length; j++) {
|
||||
this.languageServiceAdapterHost.editScript(fileName, edits[j].span.start + runningOffset, ts.textSpanEnd(edits[j].span) + runningOffset, edits[j].newText);
|
||||
this.updateMarkersForEdit(fileName, edits[j].span.start + runningOffset, ts.textSpanEnd(edits[j].span) + runningOffset, edits[j].newText);
|
||||
const change = (edits[j].span.start - ts.textSpanEnd(edits[j].span)) + edits[j].newText.length;
|
||||
for (const edit of edits) {
|
||||
this.languageServiceAdapterHost.editScript(fileName, edit.span.start + runningOffset, ts.textSpanEnd(edit.span) + runningOffset, edit.newText);
|
||||
this.updateMarkersForEdit(fileName, edit.span.start + runningOffset, ts.textSpanEnd(edit.span) + runningOffset, edit.newText);
|
||||
const change = (edit.span.start - ts.textSpanEnd(edit.span)) + edit.newText.length;
|
||||
runningOffset += change;
|
||||
// TODO: Consider doing this at least some of the time for higher fidelity. Currently causes a failure (bug 707150)
|
||||
// this.languageService.getScriptLexicalStructure(fileName);
|
||||
@@ -1830,7 +1766,7 @@ namespace FourSlash {
|
||||
return result;
|
||||
}
|
||||
|
||||
private rangeText({fileName, start, end}: Range, more = false): string {
|
||||
private rangeText({fileName, start, end}: Range): string {
|
||||
return this.getFileContent(fileName).slice(start, end);
|
||||
}
|
||||
|
||||
@@ -1925,7 +1861,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public printNameOrDottedNameSpans(pos: number) {
|
||||
Harness.IO.log(this.spanInfoToString(pos, this.getNameOrDottedNameSpan(pos), "**"));
|
||||
Harness.IO.log(this.spanInfoToString(this.getNameOrDottedNameSpan(pos), "**"));
|
||||
}
|
||||
|
||||
private verifyClassifications(expected: { classificationType: string; text: string; textSpan?: TextSpan }[], actual: ts.ClassifiedSpan[]) {
|
||||
@@ -1935,10 +1871,7 @@ namespace FourSlash {
|
||||
jsonMismatchString());
|
||||
}
|
||||
|
||||
for (let i = 0; i < expected.length; i++) {
|
||||
const expectedClassification = expected[i];
|
||||
const actualClassification = actual[i];
|
||||
|
||||
ts.zipWith(expected, actual, (expectedClassification, actualClassification) => {
|
||||
const expectedType: string = (<any>ts.ClassificationTypeNames)[expectedClassification.classificationType];
|
||||
if (expectedType !== actualClassification.classificationType) {
|
||||
this.raiseError("verifyClassifications failed - expected classifications type to be " +
|
||||
@@ -1968,7 +1901,7 @@ namespace FourSlash {
|
||||
actualText +
|
||||
jsonMismatchString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function jsonMismatchString() {
|
||||
return Harness.IO.newLine() +
|
||||
@@ -2013,13 +1946,11 @@ namespace FourSlash {
|
||||
this.raiseError(`verifyOutliningSpans failed - expected total spans to be ${spans.length}, but was ${actual.length}`);
|
||||
}
|
||||
|
||||
for (let i = 0; i < spans.length; i++) {
|
||||
const expectedSpan = spans[i];
|
||||
const actualSpan = actual[i];
|
||||
ts.zipWith(spans, actual, (expectedSpan, actualSpan, i) => {
|
||||
if (expectedSpan.start !== actualSpan.textSpan.start || expectedSpan.end !== ts.textSpanEnd(actualSpan.textSpan)) {
|
||||
this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualSpan.textSpan.start},${ts.textSpanEnd(actualSpan.textSpan)})`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public verifyTodoComments(descriptors: string[], spans: TextSpan[]) {
|
||||
@@ -2030,15 +1961,13 @@ namespace FourSlash {
|
||||
this.raiseError(`verifyTodoComments failed - expected total spans to be ${spans.length}, but was ${actual.length}`);
|
||||
}
|
||||
|
||||
for (let i = 0; i < spans.length; i++) {
|
||||
const expectedSpan = spans[i];
|
||||
const actualComment = actual[i];
|
||||
ts.zipWith(spans, actual, (expectedSpan, actualComment, i) => {
|
||||
const actualCommentSpan = ts.createTextSpan(actualComment.position, actualComment.message.length);
|
||||
|
||||
if (expectedSpan.start !== actualCommentSpan.start || expectedSpan.end !== ts.textSpanEnd(actualCommentSpan)) {
|
||||
this.raiseError(`verifyOutliningSpans failed - span ${(i + 1)} expected: (${expectedSpan.start},${expectedSpan.end}), actual: (${actualCommentSpan.start},${ts.textSpanEnd(actualCommentSpan)})`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private getCodeFixes(errorCode?: number) {
|
||||
@@ -2049,13 +1978,13 @@ namespace FourSlash {
|
||||
this.raiseError("Errors expected.");
|
||||
}
|
||||
|
||||
if (diagnostics.length > 1 && errorCode !== undefined) {
|
||||
if (diagnostics.length > 1 && errorCode === undefined) {
|
||||
this.raiseError("When there's more than one error, you must specify the errror to fix.");
|
||||
}
|
||||
|
||||
const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode);
|
||||
|
||||
return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]);
|
||||
return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.start + diagnostic.length, [diagnostic.code]);
|
||||
}
|
||||
|
||||
public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) {
|
||||
@@ -2082,6 +2011,34 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) {
|
||||
const ranges = this.getRanges();
|
||||
if (ranges.length == 0) {
|
||||
this.raiseError("At least one range should be specified in the testfile.");
|
||||
}
|
||||
|
||||
const codeFixes = this.getCodeFixes(errorCode);
|
||||
|
||||
if (!codeFixes || codeFixes.length == 0) {
|
||||
this.raiseError("No codefixes returned.");
|
||||
}
|
||||
|
||||
const actualTextArray: string[] = [];
|
||||
const scriptInfo = this.languageServiceAdapterHost.getScriptInfo(codeFixes[0].changes[0].fileName);
|
||||
const originalContent = scriptInfo.content;
|
||||
for (const codeFix of codeFixes) {
|
||||
this.applyEdits(codeFix.changes[0].fileName, codeFix.changes[0].textChanges, /*isFormattingEdit*/ false);
|
||||
actualTextArray.push(this.normalizeNewlines(this.rangeText(ranges[0])));
|
||||
scriptInfo.updateContent(originalContent);
|
||||
}
|
||||
const sortedExpectedArray = ts.map(expectedTextArray, str => this.normalizeNewlines(str)).sort();
|
||||
const sortedActualArray = actualTextArray.sort();
|
||||
if (!ts.arrayIsEqualTo(sortedExpectedArray, sortedActualArray)) {
|
||||
this.raiseError(
|
||||
`Actual text array doesn't match expected text array. \nActual: \n"${sortedActualArray.join("\n\n")}"\n---\nExpected: \n'${sortedExpectedArray.join("\n\n")}'`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyDocCommentTemplate(expected?: ts.TextInsertion) {
|
||||
const name = "verifyDocCommentTemplate";
|
||||
const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
@@ -2115,6 +2072,10 @@ namespace FourSlash {
|
||||
});
|
||||
}
|
||||
|
||||
private normalizeNewlines(str: string) {
|
||||
return str.replace(/\r?\n/g, "\n");
|
||||
}
|
||||
|
||||
public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) {
|
||||
|
||||
const openBraceMap = ts.createMap<ts.CharacterCodes>({
|
||||
@@ -2185,11 +2146,9 @@ namespace FourSlash {
|
||||
public verifyNavigationItemsCount(expected: number, searchValue: string, matchKind?: string, fileName?: string) {
|
||||
const items = this.languageService.getNavigateToItems(searchValue, /*maxResultCount*/ undefined, fileName);
|
||||
let actual = 0;
|
||||
let item: ts.NavigateToItem;
|
||||
|
||||
// Count only the match that match the same MatchKind
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
item = items[i];
|
||||
for (const item of items) {
|
||||
if (!matchKind || item.matchKind === matchKind) {
|
||||
actual++;
|
||||
}
|
||||
@@ -2217,8 +2176,7 @@ namespace FourSlash {
|
||||
this.raiseError("verifyNavigationItemsListContains failed - found 0 navigation items, expected at least one.");
|
||||
}
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
for (const item of items) {
|
||||
if (item && item.name === name && item.kind === kind &&
|
||||
(matchKind === undefined || item.matchKind === matchKind) &&
|
||||
(fileName === undefined || item.fileName === fileName) &&
|
||||
@@ -2269,24 +2227,16 @@ namespace FourSlash {
|
||||
|
||||
public printNavigationItems(searchValue: string) {
|
||||
const items = this.languageService.getNavigateToItems(searchValue);
|
||||
const length = items && items.length;
|
||||
|
||||
Harness.IO.log(`NavigationItems list (${length} items)`);
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
const item = items[i];
|
||||
Harness.IO.log(`NavigationItems list (${items.length} items)`);
|
||||
for (const item of items) {
|
||||
Harness.IO.log(`name: ${item.name}, kind: ${item.kind}, parentName: ${item.containerName}, fileName: ${item.fileName}`);
|
||||
}
|
||||
}
|
||||
|
||||
public printNavigationBar() {
|
||||
const items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
|
||||
const length = items && items.length;
|
||||
|
||||
Harness.IO.log(`Navigation bar (${length} items)`);
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
const item = items[i];
|
||||
Harness.IO.log(`Navigation bar (${items.length} items)`);
|
||||
for (const item of items) {
|
||||
Harness.IO.log(`${repeatString(item.indent, " ")}name: ${item.text}, kind: ${item.kind}, childItems: ${item.childItems.map(child => child.text)}`);
|
||||
}
|
||||
}
|
||||
@@ -2407,8 +2357,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
for (const item of items) {
|
||||
if (item.name === name) {
|
||||
if (documentation != undefined || text !== undefined) {
|
||||
const details = this.getCompletionEntryDetails(item.name);
|
||||
@@ -2457,20 +2406,17 @@ namespace FourSlash {
|
||||
name = name.indexOf("/") === -1 ? (this.basePath + "/" + name) : name;
|
||||
|
||||
const availableNames: string[] = [];
|
||||
let foundIt = false;
|
||||
for (let i = 0; i < this.testData.files.length; i++) {
|
||||
const fn = this.testData.files[i].fileName;
|
||||
result = ts.forEach(this.testData.files, file => {
|
||||
const fn = file.fileName;
|
||||
if (fn) {
|
||||
if (fn === name) {
|
||||
result = this.testData.files[i];
|
||||
foundIt = true;
|
||||
break;
|
||||
return file;
|
||||
}
|
||||
availableNames.push(fn);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!foundIt) {
|
||||
if (!result) {
|
||||
throw new Error(`No test file named "${name}" exists. Available file names are: ${availableNames.join(", ")}`);
|
||||
}
|
||||
}
|
||||
@@ -2571,8 +2517,8 @@ ${code}
|
||||
|
||||
function chompLeadingSpace(content: string) {
|
||||
const lines = content.split("\n");
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if ((lines[i].length !== 0) && (lines[i].charAt(0) !== " ")) {
|
||||
for (const line of lines) {
|
||||
if ((line.length !== 0) && (line.charAt(0) !== " ")) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
@@ -2610,8 +2556,7 @@ ${code}
|
||||
currentFileName = fileName;
|
||||
}
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
let line = lines[i];
|
||||
for (let line of lines) {
|
||||
const lineLength = line.length;
|
||||
|
||||
if (lineLength > 0 && line.charAt(lineLength - 1) === "\r") {
|
||||
@@ -2658,7 +2603,7 @@ ${code}
|
||||
resetLocalData();
|
||||
}
|
||||
|
||||
currentFileName = basePath + "/" + value;
|
||||
currentFileName = ts.isRootedDiskPath(value) ? value : basePath + "/" + value;
|
||||
currentFileOptions[key] = value;
|
||||
}
|
||||
else {
|
||||
@@ -3081,19 +3026,8 @@ namespace FourSlashInterface {
|
||||
}
|
||||
}
|
||||
|
||||
// Verifies the member list contains the specified symbol. The
|
||||
// member list is brought up if necessary
|
||||
public memberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
if (this.negative) {
|
||||
this.state.verifyMemberListDoesNotContain(symbol);
|
||||
}
|
||||
else {
|
||||
this.state.verifyMemberListContains(symbol, text, documentation, kind);
|
||||
}
|
||||
}
|
||||
|
||||
public memberListCount(expectedCount: number) {
|
||||
this.state.verifyMemberListCount(expectedCount, this.negative);
|
||||
public completionListCount(expectedCount: number) {
|
||||
this.state.verifyCompletionListCount(expectedCount, this.negative);
|
||||
}
|
||||
|
||||
// Verifies the completion list contains the specified symbol. The
|
||||
@@ -3129,10 +3063,6 @@ namespace FourSlashInterface {
|
||||
this.state.verifyCompletionListAllowsNewIdentifier(this.negative);
|
||||
}
|
||||
|
||||
public memberListIsEmpty() {
|
||||
this.state.verifyMemberListIsEmpty(this.negative);
|
||||
}
|
||||
|
||||
public signatureHelpPresent() {
|
||||
this.state.verifySignatureHelpPresent(!this.negative);
|
||||
}
|
||||
@@ -3287,6 +3217,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifySignatureHelpCount(expected);
|
||||
}
|
||||
|
||||
public signatureHelpCurrentArgumentListIsVariadic(expected: boolean) {
|
||||
this.state.verifyCurrentSignatureHelpIsVariadic(expected);
|
||||
}
|
||||
|
||||
public signatureHelpArgumentCountIs(expected: number) {
|
||||
this.state.verifySignatureHelpArgumentCount(expected);
|
||||
}
|
||||
@@ -3351,6 +3285,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifyCodeFixAtPosition(expectedText, errorCode);
|
||||
}
|
||||
|
||||
public importFixAtPosition(expectedTextArray: string[], errorCode?: number): void {
|
||||
this.state.verifyImportFixAtPosition(expectedTextArray, errorCode);
|
||||
}
|
||||
|
||||
public navigationBar(json: any) {
|
||||
this.state.verifyNavigationBar(json);
|
||||
}
|
||||
@@ -3526,10 +3464,6 @@ namespace FourSlashInterface {
|
||||
this.state.printCurrentSignatureHelp();
|
||||
}
|
||||
|
||||
public printMemberListMembers() {
|
||||
this.state.printMemberListMembers();
|
||||
}
|
||||
|
||||
public printCompletionListMembers() {
|
||||
this.state.printCompletionListMembers();
|
||||
}
|
||||
@@ -3590,11 +3524,8 @@ namespace FourSlashInterface {
|
||||
this.state.formatOnType(this.state.getMarkerByName(posMarker).position, key);
|
||||
}
|
||||
|
||||
public setOption(name: string, value: number): void;
|
||||
public setOption(name: string, value: string): void;
|
||||
public setOption(name: string, value: boolean): void;
|
||||
public setOption(name: string, value: any): void {
|
||||
(<any>this.state.formatCodeSettings)[name] = value;
|
||||
public setOption(name: keyof ts.FormatCodeSettings, value: number | string | boolean): void {
|
||||
this.state.formatCodeSettings[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+125
-102
@@ -85,7 +85,7 @@ namespace Utils {
|
||||
eval(fileContents);
|
||||
break;
|
||||
case ExecutionEnvironment.Node:
|
||||
let vm = require("vm");
|
||||
const vm = require("vm");
|
||||
if (nodeContext) {
|
||||
vm.runInNewContext(fileContents, nodeContext, fileName);
|
||||
}
|
||||
@@ -175,9 +175,9 @@ namespace Utils {
|
||||
assert.isFalse(array.end > node.end, "array.end > node.end");
|
||||
assert.isFalse(array.pos < currentPos, "array.pos < currentPos");
|
||||
|
||||
for (let i = 0, n = array.length; i < n; i++) {
|
||||
assert.isFalse(array[i].pos < currentPos, "array[i].pos < currentPos");
|
||||
currentPos = array[i].end;
|
||||
for (const item of array) {
|
||||
assert.isFalse(item.pos < currentPos, "array[i].pos < currentPos");
|
||||
currentPos = item.end;
|
||||
}
|
||||
|
||||
currentPos = array.end;
|
||||
@@ -220,9 +220,7 @@ namespace Utils {
|
||||
}
|
||||
|
||||
export function sourceFileToJSON(file: ts.Node): string {
|
||||
return JSON.stringify(file, (k, v) => {
|
||||
return isNodeOrArray(v) ? serializeNode(v) : v;
|
||||
}, " ");
|
||||
return JSON.stringify(file, (_, v) => isNodeOrArray(v) ? serializeNode(v) : v, " ");
|
||||
|
||||
function getKindName(k: number | string): string {
|
||||
if (typeof k === "string") {
|
||||
@@ -346,7 +344,7 @@ namespace Utils {
|
||||
|
||||
assert.equal(array1.length, array2.length, "array1.length !== array2.length");
|
||||
|
||||
for (let i = 0, n = array1.length; i < n; i++) {
|
||||
for (let i = 0; i < array1.length; i++) {
|
||||
const d1 = array1[i];
|
||||
const d2 = array2[i];
|
||||
|
||||
@@ -402,7 +400,7 @@ namespace Utils {
|
||||
assert.equal(array1.end, array2.end, "array1.end !== array2.end");
|
||||
assert.equal(array1.length, array2.length, "array1.length !== array2.length");
|
||||
|
||||
for (let i = 0, n = array1.length; i < n; i++) {
|
||||
for (let i = 0; i < array1.length; i++) {
|
||||
assertStructuralEquals(array1[i], array2[i]);
|
||||
}
|
||||
}
|
||||
@@ -472,19 +470,6 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
namespace Harness.Path {
|
||||
export function getFileName(fullPath: string) {
|
||||
return fullPath.replace(/^.*[\\\/]/, "");
|
||||
}
|
||||
|
||||
export function filePath(fullPath: string) {
|
||||
fullPath = ts.normalizeSlashes(fullPath);
|
||||
const components = fullPath.split("/");
|
||||
const path: string[] = components.slice(0, components.length - 1);
|
||||
return path.join("/") + "/";
|
||||
}
|
||||
}
|
||||
|
||||
namespace Harness {
|
||||
export interface IO {
|
||||
newLine(): string;
|
||||
@@ -692,7 +677,7 @@ namespace Harness {
|
||||
export const getCurrentDirectory = () => "";
|
||||
export const args = () => <string[]>[];
|
||||
export const getExecutingFilePath = () => "";
|
||||
export const exit = (exitCode: number) => { };
|
||||
export const exit = ts.noop;
|
||||
export const getDirectories = () => <string[]>[];
|
||||
|
||||
export let log = (s: string) => console.log(s);
|
||||
@@ -742,7 +727,7 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export function createDirectory(path: string) {
|
||||
export function createDirectory() {
|
||||
// Do nothing (?)
|
||||
}
|
||||
|
||||
@@ -750,7 +735,7 @@ namespace Harness {
|
||||
Http.writeToServerSync(serverRoot + path, "DELETE");
|
||||
}
|
||||
|
||||
export function directoryExists(path: string): boolean {
|
||||
export function directoryExists(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -792,7 +777,7 @@ namespace Harness {
|
||||
return response.status === 200;
|
||||
}
|
||||
|
||||
export function _listFilesImpl(path: string, spec?: RegExp, options?: any) {
|
||||
export let listFiles = Utils.memoize((path: string, spec?: RegExp): string[] => {
|
||||
const response = Http.getFileFromServerSync(serverRoot + path);
|
||||
if (response.status === 200) {
|
||||
const results = response.responseText.split(",");
|
||||
@@ -806,8 +791,7 @@ namespace Harness {
|
||||
else {
|
||||
return [""];
|
||||
}
|
||||
};
|
||||
export let listFiles = Utils.memoize(_listFilesImpl);
|
||||
});
|
||||
|
||||
export function readFile(file: string) {
|
||||
const response = Http.getFileFromServerSync(serverRoot + file);
|
||||
@@ -941,7 +925,17 @@ namespace Harness {
|
||||
}
|
||||
|
||||
export function getDefaultLibFileName(options: ts.CompilerOptions): string {
|
||||
return options.target === ts.ScriptTarget.ES6 ? es2015DefaultLibFileName : defaultLibFileName;
|
||||
switch (options.target) {
|
||||
case ts.ScriptTarget.ES2017:
|
||||
return "lib.es2017.d.ts";
|
||||
case ts.ScriptTarget.ES2016:
|
||||
return "lib.es2016.d.ts";
|
||||
case ts.ScriptTarget.ES2015:
|
||||
return es2015DefaultLibFileName;
|
||||
|
||||
default:
|
||||
return defaultLibFileName;
|
||||
}
|
||||
}
|
||||
|
||||
// Cache these between executions so we don't have to re-parse them for every test
|
||||
@@ -964,28 +958,38 @@ namespace Harness {
|
||||
// Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames
|
||||
const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
|
||||
const realPathMap: ts.FileMap<string> = ts.createFileMap<string>();
|
||||
const fileMap: ts.FileMap<() => ts.SourceFile> = ts.createFileMap<() => ts.SourceFile>();
|
||||
/** Maps a symlink name to a realpath. Used only for exposing `realpath`. */
|
||||
const realPathMap = ts.createFileMap<string>();
|
||||
/**
|
||||
* Maps a file name to a source file.
|
||||
* This will have a different SourceFile for every symlink pointing to that file;
|
||||
* if the program resolves realpaths then symlink entries will be ignored.
|
||||
*/
|
||||
const fileMap = ts.createFileMap<ts.SourceFile>();
|
||||
for (const file of inputFiles) {
|
||||
if (file.content !== undefined) {
|
||||
const fileName = ts.normalizePath(file.unitName);
|
||||
const path = ts.toPath(file.unitName, currentDirectory, getCanonicalFileName);
|
||||
if (file.fileOptions && file.fileOptions["symlink"]) {
|
||||
const link = file.fileOptions["symlink"];
|
||||
const linkPath = ts.toPath(link, currentDirectory, getCanonicalFileName);
|
||||
realPathMap.set(linkPath, fileName);
|
||||
fileMap.set(path, (): ts.SourceFile => { throw new Error("Symlinks should always be resolved to a realpath first"); });
|
||||
const links = file.fileOptions["symlink"].split(",");
|
||||
for (const link of links) {
|
||||
const linkPath = ts.toPath(link, currentDirectory, getCanonicalFileName);
|
||||
realPathMap.set(linkPath, fileName);
|
||||
// Create a different SourceFile for every symlink.
|
||||
const sourceFile = createSourceFileAndAssertInvariants(linkPath, file.content, scriptTarget);
|
||||
fileMap.set(linkPath, sourceFile);
|
||||
}
|
||||
}
|
||||
const sourceFile = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
fileMap.set(path, () => sourceFile);
|
||||
fileMap.set(path, sourceFile);
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget) {
|
||||
function getSourceFile(fileName: string) {
|
||||
fileName = ts.normalizePath(fileName);
|
||||
const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
if (fileMap.contains(path)) {
|
||||
return fileMap.get(path)();
|
||||
const fromFileMap = fileMap.get(toPath(fileName));
|
||||
if (fromFileMap) {
|
||||
return fromFileMap;
|
||||
}
|
||||
else if (fileName === fourslashFileName) {
|
||||
const tsFn = "tests/cases/fourslash/" + fourslashFileName;
|
||||
@@ -1004,6 +1008,9 @@ namespace Harness {
|
||||
newLineKind === ts.NewLineKind.LineFeed ? lineFeed :
|
||||
Harness.IO.newLine();
|
||||
|
||||
function toPath(fileName: string): ts.Path {
|
||||
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
}
|
||||
|
||||
return {
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
@@ -1013,35 +1020,31 @@ namespace Harness {
|
||||
getCanonicalFileName,
|
||||
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
||||
getNewLine: () => newLine,
|
||||
fileExists: fileName => {
|
||||
const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
return fileMap.contains(path) || (realPathMap && realPathMap.contains(path));
|
||||
},
|
||||
fileExists: fileName => fileMap.contains(toPath(fileName)),
|
||||
readFile: (fileName: string): string => {
|
||||
return fileMap.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName))().getText();
|
||||
const file = fileMap.get(toPath(fileName));
|
||||
if (ts.endsWith(fileName, "json")) {
|
||||
// strip comments
|
||||
return file.getText();
|
||||
}
|
||||
return file.text;
|
||||
},
|
||||
realpath: (fileName: string): ts.Path => {
|
||||
const path = toPath(fileName);
|
||||
return (realPathMap.get(path) as ts.Path) || path;
|
||||
},
|
||||
realpath: realPathMap && ((f: string) => {
|
||||
const path = ts.toPath(f, currentDirectory, getCanonicalFileName);
|
||||
return realPathMap.contains(path) ? realPathMap.get(path) : path;
|
||||
}),
|
||||
directoryExists: dir => {
|
||||
let path = ts.toPath(dir, currentDirectory, getCanonicalFileName);
|
||||
// Strip trailing /, which may exist if the path is a drive root
|
||||
if (path[path.length - 1] === "/") {
|
||||
path = <ts.Path>path.substr(0, path.length - 1);
|
||||
}
|
||||
let exists = false;
|
||||
fileMap.forEachValue(key => {
|
||||
if (key.indexOf(path) === 0 && key[path.length] === "/") {
|
||||
exists = true;
|
||||
}
|
||||
});
|
||||
return exists;
|
||||
return mapHasFileInDirectory(path, fileMap);
|
||||
},
|
||||
getDirectories: d => {
|
||||
const path = ts.toPath(d, currentDirectory, getCanonicalFileName);
|
||||
const result: string[] = [];
|
||||
fileMap.forEachValue((key, value) => {
|
||||
fileMap.forEachValue(key => {
|
||||
if (key.indexOf(path) === 0 && key.lastIndexOf("/") > path.length) {
|
||||
let dirName = key.substr(path.length, key.indexOf("/", path.length + 1) - path.length);
|
||||
if (dirName[0] === "/") {
|
||||
@@ -1057,6 +1060,19 @@ namespace Harness {
|
||||
};
|
||||
}
|
||||
|
||||
function mapHasFileInDirectory(directoryPath: ts.Path, map: ts.FileMap<any>): boolean {
|
||||
if (!map) {
|
||||
return false;
|
||||
}
|
||||
let exists = false;
|
||||
map.forEachValue(fileName => {
|
||||
if (!exists && ts.startsWith(fileName, directoryPath) && fileName[directoryPath.length] === "/") {
|
||||
exists = true;
|
||||
}
|
||||
});
|
||||
return exists;
|
||||
}
|
||||
|
||||
interface HarnessOptions {
|
||||
useCaseSensitiveFileNames?: boolean;
|
||||
includeBuiltFile?: string;
|
||||
@@ -1076,7 +1092,9 @@ namespace Harness {
|
||||
{ name: "suppressOutputPathCheck", type: "boolean" },
|
||||
{ name: "noImplicitReferences", type: "boolean" },
|
||||
{ name: "currentDirectory", type: "string" },
|
||||
{ name: "symlink", type: "string" }
|
||||
{ name: "symlink", type: "string" },
|
||||
// Emitted js baseline will print full paths for every output file
|
||||
{ name: "fullEmitPaths", type: "boolean" }
|
||||
];
|
||||
|
||||
let optionsIndex: ts.Map<ts.CommandLineOption>;
|
||||
@@ -1101,22 +1119,7 @@ namespace Harness {
|
||||
const option = getCommandLineOption(name);
|
||||
if (option) {
|
||||
const errors: ts.Diagnostic[] = [];
|
||||
switch (option.type) {
|
||||
case "boolean":
|
||||
options[option.name] = value.toLowerCase() === "true";
|
||||
break;
|
||||
case "string":
|
||||
options[option.name] = value;
|
||||
break;
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
case "list":
|
||||
options[option.name] = ts.parseListTypeOption(<ts.CommandLineOptionOfListType>option, value, errors);
|
||||
break;
|
||||
default:
|
||||
options[option.name] = ts.parseCustomTypeOption(<ts.CommandLineOptionOfCustomType>option, value, errors);
|
||||
break;
|
||||
}
|
||||
|
||||
options[option.name] = optionValue(option, value, errors);
|
||||
if (errors.length > 0) {
|
||||
throw new Error(`Unknown value '${value}' for compiler option '${name}'.`);
|
||||
}
|
||||
@@ -1128,6 +1131,27 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
function optionValue(option: ts.CommandLineOption, value: string, errors: ts.Diagnostic[]): any {
|
||||
switch (option.type) {
|
||||
case "boolean":
|
||||
return value.toLowerCase() === "true";
|
||||
case "string":
|
||||
return value;
|
||||
case "number": {
|
||||
const number = parseInt(value, 10);
|
||||
if (isNaN(number)) {
|
||||
throw new Error(`Value must be a number, got: ${JSON.stringify(value)}`);
|
||||
}
|
||||
return number;
|
||||
}
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
case "list":
|
||||
return ts.parseListTypeOption(<ts.CommandLineOptionOfListType>option, value, errors);
|
||||
default:
|
||||
return ts.parseCustomTypeOption(<ts.CommandLineOptionOfCustomType>option, value, errors);
|
||||
}
|
||||
}
|
||||
|
||||
export interface TestFile {
|
||||
unitName: string;
|
||||
content: string;
|
||||
@@ -1231,7 +1255,7 @@ namespace Harness {
|
||||
if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) {
|
||||
ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles));
|
||||
ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles));
|
||||
const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory);
|
||||
const output = compileFiles(declInputFiles, declOtherFiles, harnessSettings, options, currentDirectory || harnessSettings["currentDirectory"]);
|
||||
return { declInputFiles, declOtherFiles, declResult: output.result };
|
||||
}
|
||||
|
||||
@@ -1463,7 +1487,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
if (typesError && symbolsError) {
|
||||
throw new Error(typesError.message + ts.sys.newLine + symbolsError.message);
|
||||
throw new Error(typesError.message + Harness.IO.newLine() + symbolsError.message);
|
||||
}
|
||||
|
||||
if (typesError) {
|
||||
@@ -1545,7 +1569,7 @@ namespace Harness {
|
||||
return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : "";
|
||||
}
|
||||
|
||||
export function doSourcemapBaseline(baselinePath: string, options: ts.CompilerOptions, result: CompilerResult) {
|
||||
export function doSourcemapBaseline(baselinePath: string, options: ts.CompilerOptions, result: CompilerResult, harnessSettings: Harness.TestCaseParser.CompilerSettings) {
|
||||
if (options.inlineSourceMap) {
|
||||
if (result.sourceMaps.length > 0) {
|
||||
throw new Error("No sourcemap files should be generated if inlineSourceMaps was set.");
|
||||
@@ -1567,10 +1591,8 @@ namespace Harness {
|
||||
}
|
||||
|
||||
let sourceMapCode = "";
|
||||
for (let i = 0; i < result.sourceMaps.length; i++) {
|
||||
sourceMapCode += "//// [" + Harness.Path.getFileName(result.sourceMaps[i].fileName) + "]\r\n";
|
||||
sourceMapCode += getByteOrderMarkText(result.sourceMaps[i]);
|
||||
sourceMapCode += result.sourceMaps[i].code;
|
||||
for (const sourceMap of result.sourceMaps) {
|
||||
sourceMapCode += fileOutput(sourceMap, harnessSettings);
|
||||
}
|
||||
|
||||
return sourceMapCode;
|
||||
@@ -1591,23 +1613,19 @@ namespace Harness {
|
||||
tsCode += "//// [" + header + "] ////\r\n\r\n";
|
||||
}
|
||||
for (let i = 0; i < tsSources.length; i++) {
|
||||
tsCode += "//// [" + Harness.Path.getFileName(tsSources[i].unitName) + "]\r\n";
|
||||
tsCode += "//// [" + ts.getBaseFileName(tsSources[i].unitName) + "]\r\n";
|
||||
tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? "\r\n" : "");
|
||||
}
|
||||
|
||||
let jsCode = "";
|
||||
for (let i = 0; i < result.files.length; i++) {
|
||||
jsCode += "//// [" + Harness.Path.getFileName(result.files[i].fileName) + "]\r\n";
|
||||
jsCode += getByteOrderMarkText(result.files[i]);
|
||||
jsCode += result.files[i].code;
|
||||
for (const file of result.files) {
|
||||
jsCode += fileOutput(file, harnessSettings);
|
||||
}
|
||||
|
||||
if (result.declFilesCode.length > 0) {
|
||||
jsCode += "\r\n\r\n";
|
||||
for (let i = 0; i < result.declFilesCode.length; i++) {
|
||||
jsCode += "//// [" + Harness.Path.getFileName(result.declFilesCode[i].fileName) + "]\r\n";
|
||||
jsCode += getByteOrderMarkText(result.declFilesCode[i]);
|
||||
jsCode += result.declFilesCode[i].code;
|
||||
for (const declFile of result.declFilesCode) {
|
||||
jsCode += fileOutput(declFile, harnessSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1632,9 +1650,14 @@ namespace Harness {
|
||||
});
|
||||
}
|
||||
|
||||
function fileOutput(file: GeneratedFile, harnessSettings: Harness.TestCaseParser.CompilerSettings): string {
|
||||
const fileName = harnessSettings["fullEmitPaths"] ? file.fileName : ts.getBaseFileName(file.fileName);
|
||||
return "//// [" + fileName + "]\r\n" + getByteOrderMarkText(file) + file.code;
|
||||
}
|
||||
|
||||
export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string {
|
||||
// Collect, test, and sort the fileNames
|
||||
outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName)));
|
||||
outputFiles.sort((a, b) => ts.compareStrings(cleanName(a.fileName), cleanName(b.fileName)));
|
||||
|
||||
// Emit them
|
||||
let result = "";
|
||||
@@ -1659,9 +1682,9 @@ namespace Harness {
|
||||
}
|
||||
|
||||
// This does not need to exist strictly speaking, but many tests will need to be updated if it's removed
|
||||
export function compileString(code: string, unitName: string, callback: (result: CompilerResult) => void) {
|
||||
export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) {
|
||||
// NEWTODO: Re-implement 'compileString'
|
||||
throw new Error("compileString NYI");
|
||||
return ts.notImplemented();
|
||||
}
|
||||
|
||||
export interface GeneratedFile {
|
||||
@@ -1748,7 +1771,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
// Regex for parsing options in the format "@Alpha: Value of any sort"
|
||||
const optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
const optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*([^\r\n]*)/gm; // multiple matches on multiple lines
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSettings {
|
||||
const opts: CompilerSettings = {};
|
||||
@@ -1757,7 +1780,7 @@ namespace Harness {
|
||||
/* tslint:disable:no-null-keyword */
|
||||
while ((match = optionRegex.exec(content)) !== null) {
|
||||
/* tslint:enable:no-null-keyword */
|
||||
opts[match[1]] = match[2];
|
||||
opts[match[1]] = match[2].trim();
|
||||
}
|
||||
|
||||
return opts;
|
||||
@@ -1785,7 +1808,7 @@ namespace Harness {
|
||||
// Comment line, check for global/file @options and record them
|
||||
optionRegex.lastIndex = 0;
|
||||
const metaDataName = testMetaData[1].toLowerCase();
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2];
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2].trim();
|
||||
if (metaDataName !== "filename") {
|
||||
continue;
|
||||
}
|
||||
@@ -1805,12 +1828,12 @@ namespace Harness {
|
||||
// Reset local data
|
||||
currentFileContent = undefined;
|
||||
currentFileOptions = {};
|
||||
currentFileName = testMetaData[2];
|
||||
currentFileName = testMetaData[2].trim();
|
||||
refs = [];
|
||||
}
|
||||
else {
|
||||
// First metadata marker in the file
|
||||
currentFileName = testMetaData[2];
|
||||
currentFileName = testMetaData[2].trim();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1828,7 +1851,7 @@ namespace Harness {
|
||||
}
|
||||
|
||||
// normalize the fileName for the single file case
|
||||
currentFileName = testUnitData.length > 0 || currentFileName ? currentFileName : Path.getFileName(fileName);
|
||||
currentFileName = testUnitData.length > 0 || currentFileName ? currentFileName : ts.getBaseFileName(fileName);
|
||||
|
||||
// EOF, push whatever remains
|
||||
const newTestFile2 = {
|
||||
@@ -1843,8 +1866,8 @@ namespace Harness {
|
||||
// unit tests always list files explicitly
|
||||
const parseConfigHost: ts.ParseConfigHost = {
|
||||
useCaseSensitiveFileNames: false,
|
||||
readDirectory: (name) => [],
|
||||
fileExists: (name) => true,
|
||||
readDirectory: () => [],
|
||||
fileExists: () => true,
|
||||
readFile: (name) => ts.forEach(testUnitData, data => data.name.toLowerCase() === name.toLowerCase() ? data.content : undefined)
|
||||
};
|
||||
|
||||
@@ -1992,7 +2015,7 @@ namespace Harness {
|
||||
|
||||
export function isDefaultLibraryFile(filePath: string): boolean {
|
||||
// We need to make sure that the filePath is prefixed with "lib." not just containing "lib." and end with ".d.ts"
|
||||
const fileName = Path.getFileName(filePath);
|
||||
const fileName = ts.getBaseFileName(ts.normalizeSlashes(filePath));
|
||||
return ts.startsWith(fileName, "lib.") && ts.endsWith(fileName, ".d.ts");
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Harness.LanguageService {
|
||||
throw new Error("No script with name '" + fileName + "'");
|
||||
}
|
||||
|
||||
public openFile(fileName: string, content?: string, scriptKindName?: string): void {
|
||||
public openFile(_fileName: string, _content?: string, _scriptKindName?: string): void {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +198,7 @@ namespace Harness.LanguageService {
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? new ScriptSnapshot(script) : undefined;
|
||||
}
|
||||
getScriptKind(fileName: string): ts.ScriptKind { return ts.ScriptKind.Unknown; }
|
||||
getScriptKind(): ts.ScriptKind { return ts.ScriptKind.Unknown; }
|
||||
getScriptVersion(fileName: string): string {
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? script.version.toString() : undefined;
|
||||
@@ -214,7 +214,7 @@ namespace Harness.LanguageService {
|
||||
this.getCurrentDirectory(),
|
||||
(p) => this.virtualFileSystem.getAccessibleFileSystemEntries(p));
|
||||
}
|
||||
readFile(path: string, encoding?: string): string {
|
||||
readFile(path: string): string {
|
||||
const snapshot = this.getScriptSnapshot(path);
|
||||
return snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
@@ -223,9 +223,9 @@ namespace Harness.LanguageService {
|
||||
}
|
||||
|
||||
|
||||
log(s: string): void { }
|
||||
trace(s: string): void { }
|
||||
error(s: string): void { }
|
||||
log(_: string): void { }
|
||||
trace(_: string): void { }
|
||||
error(_: string): void { }
|
||||
}
|
||||
|
||||
export class NativeLanguageServiceAdapter implements LanguageServiceAdapter {
|
||||
@@ -308,19 +308,15 @@ namespace Harness.LanguageService {
|
||||
const nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
|
||||
}
|
||||
getScriptKind(fileName: string): ts.ScriptKind { return this.nativeHost.getScriptKind(fileName); }
|
||||
getScriptKind(): ts.ScriptKind { return this.nativeHost.getScriptKind(); }
|
||||
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
|
||||
getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); }
|
||||
|
||||
readDirectory(rootDir: string, extension: string): string {
|
||||
throw new Error("NYI");
|
||||
}
|
||||
readDirectoryNames(path: string): string {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
readFileNames(path: string): string {
|
||||
throw new Error("Not implemented.");
|
||||
readDirectory(_rootDir: string, _extension: string): string {
|
||||
return ts.notImplemented();
|
||||
}
|
||||
readDirectoryNames = ts.notImplemented;
|
||||
readFileNames = ts.notImplemented;
|
||||
fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; }
|
||||
readFile(fileName: string) {
|
||||
const snapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
@@ -329,7 +325,7 @@ namespace Harness.LanguageService {
|
||||
log(s: string): void { this.nativeHost.log(s); }
|
||||
trace(s: string): void { this.nativeHost.trace(s); }
|
||||
error(s: string): void { this.nativeHost.error(s); }
|
||||
directoryExists(directoryName: string): boolean {
|
||||
directoryExists(): boolean {
|
||||
// for tests pessimistically assume that directory always exists
|
||||
return true;
|
||||
}
|
||||
@@ -338,8 +334,8 @@ namespace Harness.LanguageService {
|
||||
class ClassifierShimProxy implements ts.Classifier {
|
||||
constructor(private shim: ts.ClassifierShim) {
|
||||
}
|
||||
getEncodedLexicalClassifications(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.Classifications {
|
||||
throw new Error("NYI");
|
||||
getEncodedLexicalClassifications(_text: string, _lexState: ts.EndOfLineState, _classifyKeywordsInGenerics?: boolean): ts.Classifications {
|
||||
return ts.notImplemented();
|
||||
}
|
||||
getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult {
|
||||
const result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split("\n");
|
||||
@@ -411,7 +407,7 @@ namespace Harness.LanguageService {
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): ts.CompletionEntryDetails {
|
||||
return unwrapJSONCallResult(this.shim.getCompletionEntryDetails(fileName, position, entryName));
|
||||
}
|
||||
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): ts.Symbol {
|
||||
getCompletionEntrySymbol(): ts.Symbol {
|
||||
throw new Error("getCompletionEntrySymbol not implemented across the shim layer.");
|
||||
}
|
||||
getQuickInfoAtPosition(fileName: string, position: number): ts.QuickInfo {
|
||||
@@ -490,7 +486,7 @@ namespace Harness.LanguageService {
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
|
||||
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace));
|
||||
}
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] {
|
||||
getCodeFixesAtPosition(): ts.CodeAction[] {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
getEmitOutput(fileName: string): ts.EmitOutput {
|
||||
@@ -499,10 +495,10 @@ namespace Harness.LanguageService {
|
||||
getProgram(): ts.Program {
|
||||
throw new Error("Program can not be marshaled across the shim layer.");
|
||||
}
|
||||
getNonBoundSourceFile(fileName: string): ts.SourceFile {
|
||||
getNonBoundSourceFile(): ts.SourceFile {
|
||||
throw new Error("SourceFile can not be marshaled across the shim layer.");
|
||||
}
|
||||
getSourceFile(fileName: string): ts.SourceFile {
|
||||
getSourceFile(): ts.SourceFile {
|
||||
throw new Error("SourceFile can not be marshaled across the shim layer.");
|
||||
}
|
||||
dispose(): void { this.shim.dispose({}); }
|
||||
@@ -572,11 +568,11 @@ namespace Harness.LanguageService {
|
||||
super(cancellationToken, settings);
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
onMessage(): void {
|
||||
|
||||
}
|
||||
|
||||
writeMessage(message: string): void {
|
||||
writeMessage(): void {
|
||||
|
||||
}
|
||||
|
||||
@@ -604,11 +600,11 @@ namespace Harness.LanguageService {
|
||||
this.newLine = this.host.getNewLine();
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
onMessage(): void {
|
||||
|
||||
}
|
||||
|
||||
writeMessage(message: string): void {
|
||||
writeMessage(_message: string): void {
|
||||
}
|
||||
|
||||
write(message: string): void {
|
||||
@@ -624,7 +620,7 @@ namespace Harness.LanguageService {
|
||||
return snapshot && snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
|
||||
writeFile(name: string, text: string, writeByteOrderMark: boolean): void {
|
||||
writeFile(): void {
|
||||
}
|
||||
|
||||
resolvePath(path: string): string {
|
||||
@@ -635,7 +631,7 @@ namespace Harness.LanguageService {
|
||||
return !!this.host.getScriptSnapshot(path);
|
||||
}
|
||||
|
||||
directoryExists(path: string): boolean {
|
||||
directoryExists(): boolean {
|
||||
// for tests assume that directory exists
|
||||
return true;
|
||||
}
|
||||
@@ -644,18 +640,18 @@ namespace Harness.LanguageService {
|
||||
return "";
|
||||
}
|
||||
|
||||
exit(exitCode: number): void {
|
||||
exit(): void {
|
||||
}
|
||||
|
||||
createDirectory(directoryName: string): void {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
createDirectory(_directoryName: string): void {
|
||||
return ts.notImplemented();
|
||||
}
|
||||
|
||||
getCurrentDirectory(): string {
|
||||
return this.host.getCurrentDirectory();
|
||||
}
|
||||
|
||||
getDirectories(path: string): string[] {
|
||||
getDirectories(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -663,16 +659,16 @@ namespace Harness.LanguageService {
|
||||
return ts.sys.getEnvironmentVariable(name);
|
||||
}
|
||||
|
||||
readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]): string[] {
|
||||
throw new Error("Not implemented Yet.");
|
||||
readDirectory(_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] {
|
||||
return ts.notImplemented();
|
||||
}
|
||||
|
||||
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
watchFile(): ts.FileWatcher {
|
||||
return { close: ts.noop };
|
||||
}
|
||||
|
||||
watchDirectory(path: string, callback: (path: string) => void, recursive?: boolean): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
watchDirectory(): ts.FileWatcher {
|
||||
return { close: ts.noop };
|
||||
}
|
||||
|
||||
close(): void {
|
||||
@@ -717,13 +713,17 @@ namespace Harness.LanguageService {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
setImmediate(callback: (...args: any[]) => void, ms: number, ...args: any[]): any {
|
||||
setImmediate(callback: (...args: any[]) => void, _ms: number, ...args: any[]): any {
|
||||
return setImmediate(callback, args);
|
||||
}
|
||||
|
||||
clearImmediate(timeoutId: any): void {
|
||||
clearImmediate(timeoutId);
|
||||
}
|
||||
|
||||
createHash(s: string) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
export class ServerLanguageServiceAdapter implements LanguageServiceAdapter {
|
||||
@@ -760,6 +760,6 @@ namespace Harness.LanguageService {
|
||||
getHost() { return this.host; }
|
||||
getLanguageService(): ts.LanguageService { return this.client; }
|
||||
getClassifier(): ts.Classifier { throw new Error("getClassifier is not available using the server interface."); }
|
||||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); }
|
||||
getPreProcessedFileInfo(): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); }
|
||||
}
|
||||
}
|
||||
|
||||
+15
-11
@@ -173,7 +173,7 @@ namespace Playback {
|
||||
path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }),
|
||||
memoize(path => {
|
||||
// If we read from the file, it must exist
|
||||
if (findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) {
|
||||
if (findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -217,7 +217,7 @@ namespace Playback {
|
||||
recordLog.filesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
memoize(path => findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents));
|
||||
memoize(path => findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents));
|
||||
|
||||
wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)(
|
||||
(path, extensions, exclude, include) => {
|
||||
@@ -226,7 +226,7 @@ namespace Playback {
|
||||
recordLog.directoriesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
(path, extensions, exclude) => {
|
||||
path => {
|
||||
// Because extensions is an array of all allowed extension, we will want to merge each of the replayLog.directoriesRead into one
|
||||
// if each of the directoriesRead has matched path with the given path (directory with same path but different extension will considered
|
||||
// different entry).
|
||||
@@ -244,7 +244,7 @@ namespace Playback {
|
||||
|
||||
wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
|
||||
(path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),
|
||||
(path: string, contents: string) => noOpReplay("writeFile"));
|
||||
() => noOpReplay("writeFile"));
|
||||
|
||||
wrapper.exit = (exitCode) => {
|
||||
if (recordLog !== undefined) {
|
||||
@@ -295,7 +295,7 @@ namespace Playback {
|
||||
return results[0].result;
|
||||
}
|
||||
|
||||
function findFileByPath(wrapper: { resolvePath(s: string): string }, logArray: IOLogFile[],
|
||||
function findFileByPath(logArray: IOLogFile[],
|
||||
expectedPath: string, throwFileNotFoundError: boolean): FileInformation {
|
||||
const normalizedName = ts.normalizePath(expectedPath).toLowerCase();
|
||||
// Try to find the result through normal fileName
|
||||
@@ -314,7 +314,7 @@ namespace Playback {
|
||||
}
|
||||
}
|
||||
|
||||
function noOpReplay(name: string) {
|
||||
function noOpReplay(_name: string) {
|
||||
// console.log("Swallowed write operation during replay: " + name);
|
||||
}
|
||||
|
||||
@@ -322,13 +322,17 @@ namespace Playback {
|
||||
const wrapper: PlaybackIO = <any>{};
|
||||
initWrapper(wrapper, underlying);
|
||||
|
||||
wrapper.directoryName = (path): string => { throw new Error("NotSupported"); };
|
||||
wrapper.createDirectory = (path): void => { throw new Error("NotSupported"); };
|
||||
wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); };
|
||||
wrapper.deleteFile = (path): void => { throw new Error("NotSupported"); };
|
||||
wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); };
|
||||
wrapper.directoryName = notSupported;
|
||||
wrapper.createDirectory = notSupported;
|
||||
wrapper.directoryExists = notSupported;
|
||||
wrapper.deleteFile = notSupported;
|
||||
wrapper.listFiles = notSupported;
|
||||
|
||||
return wrapper;
|
||||
|
||||
function notSupported(): never {
|
||||
throw new Error("NotSupported");
|
||||
}
|
||||
}
|
||||
|
||||
export function wrapSystem(underlying: ts.System): PlaybackSystem {
|
||||
|
||||
@@ -178,7 +178,7 @@ class ProjectRunner extends RunnerBase {
|
||||
function createCompilerHost(): ts.CompilerHost {
|
||||
return {
|
||||
getSourceFile,
|
||||
getDefaultLibFileName: options => Harness.Compiler.defaultLibFileName,
|
||||
getDefaultLibFileName: () => Harness.Compiler.defaultLibFileName,
|
||||
writeFile,
|
||||
getCurrentDirectory,
|
||||
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
|
||||
@@ -421,7 +421,7 @@ class ProjectRunner extends RunnerBase {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
function writeFile() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user