diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..7ab071b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,16 @@ +deploy: + image: greycat/linux-x64 + stage: deploy + only: + - master + script: + - export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") + - export GIT_LAST_TAG=`git describe --abbrev=0 --tags` + - export GIT_COMMITS_SINCE_LAST_TAG=`git rev-list ${GIT_LAST_TAG}..HEAD --count` + - export GIT_COMMIT_ID=`git rev-parse --short HEAD` + - export REPO_VERSION="${GIT_LAST_TAG}.${GIT_COMMITS_SINCE_LAST_TAG}" + - echo "VERSION=${REPO_VERSION}" +# - mvn licence:format +# - mvn versions:set -DnewVersion="${REPO_VERSION}" +# - mvn clean install +# - mvn ${MAVEN_CLI_OPTS} ${MAVEN_OPTS} deploy:deploy -DaltDeploymentRepository=greycat-core::https://dist.datathings.com/repository/greycat-core-maven diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..604db0a --- /dev/null +++ b/AUTHORS @@ -0,0 +1,14 @@ +# This is the official list of GreyCat authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS files. +# See the latter for an explanation. + +# Names should be added to this file as: +# Name or Organization +# The email address is not required for organizations. + +DataThings +University of Luxembourg +Francois Fouquet (fouquet.f@gmail.com) +Thomas Hartmann (thomi.hartmann@gmail.com) +Assaad Mouawad (assaadmouawad@gmail.com) +Gregory Nain (gregory.nain@gmail.com) \ No newline at end of file diff --git a/HEADER b/HEADER new file mode 100644 index 0000000..09bedc2 --- /dev/null +++ b/HEADER @@ -0,0 +1,13 @@ +Copyright 2017 The Java2TypeScript Authors. All rights reserved. +

+Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at +

+http://www.apache.org/licenses/LICENSE-2.0 +

+Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/LICENSE b/LICENSE index 6b156fe..384ef73 100644 --- a/LICENSE +++ b/LICENSE @@ -1,675 +1,193 @@ -GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - {project} Copyright (C) {year} {fullname} - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. - +Copyright 2017 The Java2TypeScript Authors. All rights reserved. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2017, The Java2TypeScript Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index aca691c..2b60b1d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,91 @@ -java2typescript -=============== +```diff +- This repository contains the legacy version of GreyCat. +! DataThings crew is about to disclose a new, faster, ligher native GreyCat. Stay tuned and follow us on twitter/facebook or +``` + +# Java To TypeScript Transpiler + +This project is a transpiler able to transform your Java codebase to TypeScript and then to JavaScript to ultimatly run Java code in the browser. + +> NB: **JDK 8 or below** + +### What is it for ? + +The goal of J2TS is to share a codebase between Java, TypeScript and Javascript. +This is especially helpful for sharing domain classes, data structures, and complex algorithms. + +### What is it not for ? + +The goal of J2TS is not to develop a UI in Java. There are better projects for this. +J2TS focus on performance and readability of the generated TypeScript code. + +### Getting Started + +The easiest way to get started with J2TS is using the maven plugin. +Hereafter is a simple snippet of usage: + +```xml + + com.datathings + j2ts-mavenplugin + ${j2ts.version} + + + transpile + + java2ts + + + sample + true + + + + +``` + +By default the Java source directory is ```src/main/java``` and the generated-sources is ```target/generated-sources/java2ts```. + +These values can be overriden as follows: + +```xml +${basedir}/../api/src/main/java +${basedir}/target/generated-sources +``` + +### Sample project + +A full sample project is hosted [here](https://github.com/datathings/java2typescript/raw/master/sample.zip) + +This project can be compiled through the following command +```sh +mvn clean install +``` + +> Make sure you have NodeJS, NPM and TypeScript installed on your system. To install TypeScript just tape the following command in your console: + +``` +npm i -g typescript +``` + +Then go to the ```target/classes``` directory and open the ```index.html``` in you browser to see how to use the generated code. + +### Limitations + +Currently, in order to keep the JRE.js as lightweight as possible, only a subSet of the JRE is supported. +For instance, we support most common structures sucj as ArrayList and HashMap, but not all advanced once such as ConcurrentQueue and so on. +However, if you face a limitation due to the lake of one JRE class, don't worry this is very easy to extend. + +In a nutshell, update the base JRE.TS file here: +``` +transpiler/src/main/resources/java.ts +``` + +To add your class with the same name than in Java. +Finally in case of inferred package please also update this class: + +``` +transpiler/src/main/java/java2typescript/helper/TypeHelper.java#L162 +``` + +Finally to provide a new JRE class permanently, please do a push request. diff --git a/deploy.sh b/deploy.sh index c1904cb..d2a0cf2 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,20 +1,28 @@ # -# Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; +# Copyright 2017 The Java2TypeScript Authors. 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.gnu.org/licenses/lgpl-3.0.txt -# +#

+# http://www.apache.org/licenses/LICENSE-2.0 +#

# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # -# Authors: -# Fouquet Francois -# Nain Gregory -# -export JAVA_HOME=$(/usr/libexec/java_home) -mvn clean deploy \ No newline at end of file + +export GIT_LAST_TAG=`git describe --abbrev=0 --tags` +export GIT_COMMITS_SINCE_LAST_TAG=`git rev-list ${GIT_LAST_TAG}..HEAD --count` +export GIT_COMMIT_ID=`git rev-parse --short HEAD` +export REPO_VERSION="${GIT_LAST_TAG}.${GIT_COMMITS_SINCE_LAST_TAG}" +echo "VERSION=${REPO_VERSION}" + +mvn licence:format +mvn versions:set -DnewVersion="${REPO_VERSION}" +mvn clean install + +mvn ${MAVEN_CLI_OPTS} ${MAVEN_OPTS} deploy:deploy-file -DpomFile=pom.xml -Dfile=../../dist/${GREYCAT_VERSION}/core-${GREYCAT_VERSION}.jar -Dsources=../../dist/${GREYCAT_VERSION}/core-${GREYCAT_VERSION}-sources.jar -DrepositoryId=greycat-core -Durl=https://dist.datathings.com/repository/greycat-core-maven diff --git a/install.sh b/install.sh deleted file mode 100755 index 92a4920..0000000 --- a/install.sh +++ /dev/null @@ -1,21 +0,0 @@ -# -# Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.gnu.org/licenses/lgpl-3.0.txt -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Authors: -# Fouquet Francois -# Nain Gregory -# - -export JAVA_HOME=$(/usr/libexec/java_home) -export MAVEN_OPTS="-Xmx3000m -XX:MaxPermSize=256m" -mvn clean install \ No newline at end of file diff --git a/org.kevoree.modeling.java2typescript.mavenplugin/pom.xml b/mavenplugin/pom.xml similarity index 61% rename from org.kevoree.modeling.java2typescript.mavenplugin/pom.xml rename to mavenplugin/pom.xml index 19cb733..85ffd0e 100644 --- a/org.kevoree.modeling.java2typescript.mavenplugin/pom.xml +++ b/mavenplugin/pom.xml @@ -1,27 +1,43 @@ + 4.0.0 - org.kevoree.modeling.java2typescript.root - org.kevoree.modeling - 28-SNAPSHOT + j2ts-parent + com.datathings + 98.0.1-SNAPSHOT ../pom.xml - org.kevoree.modeling.java2typescript.mavenplugin - Kevoree :: Modeling :: Java2TypeScript :: MavenPlugin + j2ts-mavenplugin + j2ts-mavenplugin maven-plugin + + ${basedir}/../HEADER + + - de.flapdoodle.embed - de.flapdoodle.embed.nodejs - 1.28 - - - org.kevoree.modeling - org.kevoree.modeling.java2typescript + com.datathings + j2ts-transpiler ${project.parent.version} @@ -39,7 +55,7 @@ org.apache.maven.plugin-tools maven-plugin-annotations - 3.3 + 3.6.0 provided @@ -49,7 +65,7 @@ org.apache.maven.plugins maven-plugin-plugin - 3.3 + 3.6.0 true diff --git a/mavenplugin/src/main/java/java2typescript/mavenplugin/Dependency.java b/mavenplugin/src/main/java/java2typescript/mavenplugin/Dependency.java new file mode 100755 index 0000000..dd63d7b --- /dev/null +++ b/mavenplugin/src/main/java/java2typescript/mavenplugin/Dependency.java @@ -0,0 +1,35 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.mavenplugin; + +public class Dependency { + + private String name; + private String version; + public String getVersion() { + return version; + } + public void setVersion(String version) { + this.version = version; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + +} diff --git a/mavenplugin/src/main/java/java2typescript/mavenplugin/Java2TSPlugin.java b/mavenplugin/src/main/java/java2typescript/mavenplugin/Java2TSPlugin.java new file mode 100755 index 0000000..671dd71 --- /dev/null +++ b/mavenplugin/src/main/java/java2typescript/mavenplugin/Java2TSPlugin.java @@ -0,0 +1,146 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.mavenplugin; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import java2typescript.FlatJUnitGenerator; +import java2typescript.SourceTranslator; + +import java.io.*; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Mojo(name = "java2ts", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) +public class Java2TSPlugin extends AbstractMojo { + + @Parameter(defaultValue = "${project}", required = true, readonly = true) + private MavenProject project; + + @Parameter(defaultValue = "${project.basedir}/src/main/java") + protected File source; + + @Parameter() + protected List sources = new ArrayList<>(); + + @Parameter(defaultValue = "${project.build.directory}/generated-sources/java2ts") + protected File target; + + @Parameter(defaultValue = "${project.artifactId}") + private String name; + + @Parameter(defaultValue = "${project.artifactId}") + private String packageName; + + @Parameter(defaultValue = "${project.version}") + private String packageVersion; + + @Parameter + private List dependencies = new ArrayList(); + + @Parameter + private List headers = new ArrayList(); + + @Parameter + private List testHeaders = new ArrayList(); + + @Parameter + private Map pkgTransforms = new HashMap(); + + @Parameter + private boolean withJUnit = false; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + List sources = new ArrayList<>(); + if (sources.isEmpty()) { + sources.add(source.getAbsolutePath()); + } else { + sources.addAll(this.sources.stream().map(File::getAbsolutePath).collect(Collectors.toList())); + } + + SourceTranslator sourceTranslator = new SourceTranslator(sources, target.getPath(), name); + headers.forEach(sourceTranslator::addHeader); + /*if (copyJRE) { + sourceTranslator.addHeader("./jre.ts"); + }*/ + + /* + if (copyJunit) { + sourceTranslator.addHeader("./junit.ts"); + } + */ + pkgTransforms.forEach(sourceTranslator::addPackageTransform); + + String outDir = project.getBuild().getOutputDirectory(); + sourceTranslator.addToClasspath(outDir); + getLog().info(outDir + " added to Java2TS analyzer"); + + for (Artifact a : project.getDependencyArtifacts()) { + File file = a.getFile(); + if (file != null) { + if (file.isFile()) { + sourceTranslator.addToClasspath(file.getAbsolutePath()); + getLog().info(file.getAbsolutePath() + " added to Java2TS analyzer"); + } + } + } + for (Artifact a : project.getArtifacts()) { + File file = a.getFile(); + if (file != null) { + if (file.isFile()) { + sourceTranslator.addToClasspath(file.getAbsolutePath()); + getLog().info(file.getAbsolutePath() + " added to Java2TS analyzer"); + } + } + } + sourceTranslator.process(); + sourceTranslator.generate(); + + /* + if (copyJRE) { + try { + Files.copy(getClass().getClassLoader().getResourceAsStream("java.ts"), Paths.get(target.getAbsolutePath(), "jre.ts"), StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + e.printStackTrace(); + } + }*/ + + //Generate tests + + if (withJUnit) { + try { + FlatJUnitGenerator generator = new FlatJUnitGenerator(); + generator.headers = testHeaders; + generator.generate(source, Paths.get(target.getAbsolutePath()).toFile()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + } +} \ No newline at end of file diff --git a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/ExtractDependencies.java b/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/ExtractDependencies.java deleted file mode 100644 index 6deffd1..0000000 --- a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/ExtractDependencies.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.kevoree.modeling.java2typescript.mavenplugin; - -import org.apache.commons.io.IOUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.plugins.annotations.ResolutionScope; -import org.apache.maven.project.MavenProject; - -import java.io.*; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -/** - * Created by duke on 18/03/15. - */ -@Mojo(name = "extract", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) -public class ExtractDependencies extends AbstractMojo { - - /** - * The maven project. - */ - @Parameter(defaultValue = "${project}", required = true, readonly = true) - private MavenProject project; - - /** - * Source base directory - */ - @Parameter(defaultValue = "${project.basedir}/src/main/resources") - private File target; - - @Parameter - private String[] excludes; - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - getLog().info("Extracting .js and .ts files from dependencies...."); - for (Artifact artifact : project.getArtifacts()) { - File currentArte = artifact.getFile(); - if (currentArte.exists() && currentArte.getName().endsWith(".jar")) { - unzipArchive(currentArte, target); - } - } - } - - public void unzipArchive(File archive, File outputDir) { - try { - ZipFile zipfile = new ZipFile(archive); - for (Enumeration e = zipfile.entries(); e.hasMoreElements(); ) { - ZipEntry entry = (ZipEntry) e.nextElement(); - - boolean isExclude = false; - if (excludes != null) { - for (int i = 0; i < excludes.length; i++) { - isExclude = isExclude || entry.getName().matches(excludes[i]); - } - } - if(!isExclude){ - getLog().info("Extracting " + entry.getName()); - if (entry.getName().endsWith(".js") || entry.getName().endsWith(".ts")) { - unzipEntry(zipfile, entry, outputDir); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir) throws IOException { - if (entry.isDirectory()) { - createDir(new File(outputDir, entry.getName())); - return; - } - File outputFile = new File(outputDir, entry.getName()); - if (!outputFile.getParentFile().exists()) { - createDir(outputFile.getParentFile()); - } - BufferedInputStream inputStream = new BufferedInputStream(zipfile.getInputStream(entry)); - BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile)); - try { - IOUtils.copy(inputStream, outputStream); - } finally { - outputStream.close(); - inputStream.close(); - } - } - - private void createDir(File dir) { - if (!dir.mkdirs()) throw new RuntimeException("Can not create dir " + dir); - } - -} diff --git a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/MMCompilePlugin.java b/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/MMCompilePlugin.java deleted file mode 100644 index d4d37a5..0000000 --- a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/MMCompilePlugin.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.kevoree.modeling.java2typescript.mavenplugin; - -import org.apache.maven.artifact.Artifact; -import org.kevoree.modeling.java2typescript.FlatJUnitGenerator; -import org.kevoree.modeling.java2typescript.SourceTranslator; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.plugins.annotations.ResolutionScope; -import org.apache.maven.project.MavenProject; - -import java.io.*; -import java.nio.file.Paths; - -@Mojo(name = "generate", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) -public class MMCompilePlugin extends AbstractMojo { - - /** - * Src file - */ - @Parameter - private File source; - - /** - * Target directory - */ - @Parameter - private File target; - - /** - * Target directory - */ - @Parameter(defaultValue = "${project.artifactId}") - private String projectName; - - /** - * The maven project. - */ - @Parameter(defaultValue = "${project}", required = true, readonly = true) - private MavenProject project; - - /** - * Target js directory - */ - @Parameter - private File targetJS; - - @Parameter - private boolean flatJUnit = false; - - @Parameter - private File[] libraries; - - @Parameter - private boolean copyLibDTs = true; - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - source.mkdirs(); - target.mkdirs(); - if (targetJS != null) { - targetJS.mkdirs(); - } - String flatJunitGenDir = null; - if (flatJUnit) { - flatJunitGenDir = Paths.get(Paths.get(project.getBuild().getOutputDirectory()).getParent().toString(), "gen-jstest").toString(); - FlatJUnitGenerator testGenerator = new FlatJUnitGenerator(); - testGenerator.generate(source, new File(flatJunitGenDir + File.separator + "gentest")); - } - - SourceTranslator sourceTranslator = new SourceTranslator(); - for (Artifact a : project.getDependencyArtifacts()) { - File file = a.getFile(); - if (file != null) { - sourceTranslator.getAnalyzer().addClasspath(file.getAbsolutePath()); - getLog().info("Add to classpath " + file.getAbsolutePath()); - } - } - try { - sourceTranslator.translateSources(source.getPath(), target.getPath(), projectName); - if (flatJUnit) { - sourceTranslator.translateSources(new File(flatJunitGenDir).getPath(), target.getPath(), "TestRunner"); - } - } catch (IOException e) { - e.printStackTrace(); - throw new MojoExecutionException(e.getMessage()); - } - if (targetJS != null) { - try { - TSCRunner.run(target, targetJS, libraries, copyLibDTs); - } catch (Exception e) { - throw new MojoExecutionException("TypeScript compilation failed !", e); - } - } - - } - -} \ No newline at end of file diff --git a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/TSCRunner.java b/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/TSCRunner.java deleted file mode 100644 index 5b6f492..0000000 --- a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/TSCRunner.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.kevoree.modeling.java2typescript.mavenplugin; - -import de.flapdoodle.embed.nodejs.*; -import de.flapdoodle.embed.process.config.IRuntimeConfig; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.Arrays; - -/** - * Created by duke on 08/12/14. - */ -public class TSCRunner { - - public static void run(File src, File target, File[] libraries, boolean copyLibDTs) throws Exception { - IRuntimeConfig runtimeConfig = (new NodejsRuntimeConfigBuilder()).defaults().build(); - NodejsProcess node = null; - ArrayList paramsCol = new ArrayList(); - File[] files = src.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].getName().endsWith(".ts")) { - paramsCol.add(files[i].getAbsolutePath()); - } - } - if (libraries != null) { - for (int i = 0; i < libraries.length; i++) { - File[] lib = libraries[i].listFiles(); - for (int j = 0; j < lib.length; j++) { - if (lib[j].getName().endsWith(".ts")) { - paramsCol.add(lib[j].getAbsolutePath()); - } - } - } - } - - File targetTSCBIN = new File(target, "tsc.js"); - targetTSCBIN.deleteOnExit(); - Files.copy(TSCRunner.class.getClassLoader().getResourceAsStream("tsc.js"), targetTSCBIN.toPath(), StandardCopyOption.REPLACE_EXISTING); - - if (copyLibDTs) { - File targetLIBD = new File(target, "lib.d.ts"); - targetLIBD.deleteOnExit(); - Files.copy(TSCRunner.class.getClassLoader().getResourceAsStream("lib.d.ts"), targetLIBD.toPath(), StandardCopyOption.REPLACE_EXISTING); - boolean founded = false; - for (String alreadyAdded : paramsCol) { - if (alreadyAdded.endsWith("lib.d.ts")) { - founded = true; - } - } - if (!founded) { - paramsCol.add(targetLIBD.getAbsolutePath()); - } - } - - paramsCol.add("--outDir"); - paramsCol.add(target.getAbsolutePath()); - - paramsCol.add("-d"); - - NodejsConfig nodejsConfig = new NodejsConfig(NodejsVersion.Main.V0_10, targetTSCBIN.getAbsolutePath(), paramsCol, target.getAbsolutePath()); - NodejsStarter runtime = new NodejsStarter(runtimeConfig); - try { - NodejsExecutable e = runtime.prepare(nodejsConfig); - node = e.start(); - int retVal = node.waitFor(); - if (retVal != 0) { - throw new Exception("There were TypeScript compilation errors."); - } - } catch (InterruptedException var11) { - var11.printStackTrace(); - } finally { - if (node != null) { - node.stop(); - } - } - } - -} diff --git a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/TSCompilePlugin.java b/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/TSCompilePlugin.java deleted file mode 100644 index 0648336..0000000 --- a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/java/org/kevoree/modeling/java2typescript/mavenplugin/TSCompilePlugin.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.kevoree.modeling.java2typescript.mavenplugin; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.plugins.annotations.ResolutionScope; -import org.apache.maven.project.MavenProject; - -import java.io.*; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -/** - * Created by duke on 12/01/15. - */ -@Mojo(name = "tsc", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME) -public class TSCompilePlugin extends AbstractMojo { - - /** - * The maven project. - */ - @Parameter(defaultValue = "${project}", required = true, readonly = true) - private MavenProject project; - - @Parameter(defaultValue = "${project.build.directory}/classes") - protected File outputClasses; - - @Parameter(defaultValue = "${project.basedir}/src/main/ts") - protected File inputTS; - - @Parameter(defaultValue = "${project.basedir}/src/main/js") - protected File inputJS; - - @Parameter(defaultValue = "${project.build.directory}/js") - protected File outputTempJS; - - @Parameter - private File[] libraries; - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - if (!outputClasses.exists()) { - outputClasses.mkdirs(); - } - if (!outputTempJS.exists()) { - outputTempJS.mkdirs(); - } - if (!outputTempJS.exists()) { - outputTempJS.mkdirs(); - } - try { - if (inputTS.exists()) { - FileUtils.copyDirectory(inputTS, outputTempJS); - } - } catch (IOException e) { - e.printStackTrace(); - } - try { - if (inputJS.exists()) { - FileUtils.copyDirectory(inputJS, outputTempJS); - } - } catch (IOException e) { - e.printStackTrace(); - } - for (Artifact artifact : project.getArtifacts()) { - File target = artifact.getFile(); - if (target.exists() && target.getName().endsWith(".jar")) { - unzipArchive(target, outputTempJS); - } - } - try { - TSCRunner.run(outputTempJS, outputClasses, libraries, true); - } catch (Exception e) { - throw new MojoExecutionException("TypeScript compilation failed !", e); - } - } - - public void unzipArchive(File archive, File outputDir) { - try { - ZipFile zipfile = new ZipFile(archive); - for (Enumeration e = zipfile.entries(); e.hasMoreElements(); ) { - ZipEntry entry = (ZipEntry) e.nextElement(); - if (entry.getName().endsWith(".js") || entry.getName().endsWith(".ts")) { - unzipEntry(zipfile, entry, outputDir); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir) throws IOException { - if (entry.isDirectory()) { - createDir(new File(outputDir, entry.getName())); - return; - } - File outputFile = new File(outputDir, entry.getName()); - if (!outputFile.getParentFile().exists()) { - createDir(outputFile.getParentFile()); - } - BufferedInputStream inputStream = new BufferedInputStream(zipfile.getInputStream(entry)); - BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile)); - try { - IOUtils.copy(inputStream, outputStream); - } finally { - outputStream.close(); - inputStream.close(); - } - } - - private void createDir(File dir) { - if (!dir.mkdirs()) throw new RuntimeException("Can not create dir " + dir); - } - -} diff --git a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/resources/lib.d.ts b/org.kevoree.modeling.java2typescript.mavenplugin/src/main/resources/lib.d.ts deleted file mode 100755 index bd8e2cc..0000000 --- a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/resources/lib.d.ts +++ /dev/null @@ -1,14219 +0,0 @@ -/*! ***************************************************************************** -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. -***************************************************************************** */ - -/// - -///////////////////////////// -/// ECMAScript APIs -///////////////////////////// - -declare var NaN: number; -declare var Infinity: number; - -/** - * Evaluates JavaScript code and executes it. - * @param x A String value that contains valid JavaScript code. - */ -declare function eval(x: string): any; - -/** - * Converts A string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ -declare function parseInt(s: string, radix?: number): number; - -/** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ -declare function parseFloat(string: string): number; - -/** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). - * @param number A numeric value. - */ -declare function isNaN(number: number): boolean; - -/** - * Determines whether a supplied number is finite. - * @param number Any numeric value. - */ -declare function isFinite(number: number): boolean; - -/** - * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). - * @param encodedURI A value representing an encoded URI. - */ -declare function decodeURI(encodedURI: string): string; - -/** - * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). - * @param encodedURIComponent A value representing an encoded URI component. - */ -declare function decodeURIComponent(encodedURIComponent: string): string; - -/** - * Encodes a text string as a valid Uniform Resource Identifier (URI) - * @param uri A value representing an encoded URI. - */ -declare function encodeURI(uri: string): string; - -/** - * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. - */ -declare function encodeURIComponent(uriComponent: string): string; - -interface PropertyDescriptor { - configurable?: boolean; - enumerable?: boolean; - value?: any; - writable?: boolean; - get? (): any; - set? (v: any): void; -} - -interface PropertyDescriptorMap { - [s: string]: PropertyDescriptor; -} - -interface Object { - /** The initial value of Object.prototype.constructor is the standard built-in Object constructor. */ - constructor: Function; - - /** Returns a string representation of an object. */ - toString(): string; - - /** Returns a date converted to a string using the current locale. */ - toLocaleString(): string; - - /** Returns the primitive value of the specified object. */ - valueOf(): Object; - - /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - hasOwnProperty(v: string): boolean; - - /** - * Determines whether an object exists in another object's prototype chain. - * @param v Another object whose prototype chain is to be checked. - */ - isPrototypeOf(v: Object): boolean; - - /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ - propertyIsEnumerable(v: string): boolean; -} - -interface ObjectConstructor { - new (value?: any): Object; - (): any; - (value: any): any; - - /** A reference to the prototype for a class of objects. */ - prototype: Object; - - /** - * Returns the prototype of an object. - * @param o The object that references the prototype. - */ - getPrototypeOf(o: any): any; - - /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; - - /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly - * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. - * @param o Object that contains the own properties. - */ - getOwnPropertyNames(o: any): string[]; - - /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ - create(o: any, properties?: PropertyDescriptorMap): any; - - /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. - */ - defineProperty(o: any, p: string, attributes: PropertyDescriptor): any; - - /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. - * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. - * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. - */ - defineProperties(o: any, properties: PropertyDescriptorMap): any; - - /** - * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - seal(o: any): any; - - /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - freeze(o: any): any; - - /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ - preventExtensions(o: any): any; - - /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ - isSealed(o: any): boolean; - - /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ - isFrozen(o: any): boolean; - - /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ - isExtensible(o: any): boolean; - - /** - * Returns the names of the enumerable properties and methods 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. - */ - keys(o: any): string[]; -} - -/** - * Provides functionality common to all JavaScript objects. - */ -declare var Object: ObjectConstructor; - -/** - * Creates a new function. - */ -interface Function { - /** - * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. - * @param thisArg The object to be used as the this object. - * @param argArray A set of arguments to be passed to the function. - */ - apply(thisArg: any, argArray?: any): any; - - /** - * Calls a method of an object, substituting another object for the current object. - * @param thisArg The object to be used as the current object. - * @param argArray A list of arguments to be passed to the method. - */ - call(thisArg: any, ...argArray: any[]): any; - - /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg An object to which the this keyword can refer inside the new function. - * @param argArray A list of arguments to be passed to the new function. - */ - bind(thisArg: any, ...argArray: any[]): any; - - prototype: any; - length: number; - - // Non-standard extensions - arguments: any; - caller: Function; -} - -interface FunctionConstructor { - /** - * Creates a new function. - * @param args A list of arguments the function accepts. - */ - new (...args: string[]): Function; - (...args: string[]): Function; - prototype: Function; -} - -declare var Function: FunctionConstructor; - -interface IArguments { - [index: number]: any; - length: number; - callee: Function; -} - -interface String { - /** Returns a string representation of a string. */ - toString(): string; - - /** - * Returns the character at the specified index. - * @param pos The zero-based index of the desired character. - */ - charAt(pos: number): string; - - /** - * Returns the Unicode value of the character at the specified location. - * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. - */ - charCodeAt(index: number): number; - - /** - * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. - */ - concat(...strings: string[]): string; - - /** - * Returns the position of the first occurrence of a substring. - * @param searchString The substring to search for in the string - * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. - */ - indexOf(searchString: string, position?: number): number; - - /** - * Returns the last occurrence of a substring in the string. - * @param searchString The substring to search for. - * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. - */ - lastIndexOf(searchString: string, position?: number): number; - - /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - */ - localeCompare(that: string): number; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ - match(regexp: string): RegExpMatchArray; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. - */ - match(regexp: RegExp): RegExpMatchArray; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: string, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. - */ - replace(searchValue: RegExp, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. - */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: string): number; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: RegExp): number; - - /** - * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. - * If this value is not specified, the substring continues to the end of stringObj. - */ - slice(start?: number, end?: number): string; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: string, limit?: number): string[]; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: RegExp, limit?: number): string[]; - - /** - * Returns the substring at the specified location within a String object. - * @param start The zero-based index number indicating the beginning of the substring. - * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. - * If end is omitted, the characters from start through the end of the original string are returned. - */ - substring(start: number, end?: number): string; - - /** Converts all the alphabetic characters in a string to lowercase. */ - toLowerCase(): string; - - /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ - toLocaleLowerCase(): string; - - /** Converts all the alphabetic characters in a string to uppercase. */ - toUpperCase(): string; - - /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ - toLocaleUpperCase(): string; - - /** Removes the leading and trailing white space and line terminator characters from a string. */ - trim(): string; - - /** Returns the length of a String object. */ - length: number; - - // IE extensions - /** - * Gets a substring beginning at the specified location and having the specified length. - * @param from The starting position of the desired substring. The index of the first character in the string is zero. - * @param length The number of characters to include in the returned substring. - */ - substr(from: number, length?: number): string; - - [index: number]: string; -} - -interface StringConstructor { - new (value?: any): String; - (value?: any): string; - prototype: String; - fromCharCode(...codes: number[]): string; -} - -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ -declare var String: StringConstructor; - -interface Boolean { -} - -interface BooleanConstructor { - new (value?: any): Boolean; - (value?: any): boolean; - prototype: Boolean; -} - -declare var Boolean: BooleanConstructor; - -interface Number { - /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. - */ - toString(radix?: number): string; - - /** - * Returns a string representing a number in fixed-point notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ - toFixed(fractionDigits?: number): string; - - /** - * Returns a string containing a number represented in exponential notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ - toExponential(fractionDigits?: number): string; - - /** - * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. - * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. - */ - toPrecision(precision?: number): string; -} - -interface NumberConstructor { - new (value?: any): Number; - (value?: any): number; - prototype: Number; - - /** The largest number that can be represented in JavaScript. Equal to approximately 1.79E+308. */ - MAX_VALUE: number; - - /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ - MIN_VALUE: number; - - /** - * A value that is not a number. - * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. - */ - NaN: number; - - /** - * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. - */ - NEGATIVE_INFINITY: number; - - /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. - */ - POSITIVE_INFINITY: number; -} - -/** An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers. */ -declare var Number: NumberConstructor; - -interface TemplateStringsArray extends Array { - raw: string[]; -} - -interface Math { - /** The mathematical constant e. This is Euler's number, the base of natural logarithms. */ - E: number; - /** The natural logarithm of 10. */ - LN10: number; - /** The natural logarithm of 2. */ - LN2: number; - /** The base-2 logarithm of e. */ - LOG2E: number; - /** The base-10 logarithm of e. */ - LOG10E: number; - /** Pi. This is the ratio of the circumference of a circle to its diameter. */ - PI: number; - /** The square root of 0.5, or, equivalently, one divided by the square root of 2. */ - SQRT1_2: number; - /** The square root of 2. */ - SQRT2: number; - /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). - * For example, the absolute value of -5 is the same as the absolute value of 5. - * @param x A numeric expression for which the absolute value is needed. - */ - abs(x: number): number; - /** - * Returns the arc cosine (or inverse cosine) of a number. - * @param x A numeric expression. - */ - acos(x: number): number; - /** - * Returns the arcsine of a number. - * @param x A numeric expression. - */ - asin(x: number): number; - /** - * Returns the arctangent of a number. - * @param x A numeric expression for which the arctangent is needed. - */ - atan(x: number): number; - /** - * Returns the angle (in radians) from the X axis to a point (y,x). - * @param y A numeric expression representing the cartesian y-coordinate. - * @param x A numeric expression representing the cartesian x-coordinate. - */ - atan2(y: number, x: number): number; - /** - * Returns the smallest number greater than or equal to its numeric argument. - * @param x A numeric expression. - */ - ceil(x: number): number; - /** - * Returns the cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - cos(x: number): number; - /** - * Returns e (the base of natural logarithms) raised to a power. - * @param x A numeric expression representing the power of e. - */ - exp(x: number): number; - /** - * Returns the greatest number less than or equal to its numeric argument. - * @param x A numeric expression. - */ - floor(x: number): number; - /** - * Returns the natural logarithm (base e) of a number. - * @param x A numeric expression. - */ - log(x: number): number; - /** - * Returns the larger of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - max(...values: number[]): number; - /** - * Returns the smaller of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ - min(...values: number[]): number; - /** - * Returns the value of a base expression taken to a specified power. - * @param x The base value of the expression. - * @param y The exponent value of the expression. - */ - pow(x: number, y: number): number; - /** Returns a pseudorandom number between 0 and 1. */ - random(): number; - /** - * Returns a supplied numeric expression rounded to the nearest number. - * @param x The value to be rounded to the nearest number. - */ - round(x: number): number; - /** - * Returns the sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - sin(x: number): number; - /** - * Returns the square root of a number. - * @param x A numeric expression. - */ - sqrt(x: number): number; - /** - * Returns the tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ - tan(x: number): number; -} -/** An intrinsic object that provides basic mathematics functionality and constants. */ -declare var Math: Math; - -/** Enables basic storage and retrieval of dates and times. */ -interface Date { - /** Returns a string representation of a date. The format of the string depends on the locale. */ - toString(): string; - /** Returns a date as a string value. */ - toDateString(): string; - /** Returns a time as a string value. */ - toTimeString(): string; - /** Returns a value as a string value appropriate to the host environment's current locale. */ - toLocaleString(): string; - /** Returns a date as a string value appropriate to the host environment's current locale. */ - toLocaleDateString(): string; - /** Returns a time as a string value appropriate to the host environment's current locale. */ - toLocaleTimeString(): string; - /** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */ - valueOf(): number; - /** Gets the time value in milliseconds. */ - getTime(): number; - /** Gets the year, using local time. */ - getFullYear(): number; - /** Gets the year using Universal Coordinated Time (UTC). */ - getUTCFullYear(): number; - /** Gets the month, using local time. */ - getMonth(): number; - /** Gets the month of a Date object using Universal Coordinated Time (UTC). */ - getUTCMonth(): number; - /** Gets the day-of-the-month, using local time. */ - getDate(): number; - /** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */ - getUTCDate(): number; - /** Gets the day of the week, using local time. */ - getDay(): number; - /** Gets the day of the week using Universal Coordinated Time (UTC). */ - getUTCDay(): number; - /** Gets the hours in a date, using local time. */ - getHours(): number; - /** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */ - getUTCHours(): number; - /** Gets the minutes of a Date object, using local time. */ - getMinutes(): number; - /** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */ - getUTCMinutes(): number; - /** Gets the seconds of a Date object, using local time. */ - getSeconds(): number; - /** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCSeconds(): number; - /** Gets the milliseconds of a Date, using local time. */ - getMilliseconds(): number; - /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ - getUTCMilliseconds(): number; - /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ - getTimezoneOffset(): number; - /** - * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. - */ - setTime(time: number): number; - /** - * Sets the milliseconds value in the Date object using local time. - * @param ms A numeric value equal to the millisecond value. - */ - setMilliseconds(ms: number): number; - /** - * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). - * @param ms A numeric value equal to the millisecond value. - */ - setUTCMilliseconds(ms: number): number; - - /** - * Sets the seconds value in the Date object using local time. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setSeconds(sec: number, ms?: number): number; - /** - * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setUTCSeconds(sec: number, ms?: number): number; - /** - * Sets the minutes value in the Date object using local time. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setMinutes(min: number, sec?: number, ms?: number): number; - /** - * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setUTCMinutes(min: number, sec?: number, ms?: number): number; - /** - * Sets the hour value in the Date object using local time. - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setHours(hours: number, min?: number, sec?: number, ms?: number): number; - /** - * Sets the hours value in the Date object using Universal Coordinated Time (UTC). - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ - setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; - /** - * Sets the numeric day-of-the-month value of the Date object using local time. - * @param date A numeric value equal to the day of the month. - */ - setDate(date: number): number; - /** - * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). - * @param date A numeric value equal to the day of the month. - */ - setUTCDate(date: number): number; - /** - * Sets the month value in the Date object using local time. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. - */ - setMonth(month: number, date?: number): number; - /** - * Sets the month value in the Date object using Universal Coordinated Time (UTC). - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. - */ - setUTCMonth(month: number, date?: number): number; - /** - * Sets the year of the Date object using local time. - * @param year A numeric value for the year. - * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. - * @param date A numeric value equal for the day of the month. - */ - setFullYear(year: number, month?: number, date?: number): number; - /** - * Sets the year value in the Date object using Universal Coordinated Time (UTC). - * @param year A numeric value equal to the year. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. - * @param date A numeric value equal to the day of the month. - */ - setUTCFullYear(year: number, month?: number, date?: number): number; - /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ - toUTCString(): string; - /** Returns a date as a string value in ISO format. */ - toISOString(): string; - /** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */ - toJSON(key?: any): string; -} - -interface DateConstructor { - new (): Date; - new (value: number): Date; - new (value: string): Date; - new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date; - (): string; - prototype: Date; - /** - * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. - * @param s A date string - */ - parse(s: string): number; - /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. - * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. - * @param month The month as an number between 0 and 11 (January to December). - * @param date The date as an number between 1 and 31. - * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. - * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. - * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. - * @param ms An number from 0 to 999 that specifies the milliseconds. - */ - UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; - now(): number; -} - -declare var Date: DateConstructor; - -interface RegExpMatchArray extends Array { - index?: number; - input?: string; -} - -interface RegExpExecArray extends Array { - index: number; - input: string; -} - -interface RegExp { - /** - * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. - * @param string The String object or string literal on which to perform the search. - */ - exec(string: string): RegExpExecArray; - - /** - * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. - * @param string String on which to perform the search. - */ - test(string: string): boolean; - - /** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */ - source: string; - - /** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */ - global: boolean; - - /** Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only. */ - ignoreCase: boolean; - - /** Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only. */ - multiline: boolean; - - lastIndex: number; - - // Non-standard extensions - compile(): RegExp; -} - -interface RegExpConstructor { - new (pattern: string, flags?: string): RegExp; - (pattern: string, flags?: string): RegExp; - prototype: RegExp; - - // Non-standard extensions - $1: string; - $2: string; - $3: string; - $4: string; - $5: string; - $6: string; - $7: string; - $8: string; - $9: string; - lastMatch: string; -} - -declare var RegExp: RegExpConstructor; - -interface Error { - name: string; - message: string; -} - -interface ErrorConstructor { - new (message?: string): Error; - (message?: string): Error; - prototype: Error; -} - -declare var Error: ErrorConstructor; - -interface EvalError extends Error { -} - -interface EvalErrorConstructor { - new (message?: string): EvalError; - (message?: string): EvalError; - prototype: EvalError; -} - -declare var EvalError: EvalErrorConstructor; - -interface RangeError extends Error { -} - -interface RangeErrorConstructor { - new (message?: string): RangeError; - (message?: string): RangeError; - prototype: RangeError; -} - -declare var RangeError: RangeErrorConstructor; - -interface ReferenceError extends Error { -} - -interface ReferenceErrorConstructor { - new (message?: string): ReferenceError; - (message?: string): ReferenceError; - prototype: ReferenceError; -} - -declare var ReferenceError: ReferenceErrorConstructor; - -interface SyntaxError extends Error { -} - -interface SyntaxErrorConstructor { - new (message?: string): SyntaxError; - (message?: string): SyntaxError; - prototype: SyntaxError; -} - -declare var SyntaxError: SyntaxErrorConstructor; - -interface TypeError extends Error { -} - -interface TypeErrorConstructor { - new (message?: string): TypeError; - (message?: string): TypeError; - prototype: TypeError; -} - -declare var TypeError: TypeErrorConstructor; - -interface URIError extends Error { -} - -interface URIErrorConstructor { - new (message?: string): URIError; - (message?: string): URIError; - prototype: URIError; -} - -declare var URIError: URIErrorConstructor; - -interface JSON { - /** - * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. - */ - parse(text: string, reviver?: (key: any, value: any) => any): any; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - */ - stringify(value: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - */ - stringify(value: any, replacer: (key: string, value: any) => any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - */ - stringify(value: any, replacer: any[]): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: (key: string, value: any) => any, space: any): string; - /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer Array that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ - stringify(value: any, replacer: any[], space: any): string; -} -/** - * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. - */ -declare var JSON: JSON; - - -///////////////////////////// -/// ECMAScript Array API (specially handled by compiler) -///////////////////////////// - -interface Array { - /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ - length: number; - /** - * Returns a string representation of an array. - */ - toString(): string; - toLocaleString(): string; - /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ - push(...items: T[]): number; - /** - * Removes the last element from an array and returns it. - */ - pop(): T; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: U[]): T[]; - /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ - concat(...items: T[]): T[]; - /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ - join(separator?: string): string; - /** - * Reverses the elements in an Array. - */ - reverse(): T[]; - /** - * Removes the first element from an array and returns it. - */ - shift(): T; - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - slice(start?: number, end?: number): T[]; - - /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. - */ - sort(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - */ - splice(start: number): T[]; - - /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - */ - splice(start: number, deleteCount: number, ...items: T[]): T[]; - - /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ - unshift(...items: T[]): number; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ - indexOf(searchElement: T, fromIndex?: number): number; - - /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ - lastIndexOf(searchElement: T, fromIndex?: number): number; - - /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; - - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; - - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; - - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; - - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - - [n: number]: T; -} - -interface ArrayConstructor { - new (arrayLength?: number): any[]; - new (arrayLength: number): T[]; - new (...items: T[]): T[]; - (arrayLength?: number): any[]; - (arrayLength: number): T[]; - (...items: T[]): T[]; - isArray(arg: any): boolean; - prototype: Array; -} - -declare var Array: ArrayConstructor; - -///////////////////////////// -/// IE10 ECMAScript Extensions -///////////////////////////// - -/** - * 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 { - /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ - byteLength: number; - - /** - * Returns a section of an ArrayBuffer. - */ - slice(begin:number, end?:number): ArrayBuffer; -} - -declare var ArrayBuffer: { - prototype: ArrayBuffer; - new (byteLength: number): ArrayBuffer; -} - -interface ArrayBufferView { - buffer: ArrayBuffer; - byteOffset: number; - byteLength: number; -} - -/** - * 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 extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int8Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; -} -declare var Int8Array: { - prototype: Int8Array; - new (length: number): Int8Array; - new (array: Int8Array): Int8Array; - new (array: number[]): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; - BYTES_PER_ELEMENT: number; -} - -/** - * 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 extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint8Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Uint8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; -} -declare var Uint8Array: { - prototype: Uint8Array; - new (length: number): Uint8Array; - new (array: Uint8Array): Uint8Array; - new (array: number[]): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 16-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int16Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int16Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; -} -declare var Int16Array: { - prototype: Int16Array; - new (length: number): Int16Array; - new (array: Int16Array): Int16Array; - new (array: number[]): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; - BYTES_PER_ELEMENT: number; -} - -/** - * 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 extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint16Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Uint16Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; -} -declare var Uint16Array: { - prototype: Uint16Array; - new (length: number): Uint16Array; - new (array: Uint16Array): Uint16Array; - new (array: number[]): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; - BYTES_PER_ELEMENT: number; -} - -/** - * A typed array of 32-bit integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised. - */ -interface Int32Array extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Int32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; -} -declare var Int32Array: { - prototype: Int32Array; - new (length: number): Int32Array; - new (array: Int32Array): Int32Array; - new (array: number[]): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * 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 extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Uint32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Int8Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; -} -declare var Uint32Array: { - prototype: Uint32Array; - new (length: number): Uint32Array; - new (array: Uint32Array): Uint32Array; - new (array: number[]): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * 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 extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float32Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Float32Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; -} -declare var Float32Array: { - prototype: Float32Array; - new (length: number): Float32Array; - new (array: Float32Array): Float32Array; - new (array: number[]): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; - BYTES_PER_ELEMENT: number; -} - -/** - * 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 extends ArrayBufferView { - /** - * The size in bytes of each element in the array. - */ - BYTES_PER_ELEMENT: number; - - /** - * The length of the array. - */ - length: number; - [index: number]: number; - - /** - * Gets the element at the specified index. - * @param index The index at which to get the element of the array. - */ - get(index: number): number; - - /** - * Sets a value or an array of values. - * @param index The index of the location to set. - * @param value The value to set. - */ - set(index: number, value: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: Float64Array, offset?: number): void; - - /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ - set(array: number[], offset?: number): void; - - /** - * Gets a new Float64Array view of the ArrayBuffer Object store for this array, specifying the first and last members of the subarray. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; -} -declare var Float64Array: { - prototype: Float64Array; - new (length: number): Float64Array; - new (array: Float64Array): Float64Array; - new (array: number[]): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; - BYTES_PER_ELEMENT: number; -} - -/** - * You can use a DataView object to read and write the different kinds of binary data to any location in the ArrayBuffer. - */ -interface DataView extends ArrayBufferView { - /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt8(byteOffset: number): number; - - /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint8(byteOffset: number): number; - - /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt16(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint16(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getInt32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getUint32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat32(byteOffset: number, littleEndian?: boolean): number; - - /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ - getFloat64(byteOffset: number, littleEndian?: boolean): number; - - /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setInt8(byteOffset: number, value: number): void; - - /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ - setUint8(byteOffset: number, value: number): void; - - /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; - - /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, otherwise a little-endian value should be written. - */ - setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; -} -declare var DataView: { - prototype: DataView; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): DataView; -} - -///////////////////////////// -/// IE11 ECMAScript Extensions -///////////////////////////// - -interface Map { - clear(): void; - delete(key: K): boolean; - forEach(callbackfn: (value: V, index: K, map: Map) => void, thisArg?: any): void; - get(key: K): V; - has(key: K): boolean; - set(key: K, value: V): Map; - size: number; -} -declare var Map: { - new (): Map; - prototype: Map; -} - -interface WeakMap { - clear(): void; - delete(key: K): boolean; - get(key: K): V; - has(key: K): boolean; - set(key: K, value: V): WeakMap; -} -declare var WeakMap: { - new (): WeakMap; - prototype: WeakMap; -} - -interface Set { - add(value: T): Set; - clear(): void; - delete(value: T): boolean; - forEach(callbackfn: (value: T, index: T, set: Set) => void, thisArg?: any): void; - has(value: T): boolean; - size: number; -} -declare var Set: { - new (): Set; - prototype: Set; -} -///////////////////////////// -/// ECMAScript Internationalization API -///////////////////////////// - -declare module Intl { - interface CollatorOptions { - usage?: string; - localeMatcher?: string; - numeric?: boolean; - caseFirst?: string; - sensitivity?: string; - ignorePunctuation?: boolean; - } - - interface ResolvedCollatorOptions { - locale: string; - usage: string; - sensitivity: string; - ignorePunctuation: boolean; - collation: string; - caseFirst: string; - numeric: boolean; - } - - interface Collator { - compare(x: string, y: string): number; - resolvedOptions(): ResolvedCollatorOptions; - } - var Collator: { - new (locales?: string[], options?: CollatorOptions): Collator; - new (locale?: string, options?: CollatorOptions): Collator; - (locales?: string[], options?: CollatorOptions): Collator; - (locale?: string, options?: CollatorOptions): Collator; - supportedLocalesOf(locales: string[], options?: CollatorOptions): string[]; - supportedLocalesOf(locale: string, options?: CollatorOptions): string[]; - } - - interface NumberFormatOptions { - localeMatcher?: string; - style?: string; - currency?: string; - currencyDisplay?: string; - useGrouping?: boolean; - } - - interface ResolvedNumberFormatOptions { - locale: string; - numberingSystem: string; - style: string; - currency?: string; - currencyDisplay?: string; - minimumintegerDigits: number; - minimumFractionDigits: number; - maximumFractionDigits: number; - minimumSignificantDigits?: number; - maximumSignificantDigits?: number; - useGrouping: boolean; - } - - interface NumberFormat { - format(value: number): string; - resolvedOptions(): ResolvedNumberFormatOptions; - } - var NumberFormat: { - new (locales?: string[], options?: NumberFormatOptions): Collator; - new (locale?: string, options?: NumberFormatOptions): Collator; - (locales?: string[], options?: NumberFormatOptions): Collator; - (locale?: string, options?: NumberFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[]; - } - - interface DateTimeFormatOptions { - localeMatcher?: string; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - formatMatcher?: string; - hour12: boolean; - } - - interface ResolvedDateTimeFormatOptions { - locale: string; - calendar: string; - numberingSystem: string; - timeZone: string; - hour12?: boolean; - weekday?: string; - era?: string; - year?: string; - month?: string; - day?: string; - hour?: string; - minute?: string; - second?: string; - timeZoneName?: string; - } - - interface DateTimeFormat { - format(date: number): string; - resolvedOptions(): ResolvedDateTimeFormatOptions; - } - var DateTimeFormat: { - new (locales?: string[], options?: DateTimeFormatOptions): Collator; - new (locale?: string, options?: DateTimeFormatOptions): Collator; - (locales?: string[], options?: DateTimeFormatOptions): Collator; - (locale?: string, options?: DateTimeFormatOptions): Collator; - supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[]; - supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[]; - } -} - -interface String { - /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. - * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. - */ - localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number; - - /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. - * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. - */ - localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number; -} - -interface Number { - /** - * Converts a number to a string by using the current or specified locale. - * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ - toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; - - /** - * Converts a number to a string by using the current or specified locale. - * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ - toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string; -} - -interface Date { - /** - * Converts a date to a string by using the current or specified locale. - * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ - toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; - - /** - * Converts a date to a string by using the current or specified locale. - * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ - toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; -} - -///////////////////////////// -/// IE DOM APIs -///////////////////////////// - - -interface PositionOptions { - enableHighAccuracy?: boolean; - timeout?: number; - maximumAge?: number; -} - -interface ObjectURLOptions { - oneTimeOnly?: boolean; -} - -interface StoreExceptionsInformation extends ExceptionInformation { - siteName?: string; - explanationString?: string; - detailURI?: string; -} - -interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { - arrayOfDomainStrings?: string[]; -} - -interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { - arrayOfDomainStrings?: string[]; -} - -interface AlgorithmParameters { -} - -interface MutationObserverInit { - childList?: boolean; - attributes?: boolean; - characterData?: boolean; - subtree?: boolean; - attributeOldValue?: boolean; - characterDataOldValue?: boolean; - attributeFilter?: string[]; -} - -interface PointerEventInit extends MouseEventInit { - pointerId?: number; - width?: number; - height?: number; - pressure?: number; - tiltX?: number; - tiltY?: number; - pointerType?: string; - isPrimary?: boolean; -} - -interface ExceptionInformation { - domain?: string; -} - -interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; -} - -interface MsZoomToOptions { - contentX?: number; - contentY?: number; - viewportX?: string; - viewportY?: string; - scaleFactor?: number; - animate?: string; -} - -interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; -} - -interface Algorithm { - name?: string; - params?: AlgorithmParameters; -} - -interface MouseEventInit { - bubbles?: boolean; - cancelable?: boolean; - view?: Window; - detail?: number; - screenX?: number; - screenY?: number; - clientX?: number; - clientY?: number; - ctrlKey?: boolean; - shiftKey?: boolean; - altKey?: boolean; - metaKey?: boolean; - button?: number; - buttons?: number; - relatedTarget?: EventTarget; -} - -interface WebGLContextAttributes { - alpha?: boolean; - depth?: boolean; - stencil?: boolean; - antialias?: boolean; - premultipliedAlpha?: boolean; - preserveDrawingBuffer?: boolean; -} - -interface NodeListOf extends NodeList { - length: number; - item(index: number): TNode; - [index: number]: TNode; -} - -interface HTMLElement extends Element, ElementCSSInlineStyle, MSEventAttachmentTarget, MSNodeExtensions { - hidden: any; - readyState: any; - onmouseleave: (ev: MouseEvent) => any; - onbeforecut: (ev: DragEvent) => any; - onkeydown: (ev: KeyboardEvent) => any; - onmove: (ev: MSEventObj) => any; - onkeyup: (ev: KeyboardEvent) => any; - onreset: (ev: Event) => any; - onhelp: (ev: Event) => any; - ondragleave: (ev: DragEvent) => any; - className: string; - onfocusin: (ev: FocusEvent) => any; - onseeked: (ev: Event) => any; - recordNumber: any; - title: string; - parentTextEdit: Element; - outerHTML: string; - ondurationchange: (ev: Event) => any; - offsetHeight: number; - all: HTMLCollection; - onblur: (ev: FocusEvent) => any; - dir: string; - onemptied: (ev: Event) => any; - onseeking: (ev: Event) => any; - oncanplay: (ev: Event) => any; - ondeactivate: (ev: UIEvent) => any; - ondatasetchanged: (ev: MSEventObj) => any; - onrowsdelete: (ev: MSEventObj) => any; - sourceIndex: number; - onloadstart: (ev: Event) => any; - onlosecapture: (ev: MSEventObj) => any; - ondragenter: (ev: DragEvent) => any; - oncontrolselect: (ev: MSEventObj) => any; - onsubmit: (ev: Event) => any; - behaviorUrns: MSBehaviorUrnsCollection; - scopeName: string; - onchange: (ev: Event) => any; - id: string; - onlayoutcomplete: (ev: MSEventObj) => any; - uniqueID: string; - onbeforeactivate: (ev: UIEvent) => any; - oncanplaythrough: (ev: Event) => any; - onbeforeupdate: (ev: MSEventObj) => any; - onfilterchange: (ev: MSEventObj) => any; - offsetParent: Element; - ondatasetcomplete: (ev: MSEventObj) => any; - onsuspend: (ev: Event) => any; - onmouseenter: (ev: MouseEvent) => any; - innerText: string; - onerrorupdate: (ev: MSEventObj) => any; - onmouseout: (ev: MouseEvent) => any; - parentElement: HTMLElement; - onmousewheel: (ev: MouseWheelEvent) => any; - onvolumechange: (ev: Event) => any; - oncellchange: (ev: MSEventObj) => any; - onrowexit: (ev: MSEventObj) => any; - onrowsinserted: (ev: MSEventObj) => any; - onpropertychange: (ev: MSEventObj) => any; - filters: any; - children: HTMLCollection; - ondragend: (ev: DragEvent) => any; - onbeforepaste: (ev: DragEvent) => any; - ondragover: (ev: DragEvent) => any; - offsetTop: number; - onmouseup: (ev: MouseEvent) => any; - ondragstart: (ev: DragEvent) => any; - onbeforecopy: (ev: DragEvent) => any; - ondrag: (ev: DragEvent) => any; - innerHTML: string; - onmouseover: (ev: MouseEvent) => any; - lang: string; - uniqueNumber: number; - onpause: (ev: Event) => any; - tagUrn: string; - onmousedown: (ev: MouseEvent) => any; - onclick: (ev: MouseEvent) => any; - onwaiting: (ev: Event) => any; - onresizestart: (ev: MSEventObj) => any; - offsetLeft: number; - isTextEdit: boolean; - isDisabled: boolean; - onpaste: (ev: DragEvent) => any; - canHaveHTML: boolean; - onmoveend: (ev: MSEventObj) => any; - language: string; - onstalled: (ev: Event) => any; - onmousemove: (ev: MouseEvent) => any; - style: MSStyleCSSProperties; - isContentEditable: boolean; - onbeforeeditfocus: (ev: MSEventObj) => any; - onratechange: (ev: Event) => any; - contentEditable: string; - tabIndex: number; - document: Document; - onprogress: (ev: ProgressEvent) => any; - ondblclick: (ev: MouseEvent) => any; - oncontextmenu: (ev: MouseEvent) => any; - onloadedmetadata: (ev: Event) => any; - onafterupdate: (ev: MSEventObj) => any; - onerror: (ev: ErrorEvent) => any; - onplay: (ev: Event) => any; - onresizeend: (ev: MSEventObj) => any; - onplaying: (ev: Event) => any; - isMultiLine: boolean; - onfocusout: (ev: FocusEvent) => any; - onabort: (ev: UIEvent) => any; - ondataavailable: (ev: MSEventObj) => any; - hideFocus: boolean; - onreadystatechange: (ev: Event) => any; - onkeypress: (ev: KeyboardEvent) => any; - onloadeddata: (ev: Event) => any; - onbeforedeactivate: (ev: UIEvent) => any; - outerText: string; - disabled: boolean; - onactivate: (ev: UIEvent) => any; - accessKey: string; - onmovestart: (ev: MSEventObj) => any; - onselectstart: (ev: Event) => any; - onfocus: (ev: FocusEvent) => any; - ontimeupdate: (ev: Event) => any; - onresize: (ev: UIEvent) => any; - oncut: (ev: DragEvent) => any; - onselect: (ev: UIEvent) => any; - ondrop: (ev: DragEvent) => any; - offsetWidth: number; - oncopy: (ev: DragEvent) => any; - onended: (ev: Event) => any; - onscroll: (ev: UIEvent) => any; - onrowenter: (ev: MSEventObj) => any; - onload: (ev: Event) => any; - canHaveChildren: boolean; - oninput: (ev: Event) => any; - onmscontentzoom: (ev: MSEventObj) => any; - oncuechange: (ev: Event) => any; - spellcheck: boolean; - classList: DOMTokenList; - onmsmanipulationstatechanged: (ev: any) => any; - draggable: boolean; - dataset: DOMStringMap; - dragDrop(): boolean; - scrollIntoView(top?: boolean): void; - addFilter(filter: any): void; - setCapture(containerCapture?: boolean): void; - focus(): void; - getAdjacentText(where: string): string; - insertAdjacentText(where: string, text: string): void; - getElementsByClassName(classNames: string): NodeList; - setActive(): void; - removeFilter(filter: any): void; - blur(): void; - clearAttributes(): void; - releaseCapture(): void; - createControlRange(): ControlRangeCollection; - removeBehavior(cookie: number): boolean; - contains(child: HTMLElement): boolean; - click(): void; - insertAdjacentElement(position: string, insertedElement: Element): Element; - mergeAttributes(source: HTMLElement, preserveIdentity?: boolean): void; - replaceAdjacentText(where: string, newText: string): string; - applyElement(apply: Element, where?: string): Element; - addBehavior(bstrUrl: string, factory?: any): number; - insertAdjacentHTML(where: string, html: string): void; - msGetInputContext(): MSInputMethodContext; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLElement: { - prototype: HTMLElement; - new(): HTMLElement; -} - -interface Document extends Node, NodeSelector, MSEventAttachmentTarget, DocumentEvent, MSResourceMetadata, MSNodeExtensions, MSDocumentExtensions, GlobalEventHandlers { - /** - * Gets a reference to the root node of the document. - */ - documentElement: HTMLElement; - /** - * Retrieves the collection of user agents and versions declared in the X-UA-Compatible - */ - compatible: MSCompatibleInfoCollection; - /** - * Fires when the user presses a key. - * @param ev The keyboard event - */ - onkeydown: (ev: KeyboardEvent) => any; - /** - * Fires when the user releases a key. - * @param ev The keyboard event - */ - onkeyup: (ev: KeyboardEvent) => any; - /** - * Gets the implementation object of the current document. - */ - implementation: DOMImplementation; - /** - * Fires when the user resets a form. - * @param ev The event. - */ - onreset: (ev: Event) => any; - /** - * Retrieves a collection of all script objects in the document. - */ - scripts: HTMLCollection; - /** - * Fires when the user presses the F1 key while the browser is the active window. - * @param ev The event. - */ - onhelp: (ev: Event) => any; - /** - * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. - * @param ev The drag event. - */ - ondragleave: (ev: DragEvent) => any; - /** - * Gets or sets the character set used to encode the object. - */ - charset: string; - /** - * Fires for an element just prior to setting focus on that element. - * @param ev The focus event - */ - onfocusin: (ev: FocusEvent) => any; - /** - * Sets or gets the color of the links that the user has visited. - */ - vlinkColor: string; - /** - * Occurs when the seek operation ends. - * @param ev The event. - */ - onseeked: (ev: Event) => any; - security: string; - /** - * Contains the title of the document. - */ - title: string; - /** - * Retrieves a collection of namespace objects. - */ - namespaces: MSNamespaceInfoCollection; - /** - * Gets the default character set from the current regional language settings. - */ - defaultCharset: string; - /** - * Retrieves a collection of all embed objects in the document. - */ - embeds: HTMLCollection; - /** - * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. - */ - styleSheets: StyleSheetList; - /** - * Retrieves a collection of all window objects defined by the given document or defined by the document associated with the given window. - */ - frames: Window; - /** - * Occurs when the duration attribute is updated. - * @param ev The event. - */ - ondurationchange: (ev: Event) => any; - /** - * Returns a reference to the collection of elements contained by the object. - */ - all: HTMLCollection; - /** - * Retrieves a collection, in source order, of all form objects in the document. - */ - forms: HTMLCollection; - /** - * Fires when the object loses the input focus. - * @param ev The focus event. - */ - onblur: (ev: FocusEvent) => any; - /** - * Sets or retrieves a value that indicates the reading order of the object. - */ - dir: string; - /** - * Occurs when the media element is reset to its initial state. - * @param ev The event. - */ - onemptied: (ev: Event) => any; - /** - * Sets or gets a value that indicates whether the document can be edited. - */ - designMode: string; - /** - * Occurs when the current playback position is moved. - * @param ev The event. - */ - onseeking: (ev: Event) => any; - /** - * Fires when the activeElement is changed from the current object to another object in the parent document. - * @param ev The UI Event - */ - ondeactivate: (ev: UIEvent) => any; - /** - * Occurs when playback is possible, but would require further buffering. - * @param ev The event. - */ - oncanplay: (ev: Event) => any; - /** - * Fires when the data set exposed by a data source object changes. - * @param ev The event. - */ - ondatasetchanged: (ev: MSEventObj) => any; - /** - * Fires when rows are about to be deleted from the recordset. - * @param ev The event - */ - onrowsdelete: (ev: MSEventObj) => any; - Script: MSScriptHost; - /** - * Occurs when Internet Explorer begins looking for media data. - * @param ev The event. - */ - onloadstart: (ev: Event) => any; - /** - * Gets the URL for the document, stripped of any character encoding. - */ - URLUnencoded: string; - defaultView: Window; - /** - * Fires when the user is about to make a control selection of the object. - * @param ev The event. - */ - oncontrolselect: (ev: MSEventObj) => any; - /** - * Fires on the target element when the user drags the object to a valid drop target. - * @param ev The drag event. - */ - ondragenter: (ev: DragEvent) => any; - onsubmit: (ev: Event) => any; - /** - * Returns the character encoding used to create the webpage that is loaded into the document object. - */ - inputEncoding: string; - /** - * Gets the object that has the focus when the parent document has focus. - */ - activeElement: Element; - /** - * Fires when the contents of the object or selection have changed. - * @param ev The event. - */ - onchange: (ev: Event) => any; - /** - * Retrieves a collection of all a objects that specify the href property and all area objects in the document. - */ - links: HTMLCollection; - /** - * Retrieves an autogenerated, unique identifier for the object. - */ - uniqueID: string; - /** - * Sets or gets the URL for the current document. - */ - URL: string; - /** - * Fires immediately before the object is set as the active element. - * @param ev The event. - */ - onbeforeactivate: (ev: UIEvent) => any; - head: HTMLHeadElement; - cookie: string; - xmlEncoding: string; - oncanplaythrough: (ev: Event) => any; - /** - * Retrieves the document compatibility mode of the document. - */ - documentMode: number; - characterSet: string; - /** - * Retrieves a collection of all a objects that have a name and/or id property. Objects in this collection are in HTML source order. - */ - anchors: HTMLCollection; - onbeforeupdate: (ev: MSEventObj) => any; - /** - * Fires to indicate that all data is available from the data source object. - * @param ev The event. - */ - ondatasetcomplete: (ev: MSEventObj) => any; - plugins: HTMLCollection; - /** - * Occurs if the load operation has been intentionally halted. - * @param ev The event. - */ - onsuspend: (ev: Event) => any; - /** - * Gets the root svg element in the document hierarchy. - */ - rootElement: SVGSVGElement; - /** - * Retrieves a value that indicates the current state of the object. - */ - readyState: string; - /** - * Gets the URL of the location that referred the user to the current page. - */ - referrer: string; - /** - * Sets or gets the color of all active links in the document. - */ - alinkColor: string; - /** - * Fires on a databound object when an error occurs while updating the associated data in the data source object. - * @param ev The event. - */ - onerrorupdate: (ev: MSEventObj) => any; - /** - * Gets a reference to the container object of the window. - */ - parentWindow: Window; - /** - * Fires when the user moves the mouse pointer outside the boundaries of the object. - * @param ev The mouse event. - */ - onmouseout: (ev: MouseEvent) => any; - /** - * Occurs when a user clicks a button in a Thumbnail Toolbar of a webpage running in Site Mode. - * @param ev The event. - */ - onmsthumbnailclick: (ev: MSSiteModeEvent) => any; - /** - * Fires when the wheel button is rotated. - * @param ev The mouse event - */ - onmousewheel: (ev: MouseWheelEvent) => any; - /** - * Occurs when the volume is changed, or playback is muted or unmuted. - * @param ev The event. - */ - onvolumechange: (ev: Event) => any; - /** - * Fires when data changes in the data provider. - * @param ev The event. - */ - oncellchange: (ev: MSEventObj) => any; - /** - * Fires just before the data source control changes the current row in the object. - * @param ev The event. - */ - onrowexit: (ev: MSEventObj) => any; - /** - * Fires just after new rows are inserted in the current recordset. - * @param ev The event. - */ - onrowsinserted: (ev: MSEventObj) => any; - /** - * Gets or sets the version attribute specified in the declaration of an XML document. - */ - xmlVersion: string; - msCapsLockWarningOff: boolean; - /** - * Fires when a property changes on the object. - * @param ev The event. - */ - onpropertychange: (ev: MSEventObj) => any; - /** - * Fires on the source object when the user releases the mouse at the close of a drag operation. - * @param ev The event. - */ - ondragend: (ev: DragEvent) => any; - /** - * Gets an object representing the document type declaration associated with the current document. - */ - doctype: DocumentType; - /** - * Fires on the target element continuously while the user drags the object over a valid drop target. - * @param ev The event. - */ - ondragover: (ev: DragEvent) => any; - /** - * Deprecated. Sets or retrieves a value that indicates the background color behind the object. - */ - bgColor: string; - /** - * Fires on the source object when the user starts to drag a text selection or selected object. - * @param ev The event. - */ - ondragstart: (ev: DragEvent) => any; - /** - * Fires when the user releases a mouse button while the mouse is over the object. - * @param ev The mouse event. - */ - onmouseup: (ev: MouseEvent) => any; - /** - * Fires on the source object continuously during a drag operation. - * @param ev The event. - */ - ondrag: (ev: DragEvent) => any; - /** - * Fires when the user moves the mouse pointer into the object. - * @param ev The mouse event. - */ - onmouseover: (ev: MouseEvent) => any; - /** - * Sets or gets the color of the document links. - */ - linkColor: string; - /** - * Occurs when playback is paused. - * @param ev The event. - */ - onpause: (ev: Event) => any; - /** - * Fires when the user clicks the object with either mouse button. - * @param ev The mouse event. - */ - onmousedown: (ev: MouseEvent) => any; - /** - * Fires when the user clicks the left mouse button on the object - * @param ev The mouse event. - */ - onclick: (ev: MouseEvent) => any; - /** - * Occurs when playback stops because the next frame of a video resource is not available. - * @param ev The event. - */ - onwaiting: (ev: Event) => any; - /** - * Fires when the user clicks the Stop button or leaves the Web page. - * @param ev The event. - */ - onstop: (ev: Event) => any; - /** - * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. - * @param ev The event. - */ - onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; - /** - * Retrieves a collection of all applet objects in the document. - */ - applets: HTMLCollection; - /** - * Specifies the beginning and end of the document body. - */ - body: HTMLElement; - /** - * Sets or gets the security domain of the document. - */ - domain: string; - xmlStandalone: boolean; - /** - * Represents the active selection, which is a highlighted block of text or other elements in the document that a user or a script can carry out some action on. - */ - selection: MSSelection; - /** - * Occurs when the download has stopped. - * @param ev The event. - */ - onstalled: (ev: Event) => any; - /** - * Fires when the user moves the mouse over the object. - * @param ev The mouse event. - */ - onmousemove: (ev: MouseEvent) => any; - /** - * Fires before an object contained in an editable element enters a UI-activated state or when an editable container object is control selected. - * @param ev The event. - */ - onbeforeeditfocus: (ev: MSEventObj) => any; - /** - * Occurs when the playback rate is increased or decreased. - * @param ev The event. - */ - onratechange: (ev: Event) => any; - /** - * Occurs to indicate progress while downloading media data. - * @param ev The event. - */ - onprogress: (ev: ProgressEvent) => any; - /** - * Fires when the user double-clicks the object. - * @param ev The mouse event. - */ - ondblclick: (ev: MouseEvent) => any; - /** - * Fires when the user clicks the right mouse button in the client area, opening the context menu. - * @param ev The mouse event. - */ - oncontextmenu: (ev: MouseEvent) => any; - /** - * Occurs when the duration and dimensions of the media have been determined. - * @param ev The event. - */ - onloadedmetadata: (ev: Event) => any; - media: string; - /** - * Fires when an error occurs during object loading. - * @param ev The event. - */ - onerror: (ev: ErrorEvent) => any; - /** - * Occurs when the play method is requested. - * @param ev The event. - */ - onplay: (ev: Event) => any; - onafterupdate: (ev: MSEventObj) => any; - /** - * Occurs when the audio or video has started playing. - * @param ev The event. - */ - onplaying: (ev: Event) => any; - /** - * Retrieves a collection, in source order, of img objects in the document. - */ - images: HTMLCollection; - /** - * Contains information about the current URL. - */ - location: Location; - /** - * Fires when the user aborts the download. - * @param ev The event. - */ - onabort: (ev: UIEvent) => any; - /** - * Fires for the current element with focus immediately after moving focus to another element. - * @param ev The event. - */ - onfocusout: (ev: FocusEvent) => any; - /** - * Fires when the selection state of a document changes. - * @param ev The event. - */ - onselectionchange: (ev: Event) => any; - /** - * Fires when a local DOM Storage area is written to disk. - * @param ev The event. - */ - onstoragecommit: (ev: StorageEvent) => any; - /** - * Fires periodically as data arrives from data source objects that asynchronously transmit their data. - * @param ev The event. - */ - ondataavailable: (ev: MSEventObj) => any; - /** - * Fires when the state of the object has changed. - * @param ev The event - */ - onreadystatechange: (ev: Event) => any; - /** - * Gets the date that the page was last modified, if the page supplies one. - */ - lastModified: string; - /** - * Fires when the user presses an alphanumeric key. - * @param ev The event. - */ - onkeypress: (ev: KeyboardEvent) => any; - /** - * Occurs when media data is loaded at the current playback position. - * @param ev The event. - */ - onloadeddata: (ev: Event) => any; - /** - * Fires immediately before the activeElement is changed from the current object to another object in the parent document. - * @param ev The event. - */ - onbeforedeactivate: (ev: UIEvent) => any; - /** - * Fires when the object is set as the active element. - * @param ev The event. - */ - onactivate: (ev: UIEvent) => any; - onselectstart: (ev: Event) => any; - /** - * Fires when the object receives focus. - * @param ev The event. - */ - onfocus: (ev: FocusEvent) => any; - /** - * Sets or gets the foreground (text) color of the document. - */ - fgColor: string; - /** - * Occurs to indicate the current playback position. - * @param ev The event. - */ - ontimeupdate: (ev: Event) => any; - /** - * Fires when the current selection changes. - * @param ev The event. - */ - onselect: (ev: UIEvent) => any; - ondrop: (ev: DragEvent) => any; - /** - * Occurs when the end of playback is reached. - * @param ev The event - */ - onended: (ev: Event) => any; - /** - * Gets a value that indicates whether standards-compliant mode is switched on for the object. - */ - compatMode: string; - /** - * Fires when the user repositions the scroll box in the scroll bar on the object. - * @param ev The event. - */ - onscroll: (ev: UIEvent) => any; - /** - * Fires to indicate that the current row has changed in the data source and new data values are available on the object. - * @param ev The event. - */ - onrowenter: (ev: MSEventObj) => any; - /** - * Fires immediately after the browser loads the object. - * @param ev The event. - */ - onload: (ev: Event) => any; - oninput: (ev: Event) => any; - onmspointerdown: (ev: any) => any; - msHidden: boolean; - msVisibilityState: string; - onmsgesturedoubletap: (ev: any) => any; - visibilityState: string; - onmsmanipulationstatechanged: (ev: any) => any; - onmspointerhover: (ev: any) => any; - onmscontentzoom: (ev: MSEventObj) => any; - onmspointermove: (ev: any) => any; - onmsgesturehold: (ev: any) => any; - onmsgesturechange: (ev: any) => any; - onmsgesturestart: (ev: any) => any; - onmspointercancel: (ev: any) => any; - onmsgestureend: (ev: any) => any; - onmsgesturetap: (ev: any) => any; - onmspointerout: (ev: any) => any; - onmsinertiastart: (ev: any) => any; - msCSSOMElementFloatMetrics: boolean; - onmspointerover: (ev: any) => any; - hidden: boolean; - onmspointerup: (ev: any) => any; - msFullscreenEnabled: boolean; - onmsfullscreenerror: (ev: any) => any; - onmspointerenter: (ev: any) => any; - msFullscreenElement: Element; - onmsfullscreenchange: (ev: any) => any; - onmspointerleave: (ev: any) => any; - /** - * Returns a reference to the first object with the specified value of the ID or NAME attribute. - * @param elementId String that specifies the ID value. Case-insensitive. - */ - getElementById(elementId: string): HTMLElement; - /** - * Returns the current value of the document, range, or current selection for the given command. - * @param commandId String that specifies a command identifier. - */ - queryCommandValue(commandId: string): string; - adoptNode(source: Node): Node; - /** - * Returns a Boolean value that indicates whether the specified command is in the indeterminate state. - * @param commandId String that specifies a command identifier. - */ - queryCommandIndeterm(commandId: string): boolean; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - createProcessingInstruction(target: string, data: string): ProcessingInstruction; - /** - * Executes a command on the current document, current selection, or the given range. - * @param commandId String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. - * @param showUI Display the user interface, defaults to false. - * @param value Value to assign. - */ - execCommand(commandId: string, showUI?: boolean, value?: any): boolean; - /** - * Returns the element for the specified x coordinate and the specified y coordinate. - * @param x The x-offset - * @param y The y-offset - */ - elementFromPoint(x: number, y: number): Element; - createCDATASection(data: string): CDATASection; - /** - * Retrieves the string associated with a command. - * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. - */ - queryCommandText(commandId: string): string; - /** - * Writes one or more HTML expressions to a document in the specified window. - * @param content Specifies the text and HTML tags to write. - */ - write(...content: string[]): void; - /** - * Allows updating the print settings for the page. - */ - updateSettings(): void; - /** - * Creates an instance of the element for the specified tag. - * @param tagName The name of an element. - */ - createElement(tagName: "a"): HTMLAnchorElement; - createElement(tagName: "abbr"): HTMLPhraseElement; - createElement(tagName: "acronym"): HTMLPhraseElement; - createElement(tagName: "address"): HTMLBlockElement; - createElement(tagName: "applet"): HTMLAppletElement; - createElement(tagName: "area"): HTMLAreaElement; - createElement(tagName: "article"): HTMLElement; - createElement(tagName: "aside"): HTMLElement; - createElement(tagName: "audio"): HTMLAudioElement; - createElement(tagName: "b"): HTMLPhraseElement; - createElement(tagName: "base"): HTMLBaseElement; - createElement(tagName: "basefont"): HTMLBaseFontElement; - createElement(tagName: "bdo"): HTMLPhraseElement; - createElement(tagName: "bgsound"): HTMLBGSoundElement; - createElement(tagName: "big"): HTMLPhraseElement; - createElement(tagName: "blockquote"): HTMLBlockElement; - createElement(tagName: "body"): HTMLBodyElement; - createElement(tagName: "br"): HTMLBRElement; - createElement(tagName: "button"): HTMLButtonElement; - createElement(tagName: "canvas"): HTMLCanvasElement; - createElement(tagName: "caption"): HTMLTableCaptionElement; - createElement(tagName: "center"): HTMLBlockElement; - createElement(tagName: "cite"): HTMLPhraseElement; - createElement(tagName: "code"): HTMLPhraseElement; - createElement(tagName: "col"): HTMLTableColElement; - createElement(tagName: "colgroup"): HTMLTableColElement; - createElement(tagName: "datalist"): HTMLDataListElement; - createElement(tagName: "dd"): HTMLDDElement; - createElement(tagName: "del"): HTMLModElement; - createElement(tagName: "dfn"): HTMLPhraseElement; - createElement(tagName: "dir"): HTMLDirectoryElement; - createElement(tagName: "div"): HTMLDivElement; - createElement(tagName: "dl"): HTMLDListElement; - createElement(tagName: "dt"): HTMLDTElement; - createElement(tagName: "em"): HTMLPhraseElement; - createElement(tagName: "embed"): HTMLEmbedElement; - createElement(tagName: "fieldset"): HTMLFieldSetElement; - createElement(tagName: "figcaption"): HTMLElement; - createElement(tagName: "figure"): HTMLElement; - createElement(tagName: "font"): HTMLFontElement; - createElement(tagName: "footer"): HTMLElement; - createElement(tagName: "form"): HTMLFormElement; - createElement(tagName: "frame"): HTMLFrameElement; - createElement(tagName: "frameset"): HTMLFrameSetElement; - createElement(tagName: "h1"): HTMLHeadingElement; - createElement(tagName: "h2"): HTMLHeadingElement; - createElement(tagName: "h3"): HTMLHeadingElement; - createElement(tagName: "h4"): HTMLHeadingElement; - createElement(tagName: "h5"): HTMLHeadingElement; - createElement(tagName: "h6"): HTMLHeadingElement; - createElement(tagName: "head"): HTMLHeadElement; - createElement(tagName: "header"): HTMLElement; - createElement(tagName: "hgroup"): HTMLElement; - createElement(tagName: "hr"): HTMLHRElement; - createElement(tagName: "html"): HTMLHtmlElement; - createElement(tagName: "i"): HTMLPhraseElement; - createElement(tagName: "iframe"): HTMLIFrameElement; - createElement(tagName: "img"): HTMLImageElement; - createElement(tagName: "input"): HTMLInputElement; - createElement(tagName: "ins"): HTMLModElement; - createElement(tagName: "isindex"): HTMLIsIndexElement; - createElement(tagName: "kbd"): HTMLPhraseElement; - createElement(tagName: "keygen"): HTMLBlockElement; - createElement(tagName: "label"): HTMLLabelElement; - createElement(tagName: "legend"): HTMLLegendElement; - createElement(tagName: "li"): HTMLLIElement; - createElement(tagName: "link"): HTMLLinkElement; - createElement(tagName: "listing"): HTMLBlockElement; - createElement(tagName: "map"): HTMLMapElement; - createElement(tagName: "mark"): HTMLElement; - createElement(tagName: "marquee"): HTMLMarqueeElement; - createElement(tagName: "menu"): HTMLMenuElement; - createElement(tagName: "meta"): HTMLMetaElement; - createElement(tagName: "nav"): HTMLElement; - createElement(tagName: "nextid"): HTMLNextIdElement; - createElement(tagName: "nobr"): HTMLPhraseElement; - createElement(tagName: "noframes"): HTMLElement; - createElement(tagName: "noscript"): HTMLElement; - createElement(tagName: "object"): HTMLObjectElement; - createElement(tagName: "ol"): HTMLOListElement; - createElement(tagName: "optgroup"): HTMLOptGroupElement; - createElement(tagName: "option"): HTMLOptionElement; - createElement(tagName: "p"): HTMLParagraphElement; - createElement(tagName: "param"): HTMLParamElement; - createElement(tagName: "plaintext"): HTMLBlockElement; - createElement(tagName: "pre"): HTMLPreElement; - createElement(tagName: "progress"): HTMLProgressElement; - createElement(tagName: "q"): HTMLQuoteElement; - createElement(tagName: "rt"): HTMLPhraseElement; - createElement(tagName: "ruby"): HTMLPhraseElement; - createElement(tagName: "s"): HTMLPhraseElement; - createElement(tagName: "samp"): HTMLPhraseElement; - createElement(tagName: "script"): HTMLScriptElement; - createElement(tagName: "section"): HTMLElement; - createElement(tagName: "select"): HTMLSelectElement; - createElement(tagName: "small"): HTMLPhraseElement; - createElement(tagName: "SOURCE"): HTMLSourceElement; - createElement(tagName: "span"): HTMLSpanElement; - createElement(tagName: "strike"): HTMLPhraseElement; - createElement(tagName: "strong"): HTMLPhraseElement; - createElement(tagName: "style"): HTMLStyleElement; - createElement(tagName: "sub"): HTMLPhraseElement; - createElement(tagName: "sup"): HTMLPhraseElement; - createElement(tagName: "table"): HTMLTableElement; - createElement(tagName: "tbody"): HTMLTableSectionElement; - createElement(tagName: "td"): HTMLTableDataCellElement; - createElement(tagName: "textarea"): HTMLTextAreaElement; - createElement(tagName: "tfoot"): HTMLTableSectionElement; - createElement(tagName: "th"): HTMLTableHeaderCellElement; - createElement(tagName: "thead"): HTMLTableSectionElement; - createElement(tagName: "title"): HTMLTitleElement; - createElement(tagName: "tr"): HTMLTableRowElement; - createElement(tagName: "track"): HTMLTrackElement; - createElement(tagName: "tt"): HTMLPhraseElement; - createElement(tagName: "u"): HTMLPhraseElement; - createElement(tagName: "ul"): HTMLUListElement; - createElement(tagName: "var"): HTMLPhraseElement; - createElement(tagName: "video"): HTMLVideoElement; - createElement(tagName: "wbr"): HTMLElement; - createElement(tagName: "x-ms-webview"): MSHTMLWebViewElement; - createElement(tagName: "xmp"): HTMLBlockElement; - createElement(tagName: string): HTMLElement; - /** - * Removes mouse capture from the object in the current document. - */ - releaseCapture(): void; - /** - * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. - * @param content The text and HTML tags to write. - */ - writeln(...content: string[]): void; - createElementNS(namespaceURI: string, qualifiedName: string): Element; - /** - * Opens a new window and loads a document specified by a given URL. Also, opens a new window that uses the url parameter and the name parameter to collect the output of the write method and the writeln method. - * @param url Specifies a MIME type for the document. - * @param name Specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element. - * @param features Contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported. - * @param replace Specifies whether the existing entry for the document is replaced in the history list. - */ - open(url?: string, name?: string, features?: string, replace?: boolean): any; - /** - * Returns a Boolean value that indicates whether the current command is supported on the current range. - * @param commandId Specifies a command identifier. - */ - queryCommandSupported(commandId: string): boolean; - /** - * Creates a TreeWalker object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list. For more information, see whatToShow. - * @param filter A custom NodeFilter function to use. - * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. - */ - createTreeWalker(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): TreeWalker; - createAttributeNS(namespaceURI: string, qualifiedName: string): Attr; - /** - * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. - * @param commandId Specifies a command identifier. - */ - queryCommandEnabled(commandId: string): boolean; - /** - * Causes the element to receive the focus and executes the code specified by the onfocus event. - */ - focus(): void; - /** - * Closes an output stream and forces the sent data to display. - */ - close(): void; - getElementsByClassName(classNames: string): NodeList; - importNode(importedNode: Node, deep: boolean): Node; - /** - * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. - */ - createRange(): Range; - /** - * Fires a specified event on the object. - * @param eventName Specifies the name of the event to fire. - * @param eventObj Object that specifies the event object from which to obtain event object properties. - */ - fireEvent(eventName: string, eventObj?: any): boolean; - /** - * Creates a comment object with the specified data. - * @param data Sets the comment object's data. - */ - createComment(data: string): Comment; - /** - * Retrieves a collection of objects based on the specified element name. - * @param name Specifies the name of an element. - */ - getElementsByTagName(name: "a"): NodeListOf; - getElementsByTagName(name: "abbr"): NodeListOf; - getElementsByTagName(name: "acronym"): NodeListOf; - getElementsByTagName(name: "address"): NodeListOf; - getElementsByTagName(name: "applet"): NodeListOf; - getElementsByTagName(name: "area"): NodeListOf; - getElementsByTagName(name: "article"): NodeListOf; - getElementsByTagName(name: "aside"): NodeListOf; - getElementsByTagName(name: "audio"): NodeListOf; - getElementsByTagName(name: "b"): NodeListOf; - getElementsByTagName(name: "base"): NodeListOf; - getElementsByTagName(name: "basefont"): NodeListOf; - getElementsByTagName(name: "bdo"): NodeListOf; - getElementsByTagName(name: "bgsound"): NodeListOf; - getElementsByTagName(name: "big"): NodeListOf; - getElementsByTagName(name: "blockquote"): NodeListOf; - getElementsByTagName(name: "body"): NodeListOf; - getElementsByTagName(name: "br"): NodeListOf; - getElementsByTagName(name: "button"): NodeListOf; - getElementsByTagName(name: "canvas"): NodeListOf; - getElementsByTagName(name: "caption"): NodeListOf; - getElementsByTagName(name: "center"): NodeListOf; - getElementsByTagName(name: "cite"): NodeListOf; - getElementsByTagName(name: "code"): NodeListOf; - getElementsByTagName(name: "col"): NodeListOf; - getElementsByTagName(name: "colgroup"): NodeListOf; - getElementsByTagName(name: "datalist"): NodeListOf; - getElementsByTagName(name: "dd"): NodeListOf; - getElementsByTagName(name: "del"): NodeListOf; - getElementsByTagName(name: "dfn"): NodeListOf; - getElementsByTagName(name: "dir"): NodeListOf; - getElementsByTagName(name: "div"): NodeListOf; - getElementsByTagName(name: "dl"): NodeListOf; - getElementsByTagName(name: "dt"): NodeListOf; - getElementsByTagName(name: "em"): NodeListOf; - getElementsByTagName(name: "embed"): NodeListOf; - getElementsByTagName(name: "fieldset"): NodeListOf; - getElementsByTagName(name: "figcaption"): NodeListOf; - getElementsByTagName(name: "figure"): NodeListOf; - getElementsByTagName(name: "font"): NodeListOf; - getElementsByTagName(name: "footer"): NodeListOf; - getElementsByTagName(name: "form"): NodeListOf; - getElementsByTagName(name: "frame"): NodeListOf; - getElementsByTagName(name: "frameset"): NodeListOf; - getElementsByTagName(name: "h1"): NodeListOf; - getElementsByTagName(name: "h2"): NodeListOf; - getElementsByTagName(name: "h3"): NodeListOf; - getElementsByTagName(name: "h4"): NodeListOf; - getElementsByTagName(name: "h5"): NodeListOf; - getElementsByTagName(name: "h6"): NodeListOf; - getElementsByTagName(name: "head"): NodeListOf; - getElementsByTagName(name: "header"): NodeListOf; - getElementsByTagName(name: "hgroup"): NodeListOf; - getElementsByTagName(name: "hr"): NodeListOf; - getElementsByTagName(name: "html"): NodeListOf; - getElementsByTagName(name: "i"): NodeListOf; - getElementsByTagName(name: "iframe"): NodeListOf; - getElementsByTagName(name: "img"): NodeListOf; - getElementsByTagName(name: "input"): NodeListOf; - getElementsByTagName(name: "ins"): NodeListOf; - getElementsByTagName(name: "isindex"): NodeListOf; - getElementsByTagName(name: "kbd"): NodeListOf; - getElementsByTagName(name: "keygen"): NodeListOf; - getElementsByTagName(name: "label"): NodeListOf; - getElementsByTagName(name: "legend"): NodeListOf; - getElementsByTagName(name: "li"): NodeListOf; - getElementsByTagName(name: "link"): NodeListOf; - getElementsByTagName(name: "listing"): NodeListOf; - getElementsByTagName(name: "map"): NodeListOf; - getElementsByTagName(name: "mark"): NodeListOf; - getElementsByTagName(name: "marquee"): NodeListOf; - getElementsByTagName(name: "menu"): NodeListOf; - getElementsByTagName(name: "meta"): NodeListOf; - getElementsByTagName(name: "nav"): NodeListOf; - getElementsByTagName(name: "nextid"): NodeListOf; - getElementsByTagName(name: "nobr"): NodeListOf; - getElementsByTagName(name: "noframes"): NodeListOf; - getElementsByTagName(name: "noscript"): NodeListOf; - getElementsByTagName(name: "object"): NodeListOf; - getElementsByTagName(name: "ol"): NodeListOf; - getElementsByTagName(name: "optgroup"): NodeListOf; - getElementsByTagName(name: "option"): NodeListOf; - getElementsByTagName(name: "p"): NodeListOf; - getElementsByTagName(name: "param"): NodeListOf; - getElementsByTagName(name: "plaintext"): NodeListOf; - getElementsByTagName(name: "pre"): NodeListOf; - getElementsByTagName(name: "progress"): NodeListOf; - getElementsByTagName(name: "q"): NodeListOf; - getElementsByTagName(name: "rt"): NodeListOf; - getElementsByTagName(name: "ruby"): NodeListOf; - getElementsByTagName(name: "s"): NodeListOf; - getElementsByTagName(name: "samp"): NodeListOf; - getElementsByTagName(name: "script"): NodeListOf; - getElementsByTagName(name: "section"): NodeListOf; - getElementsByTagName(name: "select"): NodeListOf; - getElementsByTagName(name: "small"): NodeListOf; - getElementsByTagName(name: "SOURCE"): NodeListOf; - getElementsByTagName(name: "span"): NodeListOf; - getElementsByTagName(name: "strike"): NodeListOf; - getElementsByTagName(name: "strong"): NodeListOf; - getElementsByTagName(name: "style"): NodeListOf; - getElementsByTagName(name: "sub"): NodeListOf; - getElementsByTagName(name: "sup"): NodeListOf; - getElementsByTagName(name: "table"): NodeListOf; - getElementsByTagName(name: "tbody"): NodeListOf; - getElementsByTagName(name: "td"): NodeListOf; - getElementsByTagName(name: "textarea"): NodeListOf; - getElementsByTagName(name: "tfoot"): NodeListOf; - getElementsByTagName(name: "th"): NodeListOf; - getElementsByTagName(name: "thead"): NodeListOf; - getElementsByTagName(name: "title"): NodeListOf; - getElementsByTagName(name: "tr"): NodeListOf; - getElementsByTagName(name: "track"): NodeListOf; - getElementsByTagName(name: "tt"): NodeListOf; - getElementsByTagName(name: "u"): NodeListOf; - getElementsByTagName(name: "ul"): NodeListOf; - getElementsByTagName(name: "var"): NodeListOf; - getElementsByTagName(name: "video"): NodeListOf; - getElementsByTagName(name: "wbr"): NodeListOf; - getElementsByTagName(name: "x-ms-webview"): NodeListOf; - getElementsByTagName(name: "xmp"): NodeListOf; - getElementsByTagName(name: string): NodeList; - /** - * Creates a new document. - */ - createDocumentFragment(): DocumentFragment; - /** - * Creates a style sheet for the document. - * @param href Specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object. - * @param index Specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection. - */ - createStyleSheet(href?: string, index?: number): CSSStyleSheet; - /** - * Gets a collection of objects based on the value of the NAME or ID attribute. - * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. - */ - getElementsByName(elementName: string): NodeList; - /** - * Returns a Boolean value that indicates the current state of the command. - * @param commandId String that specifies a command identifier. - */ - queryCommandState(commandId: string): boolean; - /** - * Gets a value indicating whether the object currently has focus. - */ - hasFocus(): boolean; - /** - * Displays help information for the given command identifier. - * @param commandId Displays help information for the given command identifier. - */ - execCommandShowHelp(commandId: string): boolean; - /** - * Creates an attribute object with a specified name. - * @param name String that sets the attribute object's name. - */ - createAttribute(name: string): Attr; - /** - * Creates a text string from the specified value. - * @param data String that specifies the nodeValue property of the text node. - */ - createTextNode(data: string): Text; - /** - * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. - * @param root The root element or node to start traversing on. - * @param whatToShow The type of nodes or elements to appear in the node list - * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. - * @param entityReferenceExpansion A flag that specifies whether entity reference nodes are expanded. - */ - createNodeIterator(root: Node, whatToShow: number, filter: NodeFilter, entityReferenceExpansion: boolean): NodeIterator; - /** - * Generates an event object to pass event context information when you use the fireEvent method. - * @param eventObj An object that specifies an existing event object on which to base the new object. - */ - createEventObject(eventObj?: any): MSEventObj; - /** - * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. - */ - getSelection(): Selection; - msElementsFromPoint(x: number, y: number): NodeList; - msElementsFromRect(left: number, top: number, width: number, height: number): NodeList; - clear(): void; - msExitFullscreen(): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "msthumbnailclick", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stop", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mssitemodejumplistitemremoved", listener: (ev: MSSiteModeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectionchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "storagecommit", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msfullscreenerror", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msfullscreenchange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var Document: { - prototype: Document; - new(): Document; -} - -interface Console { - info(message?: any, ...optionalParams: any[]): void; - warn(message?: any, ...optionalParams: any[]): void; - error(message?: any, ...optionalParams: any[]): void; - log(message?: any, ...optionalParams: any[]): void; - profile(reportName?: string): void; - assert(test?: boolean, message?: string, ...optionalParams: any[]): void; - msIsIndependentlyComposed(element: Element): boolean; - clear(): void; - dir(value?: any, ...optionalParams: any[]): void; - profileEnd(): void; - count(countTitle?: string): void; - groupEnd(): void; - time(timerName?: string): void; - timeEnd(timerName?: string): void; - trace(): void; - group(groupTitle?: string): void; - dirxml(value: any): void; - debug(message?: string, ...optionalParams: any[]): void; - groupCollapsed(groupTitle?: string): void; - select(element: Element): void; -} -declare var Console: { - prototype: Console; - new(): Console; -} - -interface MSEventObj extends Event { - nextPage: string; - keyCode: number; - toElement: Element; - returnValue: any; - dataFld: string; - y: number; - dataTransfer: DataTransfer; - propertyName: string; - url: string; - offsetX: number; - recordset: any; - screenX: number; - buttonID: number; - wheelDelta: number; - reason: number; - origin: string; - data: string; - srcFilter: any; - boundElements: HTMLCollection; - cancelBubble: boolean; - altLeft: boolean; - behaviorCookie: number; - bookmarks: BookmarkCollection; - type: string; - repeat: boolean; - srcElement: Element; - source: Window; - fromElement: Element; - offsetY: number; - x: number; - behaviorPart: number; - qualifier: string; - altKey: boolean; - ctrlKey: boolean; - clientY: number; - shiftKey: boolean; - shiftLeft: boolean; - contentOverflow: boolean; - screenY: number; - ctrlLeft: boolean; - button: number; - srcUrn: string; - clientX: number; - actionURL: string; - getAttribute(strAttributeName: string, lFlags?: number): any; - setAttribute(strAttributeName: string, AttributeValue: any, lFlags?: number): void; - removeAttribute(strAttributeName: string, lFlags?: number): boolean; -} -declare var MSEventObj: { - prototype: MSEventObj; - new(): MSEventObj; -} - -interface HTMLCanvasElement extends HTMLElement { - /** - * Gets or sets the width of a canvas element on a document. - */ - width: number; - /** - * Gets or sets the height of a canvas element on a document. - */ - height: number; - /** - * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. - * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); - */ - getContext(contextId: "2d"): CanvasRenderingContext2D; - /** - * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. - * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); - */ - getContext(contextId: "experimental-webgl"): WebGLRenderingContext; - /** - * Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas. - * @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl"); - */ - getContext(contextId: string, ...args: any[]): any; - /** - * Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element. - * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. - */ - toDataURL(type?: string, ...args: any[]): string; - /** - * Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing. - */ - msToBlob(): Blob; -} -declare var HTMLCanvasElement: { - prototype: HTMLCanvasElement; - new(): HTMLCanvasElement; -} - -interface Window extends EventTarget, MSEventAttachmentTarget, WindowLocalStorage, MSWindowExtensions, WindowSessionStorage, WindowTimers, WindowBase64, IDBEnvironment, WindowConsole, GlobalEventHandlers { - ondragend: (ev: DragEvent) => any; - onkeydown: (ev: KeyboardEvent) => any; - ondragover: (ev: DragEvent) => any; - onkeyup: (ev: KeyboardEvent) => any; - onreset: (ev: Event) => any; - onmouseup: (ev: MouseEvent) => any; - ondragstart: (ev: DragEvent) => any; - ondrag: (ev: DragEvent) => any; - screenX: number; - onmouseover: (ev: MouseEvent) => any; - ondragleave: (ev: DragEvent) => any; - history: History; - pageXOffset: number; - name: string; - onafterprint: (ev: Event) => any; - onpause: (ev: Event) => any; - onbeforeprint: (ev: Event) => any; - top: Window; - onmousedown: (ev: MouseEvent) => any; - onseeked: (ev: Event) => any; - opener: Window; - onclick: (ev: MouseEvent) => any; - innerHeight: number; - onwaiting: (ev: Event) => any; - ononline: (ev: Event) => any; - ondurationchange: (ev: Event) => any; - frames: Window; - onblur: (ev: FocusEvent) => any; - onemptied: (ev: Event) => any; - onseeking: (ev: Event) => any; - oncanplay: (ev: Event) => any; - outerWidth: number; - onstalled: (ev: Event) => any; - onmousemove: (ev: MouseEvent) => any; - innerWidth: number; - onoffline: (ev: Event) => any; - length: number; - screen: Screen; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - onratechange: (ev: Event) => any; - onstorage: (ev: StorageEvent) => any; - onloadstart: (ev: Event) => any; - ondragenter: (ev: DragEvent) => any; - onsubmit: (ev: Event) => any; - self: Window; - document: Document; - onprogress: (ev: ProgressEvent) => any; - ondblclick: (ev: MouseEvent) => any; - pageYOffset: number; - oncontextmenu: (ev: MouseEvent) => any; - onchange: (ev: Event) => any; - onloadedmetadata: (ev: Event) => any; - onplay: (ev: Event) => any; - onerror: ErrorEventHandler; - onplaying: (ev: Event) => any; - parent: Window; - location: Location; - oncanplaythrough: (ev: Event) => any; - onabort: (ev: UIEvent) => any; - onreadystatechange: (ev: Event) => any; - outerHeight: number; - onkeypress: (ev: KeyboardEvent) => any; - frameElement: Element; - onloadeddata: (ev: Event) => any; - onsuspend: (ev: Event) => any; - window: Window; - onfocus: (ev: FocusEvent) => any; - onmessage: (ev: MessageEvent) => any; - ontimeupdate: (ev: Event) => any; - onresize: (ev: UIEvent) => any; - onselect: (ev: UIEvent) => any; - navigator: Navigator; - styleMedia: StyleMedia; - ondrop: (ev: DragEvent) => any; - onmouseout: (ev: MouseEvent) => any; - onended: (ev: Event) => any; - onhashchange: (ev: Event) => any; - onunload: (ev: Event) => any; - onscroll: (ev: UIEvent) => any; - screenY: number; - onmousewheel: (ev: MouseWheelEvent) => any; - onload: (ev: Event) => any; - onvolumechange: (ev: Event) => any; - oninput: (ev: Event) => any; - performance: Performance; - onmspointerdown: (ev: any) => any; - animationStartTime: number; - onmsgesturedoubletap: (ev: any) => any; - onmspointerhover: (ev: any) => any; - onmsgesturehold: (ev: any) => any; - onmspointermove: (ev: any) => any; - onmsgesturechange: (ev: any) => any; - onmsgesturestart: (ev: any) => any; - onmspointercancel: (ev: any) => any; - onmsgestureend: (ev: any) => any; - onmsgesturetap: (ev: any) => any; - onmspointerout: (ev: any) => any; - msAnimationStartTime: number; - applicationCache: ApplicationCache; - onmsinertiastart: (ev: any) => any; - onmspointerover: (ev: any) => any; - onpopstate: (ev: PopStateEvent) => any; - onmspointerup: (ev: any) => any; - onpageshow: (ev: PageTransitionEvent) => any; - ondevicemotion: (ev: DeviceMotionEvent) => any; - devicePixelRatio: number; - msCrypto: Crypto; - ondeviceorientation: (ev: DeviceOrientationEvent) => any; - doNotTrack: string; - onmspointerenter: (ev: any) => any; - onpagehide: (ev: PageTransitionEvent) => any; - onmspointerleave: (ev: any) => any; - alert(message?: any): void; - scroll(x?: number, y?: number): void; - focus(): void; - scrollTo(x?: number, y?: number): void; - print(): void; - prompt(message?: string, _default?: string): string; - toString(): string; - open(url?: string, target?: string, features?: string, replace?: boolean): Window; - scrollBy(x?: number, y?: number): void; - confirm(message?: string): boolean; - close(): void; - postMessage(message: any, targetOrigin: string, ports?: any): void; - showModalDialog(url?: string, argument?: any, options?: any): any; - blur(): void; - getSelection(): Selection; - getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; - msCancelRequestAnimationFrame(handle: number): void; - matchMedia(mediaQuery: string): MediaQueryList; - cancelAnimationFrame(handle: number): void; - msIsStaticHTML(html: string): boolean; - msMatchMedia(mediaQuery: string): MediaQueryList; - requestAnimationFrame(callback: FrameRequestCallback): number; - msRequestAnimationFrame(callback: FrameRequestCallback): number; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var Window: { - prototype: Window; - new(): Window; -} - -interface HTMLCollection extends MSHTMLCollectionExtensions { - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Retrieves an object from various collections. - */ - item(nameOrIndex?: any, optionalIndex?: any): Element; - /** - * Retrieves a select object or an object from an options collection. - */ - namedItem(name: string): Element; - // [name: string]: Element; - [index: number]: Element; -} -declare var HTMLCollection: { - prototype: HTMLCollection; - new(): HTMLCollection; -} - -interface BlobPropertyBag { - type?: string; - endings?: string; -} - -interface Blob { - type: string; - size: number; - msDetachStream(): any; - slice(start?: number, end?: number, contentType?: string): Blob; - msClose(): void; -} -declare var Blob: { - prototype: Blob; - new (blobParts?: any[], options?: BlobPropertyBag): Blob; -} - -interface NavigatorID { - appVersion: string; - appName: string; - userAgent: string; - platform: string; - product: string; - vendor: string; -} - -interface HTMLTableElement extends HTMLElement, MSDataBindingTableExtensions, MSDataBindingExtensions, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Sets or retrieves the amount of space between cells in a table. - */ - cellSpacing: string; - /** - * Retrieves the tFoot object of the table. - */ - tFoot: HTMLTableSectionElement; - /** - * Sets or retrieves the way the border frame around the table is displayed. - */ - frame: string; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: HTMLCollection; - /** - * Sets or retrieves which dividing lines (inner borders) are displayed. - */ - rules: string; - /** - * Sets or retrieves the number of columns in the table. - */ - cols: number; - /** - * Sets or retrieves a description and/or structure of the object. - */ - summary: string; - /** - * Retrieves the caption object of a table. - */ - caption: HTMLTableCaptionElement; - /** - * Retrieves a collection of all tBody objects in the table. Objects in this collection are in source order. - */ - tBodies: HTMLCollection; - /** - * Retrieves the tHead object of the table. - */ - tHead: HTMLTableSectionElement; - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; - /** - * Retrieves a collection of all cells in the table row or in the entire table. - */ - cells: HTMLCollection; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves the amount of space between the border of the cell and the content of the cell. - */ - cellPadding: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - border: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; - /** - * Removes the specified row (tr) from the element and from the rows collection. - * @param index Number that specifies the zero-based position in the rows collection of the row to remove. - */ - deleteRow(index?: number): void; - /** - * Creates an empty tBody element in the table. - */ - createTBody(): HTMLElement; - /** - * Deletes the caption element and its contents from the table. - */ - deleteCaption(): void; - /** - * Creates a new row (tr) in the table, and adds the row to the rows collection. - * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. - */ - insertRow(index?: number): HTMLElement; - /** - * Deletes the tFoot element and its contents from the table. - */ - deleteTFoot(): void; - /** - * Returns the tHead element object if successful, or null otherwise. - */ - createTHead(): HTMLElement; - /** - * Deletes the tHead element and its contents from the table. - */ - deleteTHead(): void; - /** - * Creates an empty caption element in the table. - */ - createCaption(): HTMLElement; - /** - * Moves a table row to a new position. - * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. - * @param indexTo Number that specifies where the row is moved within the rows collection. - */ - moveRow(indexFrom?: number, indexTo?: number): any; - /** - * Creates an empty tFoot element in the table. - */ - createTFoot(): HTMLElement; -} -declare var HTMLTableElement: { - prototype: HTMLTableElement; - new(): HTMLTableElement; -} - -interface TreeWalker { - whatToShow: number; - filter: NodeFilter; - root: Node; - currentNode: Node; - expandEntityReferences: boolean; - previousSibling(): Node; - lastChild(): Node; - nextSibling(): Node; - nextNode(): Node; - parentNode(): Node; - firstChild(): Node; - previousNode(): Node; -} -declare var TreeWalker: { - prototype: TreeWalker; - new(): TreeWalker; -} - -interface GetSVGDocument { - getSVGDocument(): Document; -} - -interface SVGPathSegCurvetoQuadraticRel extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticRel: { - prototype: SVGPathSegCurvetoQuadraticRel; - new(): SVGPathSegCurvetoQuadraticRel; -} - -interface Performance { - navigation: PerformanceNavigation; - timing: PerformanceTiming; - getEntriesByType(entryType: string): any; - toJSON(): any; - getMeasures(measureName?: string): any; - clearMarks(markName?: string): void; - getMarks(markName?: string): any; - clearResourceTimings(): void; - mark(markName: string): void; - measure(measureName: string, startMarkName?: string, endMarkName?: string): void; - getEntriesByName(name: string, entryType?: string): any; - getEntries(): any; - clearMeasures(measureName?: string): void; - setResourceTimingBufferSize(maxSize: number): void; - now(): number; -} -declare var Performance: { - prototype: Performance; - new(): Performance; -} - -interface MSDataBindingTableExtensions { - dataPageSize: number; - nextPage(): void; - firstPage(): void; - refresh(): void; - previousPage(): void; - lastPage(): void; -} - -interface CompositionEvent extends UIEvent { - data: string; - locale: string; - initCompositionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, locale: string): void; -} -declare var CompositionEvent: { - prototype: CompositionEvent; - new(): CompositionEvent; -} - -interface WindowTimers extends WindowTimersExtension { - clearTimeout(handle: number): void; - setTimeout(handler: any, timeout?: any, ...args: any[]): number; - clearInterval(handle: number): void; - setInterval(handler: any, timeout?: any, ...args: any[]): number; -} - -interface SVGMarkerElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { - orientType: SVGAnimatedEnumeration; - markerUnits: SVGAnimatedEnumeration; - markerWidth: SVGAnimatedLength; - markerHeight: SVGAnimatedLength; - orientAngle: SVGAnimatedAngle; - refY: SVGAnimatedLength; - refX: SVGAnimatedLength; - setOrientToAngle(angle: SVGAngle): void; - setOrientToAuto(): void; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} -declare var SVGMarkerElement: { - prototype: SVGMarkerElement; - new(): SVGMarkerElement; - SVG_MARKER_ORIENT_UNKNOWN: number; - SVG_MARKER_ORIENT_ANGLE: number; - SVG_MARKERUNITS_UNKNOWN: number; - SVG_MARKERUNITS_STROKEWIDTH: number; - SVG_MARKER_ORIENT_AUTO: number; - SVG_MARKERUNITS_USERSPACEONUSE: number; -} - -interface CSSStyleDeclaration { - backgroundAttachment: string; - visibility: string; - textAlignLast: string; - borderRightStyle: string; - counterIncrement: string; - orphans: string; - cssText: string; - borderStyle: string; - pointerEvents: string; - borderTopColor: string; - markerEnd: string; - textIndent: string; - listStyleImage: string; - cursor: string; - listStylePosition: string; - wordWrap: string; - borderTopStyle: string; - alignmentBaseline: string; - opacity: string; - direction: string; - strokeMiterlimit: string; - maxWidth: string; - color: string; - clip: string; - borderRightWidth: string; - verticalAlign: string; - overflow: string; - mask: string; - borderLeftStyle: string; - emptyCells: string; - stopOpacity: string; - paddingRight: string; - parentRule: CSSRule; - background: string; - boxSizing: string; - textJustify: string; - height: string; - paddingTop: string; - length: number; - right: string; - baselineShift: string; - borderLeft: string; - widows: string; - lineHeight: string; - left: string; - textUnderlinePosition: string; - glyphOrientationHorizontal: string; - display: string; - textAnchor: string; - cssFloat: string; - strokeDasharray: string; - rubyAlign: string; - fontSizeAdjust: string; - borderLeftColor: string; - backgroundImage: string; - listStyleType: string; - strokeWidth: string; - textOverflow: string; - fillRule: string; - borderBottomColor: string; - zIndex: string; - position: string; - listStyle: string; - msTransformOrigin: string; - dominantBaseline: string; - overflowY: string; - fill: string; - captionSide: string; - borderCollapse: string; - boxShadow: string; - quotes: string; - tableLayout: string; - unicodeBidi: string; - borderBottomWidth: string; - backgroundSize: string; - textDecoration: string; - strokeDashoffset: string; - fontSize: string; - border: string; - pageBreakBefore: string; - borderTopRightRadius: string; - msTransform: string; - borderBottomLeftRadius: string; - textTransform: string; - rubyPosition: string; - strokeLinejoin: string; - clipPath: string; - borderRightColor: string; - fontFamily: string; - clear: string; - content: string; - backgroundClip: string; - marginBottom: string; - counterReset: string; - outlineWidth: string; - marginRight: string; - paddingLeft: string; - borderBottom: string; - wordBreak: string; - marginTop: string; - top: string; - fontWeight: string; - borderRight: string; - width: string; - kerning: string; - pageBreakAfter: string; - borderBottomStyle: string; - fontStretch: string; - padding: string; - strokeOpacity: string; - markerStart: string; - bottom: string; - borderLeftWidth: string; - clipRule: string; - backgroundPosition: string; - backgroundColor: string; - pageBreakInside: string; - backgroundOrigin: string; - strokeLinecap: string; - borderTopWidth: string; - outlineStyle: string; - borderTop: string; - outlineColor: string; - paddingBottom: string; - marginLeft: string; - font: string; - outline: string; - wordSpacing: string; - maxHeight: string; - fillOpacity: string; - letterSpacing: string; - borderSpacing: string; - backgroundRepeat: string; - borderRadius: string; - borderWidth: string; - borderBottomRightRadius: string; - whiteSpace: string; - fontStyle: string; - minWidth: string; - stopColor: string; - borderTopLeftRadius: string; - borderColor: string; - marker: string; - glyphOrientationVertical: string; - markerMid: string; - fontVariant: string; - minHeight: string; - stroke: string; - rubyOverhang: string; - overflowX: string; - textAlign: string; - margin: string; - animationFillMode: string; - floodColor: string; - animationIterationCount: string; - textShadow: string; - backfaceVisibility: string; - msAnimationIterationCount: string; - animationDelay: string; - animationTimingFunction: string; - columnWidth: any; - msScrollSnapX: string; - columnRuleColor: any; - columnRuleWidth: any; - transitionDelay: string; - transition: string; - msFlowFrom: string; - msScrollSnapType: string; - msContentZoomSnapType: string; - msGridColumns: string; - msAnimationName: string; - msGridRowAlign: string; - msContentZoomChaining: string; - msGridColumn: any; - msHyphenateLimitZone: any; - msScrollRails: string; - msAnimationDelay: string; - enableBackground: string; - msWrapThrough: string; - columnRuleStyle: string; - msAnimation: string; - msFlexFlow: string; - msScrollSnapY: string; - msHyphenateLimitLines: any; - msTouchAction: string; - msScrollLimit: string; - animation: string; - transform: string; - filter: string; - colorInterpolationFilters: string; - transitionTimingFunction: string; - msBackfaceVisibility: string; - animationPlayState: string; - transformOrigin: string; - msScrollLimitYMin: any; - msFontFeatureSettings: string; - msContentZoomLimitMin: any; - columnGap: any; - transitionProperty: string; - msAnimationDuration: string; - msAnimationFillMode: string; - msFlexDirection: string; - msTransitionDuration: string; - fontFeatureSettings: string; - breakBefore: string; - msFlexWrap: string; - perspective: string; - msFlowInto: string; - msTransformStyle: string; - msScrollTranslation: string; - msTransitionProperty: string; - msUserSelect: string; - msOverflowStyle: string; - msScrollSnapPointsY: string; - animationDirection: string; - animationDuration: string; - msFlex: string; - msTransitionTimingFunction: string; - animationName: string; - columnRule: string; - msGridColumnSpan: any; - msFlexNegative: string; - columnFill: string; - msGridRow: any; - msFlexOrder: string; - msFlexItemAlign: string; - msFlexPositive: string; - msContentZoomLimitMax: any; - msScrollLimitYMax: any; - msGridColumnAlign: string; - perspectiveOrigin: string; - lightingColor: string; - columns: string; - msScrollChaining: string; - msHyphenateLimitChars: string; - msTouchSelect: string; - floodOpacity: string; - msAnimationDirection: string; - msAnimationPlayState: string; - columnSpan: string; - msContentZooming: string; - msPerspective: string; - msFlexPack: string; - msScrollSnapPointsX: string; - msContentZoomSnapPoints: string; - msGridRowSpan: any; - msContentZoomSnap: string; - msScrollLimitXMin: any; - breakInside: string; - msHighContrastAdjust: string; - msFlexLinePack: string; - msGridRows: string; - transitionDuration: string; - msHyphens: string; - breakAfter: string; - msTransition: string; - msPerspectiveOrigin: string; - msContentZoomLimit: string; - msScrollLimitXMax: any; - msFlexAlign: string; - msWrapMargin: any; - columnCount: any; - msAnimationTimingFunction: string; - msTransitionDelay: string; - transformStyle: string; - msWrapFlow: string; - msFlexPreferredSize: string; - alignItems: string; - borderImageSource: string; - flexBasis: string; - borderImageWidth: string; - borderImageRepeat: string; - order: string; - flex: string; - alignContent: string; - msImeAlign: string; - flexShrink: string; - flexGrow: string; - borderImageSlice: string; - flexWrap: string; - borderImageOutset: string; - flexDirection: string; - touchAction: string; - flexFlow: string; - borderImage: string; - justifyContent: string; - alignSelf: string; - msTextCombineHorizontal: string; - getPropertyPriority(propertyName: string): string; - getPropertyValue(propertyName: string): string; - removeProperty(propertyName: string): string; - item(index: number): string; - [index: number]: string; - setProperty(propertyName: string, value: string, priority?: string): void; -} -declare var CSSStyleDeclaration: { - prototype: CSSStyleDeclaration; - new(): CSSStyleDeclaration; -} - -interface SVGGElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGGElement: { - prototype: SVGGElement; - new(): SVGGElement; -} - -interface MSStyleCSSProperties extends MSCSSProperties { - pixelWidth: number; - posHeight: number; - posLeft: number; - pixelTop: number; - pixelBottom: number; - textDecorationNone: boolean; - pixelLeft: number; - posTop: number; - posBottom: number; - textDecorationOverline: boolean; - posWidth: number; - textDecorationLineThrough: boolean; - pixelHeight: number; - textDecorationBlink: boolean; - posRight: number; - pixelRight: number; - textDecorationUnderline: boolean; -} -declare var MSStyleCSSProperties: { - prototype: MSStyleCSSProperties; - new(): MSStyleCSSProperties; -} - -interface Navigator extends NavigatorID, NavigatorOnLine, NavigatorContentUtils, MSNavigatorExtensions, NavigatorGeolocation, MSNavigatorDoNotTrack, NavigatorStorageUtils, MSFileSaver { - msMaxTouchPoints: number; - msPointerEnabled: boolean; - msManipulationViewsEnabled: boolean; - pointerEnabled: boolean; - maxTouchPoints: number; - msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; -} -declare var Navigator: { - prototype: Navigator; - new(): Navigator; -} - -interface SVGPathSegCurvetoCubicSmoothAbs extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothAbs: { - prototype: SVGPathSegCurvetoCubicSmoothAbs; - new(): SVGPathSegCurvetoCubicSmoothAbs; -} - -interface SVGZoomEvent extends UIEvent { - zoomRectScreen: SVGRect; - previousScale: number; - newScale: number; - previousTranslate: SVGPoint; - newTranslate: SVGPoint; -} -declare var SVGZoomEvent: { - prototype: SVGZoomEvent; - new(): SVGZoomEvent; -} - -interface NodeSelector { - querySelectorAll(selectors: string): NodeList; - querySelector(selectors: string): Element; -} - -interface HTMLTableDataCellElement extends HTMLTableCellElement { -} -declare var HTMLTableDataCellElement: { - prototype: HTMLTableDataCellElement; - new(): HTMLTableDataCellElement; -} - -interface HTMLBaseElement extends HTMLElement { - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Gets or sets the baseline URL on which relative links are based. - */ - href: string; -} -declare var HTMLBaseElement: { - prototype: HTMLBaseElement; - new(): HTMLBaseElement; -} - -interface ClientRect { - left: number; - width: number; - right: number; - top: number; - bottom: number; - height: number; -} -declare var ClientRect: { - prototype: ClientRect; - new(): ClientRect; -} - -interface PositionErrorCallback { - (error: PositionError): void; -} - -interface DOMImplementation { - createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; - createDocument(namespaceURI: string, qualifiedName: string, doctype: DocumentType): Document; - hasFeature(feature: string, version?: string): boolean; - createHTMLDocument(title: string): Document; -} -declare var DOMImplementation: { - prototype: DOMImplementation; - new(): DOMImplementation; -} - -interface SVGUnitTypes { - SVG_UNIT_TYPE_UNKNOWN: number; - SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; - SVG_UNIT_TYPE_USERSPACEONUSE: number; -} -declare var SVGUnitTypes: SVGUnitTypes; - -interface Element extends Node, NodeSelector, ElementTraversal, GlobalEventHandlers { - scrollTop: number; - clientLeft: number; - scrollLeft: number; - tagName: string; - clientWidth: number; - scrollWidth: number; - clientHeight: number; - clientTop: number; - scrollHeight: number; - msRegionOverflow: string; - onmspointerdown: (ev: any) => any; - onmsgotpointercapture: (ev: any) => any; - onmsgesturedoubletap: (ev: any) => any; - onmspointerhover: (ev: any) => any; - onmsgesturehold: (ev: any) => any; - onmspointermove: (ev: any) => any; - onmsgesturechange: (ev: any) => any; - onmsgesturestart: (ev: any) => any; - onmspointercancel: (ev: any) => any; - onmsgestureend: (ev: any) => any; - onmsgesturetap: (ev: any) => any; - onmspointerout: (ev: any) => any; - onmsinertiastart: (ev: any) => any; - onmslostpointercapture: (ev: any) => any; - onmspointerover: (ev: any) => any; - msContentZoomFactor: number; - onmspointerup: (ev: any) => any; - onlostpointercapture: (ev: PointerEvent) => any; - onmspointerenter: (ev: any) => any; - ongotpointercapture: (ev: PointerEvent) => any; - onmspointerleave: (ev: any) => any; - getAttribute(name?: string): string; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; - hasAttributeNS(namespaceURI: string, localName: string): boolean; - getBoundingClientRect(): ClientRect; - getAttributeNS(namespaceURI: string, localName: string): string; - getAttributeNodeNS(namespaceURI: string, localName: string): Attr; - setAttributeNodeNS(newAttr: Attr): Attr; - msMatchesSelector(selectors: string): boolean; - hasAttribute(name: string): boolean; - removeAttribute(name?: string): void; - setAttributeNS(namespaceURI: string, qualifiedName: string, value: string): void; - getAttributeNode(name: string): Attr; - fireEvent(eventName: string, eventObj?: any): boolean; - getElementsByTagName(name: "a"): NodeListOf; - getElementsByTagName(name: "abbr"): NodeListOf; - getElementsByTagName(name: "acronym"): NodeListOf; - getElementsByTagName(name: "address"): NodeListOf; - getElementsByTagName(name: "applet"): NodeListOf; - getElementsByTagName(name: "area"): NodeListOf; - getElementsByTagName(name: "article"): NodeListOf; - getElementsByTagName(name: "aside"): NodeListOf; - getElementsByTagName(name: "audio"): NodeListOf; - getElementsByTagName(name: "b"): NodeListOf; - getElementsByTagName(name: "base"): NodeListOf; - getElementsByTagName(name: "basefont"): NodeListOf; - getElementsByTagName(name: "bdo"): NodeListOf; - getElementsByTagName(name: "bgsound"): NodeListOf; - getElementsByTagName(name: "big"): NodeListOf; - getElementsByTagName(name: "blockquote"): NodeListOf; - getElementsByTagName(name: "body"): NodeListOf; - getElementsByTagName(name: "br"): NodeListOf; - getElementsByTagName(name: "button"): NodeListOf; - getElementsByTagName(name: "canvas"): NodeListOf; - getElementsByTagName(name: "caption"): NodeListOf; - getElementsByTagName(name: "center"): NodeListOf; - getElementsByTagName(name: "cite"): NodeListOf; - getElementsByTagName(name: "code"): NodeListOf; - getElementsByTagName(name: "col"): NodeListOf; - getElementsByTagName(name: "colgroup"): NodeListOf; - getElementsByTagName(name: "datalist"): NodeListOf; - getElementsByTagName(name: "dd"): NodeListOf; - getElementsByTagName(name: "del"): NodeListOf; - getElementsByTagName(name: "dfn"): NodeListOf; - getElementsByTagName(name: "dir"): NodeListOf; - getElementsByTagName(name: "div"): NodeListOf; - getElementsByTagName(name: "dl"): NodeListOf; - getElementsByTagName(name: "dt"): NodeListOf; - getElementsByTagName(name: "em"): NodeListOf; - getElementsByTagName(name: "embed"): NodeListOf; - getElementsByTagName(name: "fieldset"): NodeListOf; - getElementsByTagName(name: "figcaption"): NodeListOf; - getElementsByTagName(name: "figure"): NodeListOf; - getElementsByTagName(name: "font"): NodeListOf; - getElementsByTagName(name: "footer"): NodeListOf; - getElementsByTagName(name: "form"): NodeListOf; - getElementsByTagName(name: "frame"): NodeListOf; - getElementsByTagName(name: "frameset"): NodeListOf; - getElementsByTagName(name: "h1"): NodeListOf; - getElementsByTagName(name: "h2"): NodeListOf; - getElementsByTagName(name: "h3"): NodeListOf; - getElementsByTagName(name: "h4"): NodeListOf; - getElementsByTagName(name: "h5"): NodeListOf; - getElementsByTagName(name: "h6"): NodeListOf; - getElementsByTagName(name: "head"): NodeListOf; - getElementsByTagName(name: "header"): NodeListOf; - getElementsByTagName(name: "hgroup"): NodeListOf; - getElementsByTagName(name: "hr"): NodeListOf; - getElementsByTagName(name: "html"): NodeListOf; - getElementsByTagName(name: "i"): NodeListOf; - getElementsByTagName(name: "iframe"): NodeListOf; - getElementsByTagName(name: "img"): NodeListOf; - getElementsByTagName(name: "input"): NodeListOf; - getElementsByTagName(name: "ins"): NodeListOf; - getElementsByTagName(name: "isindex"): NodeListOf; - getElementsByTagName(name: "kbd"): NodeListOf; - getElementsByTagName(name: "keygen"): NodeListOf; - getElementsByTagName(name: "label"): NodeListOf; - getElementsByTagName(name: "legend"): NodeListOf; - getElementsByTagName(name: "li"): NodeListOf; - getElementsByTagName(name: "link"): NodeListOf; - getElementsByTagName(name: "listing"): NodeListOf; - getElementsByTagName(name: "map"): NodeListOf; - getElementsByTagName(name: "mark"): NodeListOf; - getElementsByTagName(name: "marquee"): NodeListOf; - getElementsByTagName(name: "menu"): NodeListOf; - getElementsByTagName(name: "meta"): NodeListOf; - getElementsByTagName(name: "nav"): NodeListOf; - getElementsByTagName(name: "nextid"): NodeListOf; - getElementsByTagName(name: "nobr"): NodeListOf; - getElementsByTagName(name: "noframes"): NodeListOf; - getElementsByTagName(name: "noscript"): NodeListOf; - getElementsByTagName(name: "object"): NodeListOf; - getElementsByTagName(name: "ol"): NodeListOf; - getElementsByTagName(name: "optgroup"): NodeListOf; - getElementsByTagName(name: "option"): NodeListOf; - getElementsByTagName(name: "p"): NodeListOf; - getElementsByTagName(name: "param"): NodeListOf; - getElementsByTagName(name: "plaintext"): NodeListOf; - getElementsByTagName(name: "pre"): NodeListOf; - getElementsByTagName(name: "progress"): NodeListOf; - getElementsByTagName(name: "q"): NodeListOf; - getElementsByTagName(name: "rt"): NodeListOf; - getElementsByTagName(name: "ruby"): NodeListOf; - getElementsByTagName(name: "s"): NodeListOf; - getElementsByTagName(name: "samp"): NodeListOf; - getElementsByTagName(name: "script"): NodeListOf; - getElementsByTagName(name: "section"): NodeListOf; - getElementsByTagName(name: "select"): NodeListOf; - getElementsByTagName(name: "small"): NodeListOf; - getElementsByTagName(name: "SOURCE"): NodeListOf; - getElementsByTagName(name: "span"): NodeListOf; - getElementsByTagName(name: "strike"): NodeListOf; - getElementsByTagName(name: "strong"): NodeListOf; - getElementsByTagName(name: "style"): NodeListOf; - getElementsByTagName(name: "sub"): NodeListOf; - getElementsByTagName(name: "sup"): NodeListOf; - getElementsByTagName(name: "table"): NodeListOf; - getElementsByTagName(name: "tbody"): NodeListOf; - getElementsByTagName(name: "td"): NodeListOf; - getElementsByTagName(name: "textarea"): NodeListOf; - getElementsByTagName(name: "tfoot"): NodeListOf; - getElementsByTagName(name: "th"): NodeListOf; - getElementsByTagName(name: "thead"): NodeListOf; - getElementsByTagName(name: "title"): NodeListOf; - getElementsByTagName(name: "tr"): NodeListOf; - getElementsByTagName(name: "track"): NodeListOf; - getElementsByTagName(name: "tt"): NodeListOf; - getElementsByTagName(name: "u"): NodeListOf; - getElementsByTagName(name: "ul"): NodeListOf; - getElementsByTagName(name: "var"): NodeListOf; - getElementsByTagName(name: "video"): NodeListOf; - getElementsByTagName(name: "wbr"): NodeListOf; - getElementsByTagName(name: "x-ms-webview"): NodeListOf; - getElementsByTagName(name: "xmp"): NodeListOf; - getElementsByTagName(name: string): NodeList; - getClientRects(): ClientRectList; - setAttributeNode(newAttr: Attr): Attr; - removeAttributeNode(oldAttr: Attr): Attr; - setAttribute(name?: string, value?: string): void; - removeAttributeNS(namespaceURI: string, localName: string): void; - msGetRegionContent(): MSRangeCollection; - msReleasePointerCapture(pointerId: number): void; - msSetPointerCapture(pointerId: number): void; - msZoomTo(args: MsZoomToOptions): void; - setPointerCapture(pointerId: number): void; - msGetUntransformedBounds(): ClientRect; - releasePointerCapture(pointerId: number): void; - msRequestFullscreen(): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var Element: { - prototype: Element; - new(): Element; -} - -interface HTMLNextIdElement extends HTMLElement { - n: string; -} -declare var HTMLNextIdElement: { - prototype: HTMLNextIdElement; - new(): HTMLNextIdElement; -} - -interface SVGPathSegMovetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoRel: { - prototype: SVGPathSegMovetoRel; - new(): SVGPathSegMovetoRel; -} - -interface SVGLineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLineElement: { - prototype: SVGLineElement; - new(): SVGLineElement; -} - -interface HTMLParagraphElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; -} -declare var HTMLParagraphElement: { - prototype: HTMLParagraphElement; - new(): HTMLParagraphElement; -} - -interface HTMLAreasCollection extends HTMLCollection { - /** - * Removes an element from the collection. - */ - remove(index?: number): void; - /** - * Adds an element to the areas, controlRange, or options collection. - */ - add(element: HTMLElement, before?: any): void; -} -declare var HTMLAreasCollection: { - prototype: HTMLAreasCollection; - new(): HTMLAreasCollection; -} - -interface SVGDescElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGDescElement: { - prototype: SVGDescElement; - new(): SVGDescElement; -} - -interface Node extends EventTarget { - nodeType: number; - previousSibling: Node; - localName: string; - namespaceURI: string; - textContent: string; - parentNode: Node; - nextSibling: Node; - nodeValue: string; - lastChild: Node; - childNodes: NodeList; - nodeName: string; - ownerDocument: Document; - attributes: NamedNodeMap; - firstChild: Node; - prefix: string; - removeChild(oldChild: Node): Node; - appendChild(newChild: Node): Node; - isSupported(feature: string, version: string): boolean; - isEqualNode(arg: Node): boolean; - lookupPrefix(namespaceURI: string): string; - isDefaultNamespace(namespaceURI: string): boolean; - compareDocumentPosition(other: Node): number; - normalize(): void; - isSameNode(other: Node): boolean; - hasAttributes(): boolean; - lookupNamespaceURI(prefix: string): string; - cloneNode(deep?: boolean): Node; - hasChildNodes(): boolean; - replaceChild(newChild: Node, oldChild: Node): Node; - insertBefore(newChild: Node, refChild?: Node): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} -declare var Node: { - prototype: Node; - new(): Node; - ENTITY_REFERENCE_NODE: number; - ATTRIBUTE_NODE: number; - DOCUMENT_FRAGMENT_NODE: number; - TEXT_NODE: number; - ELEMENT_NODE: number; - COMMENT_NODE: number; - DOCUMENT_POSITION_DISCONNECTED: number; - DOCUMENT_POSITION_CONTAINED_BY: number; - DOCUMENT_POSITION_CONTAINS: number; - DOCUMENT_TYPE_NODE: number; - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; - DOCUMENT_NODE: number; - ENTITY_NODE: number; - PROCESSING_INSTRUCTION_NODE: number; - CDATA_SECTION_NODE: number; - NOTATION_NODE: number; - DOCUMENT_POSITION_FOLLOWING: number; - DOCUMENT_POSITION_PRECEDING: number; -} - -interface SVGPathSegCurvetoQuadraticSmoothRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothRel: { - prototype: SVGPathSegCurvetoQuadraticSmoothRel; - new(): SVGPathSegCurvetoQuadraticSmoothRel; -} - -interface DOML2DeprecatedListSpaceReduction { - compact: boolean; -} - -interface MSScriptHost { -} -declare var MSScriptHost: { - prototype: MSScriptHost; - new(): MSScriptHost; -} - -interface SVGClipPathElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - clipPathUnits: SVGAnimatedEnumeration; -} -declare var SVGClipPathElement: { - prototype: SVGClipPathElement; - new(): SVGClipPathElement; -} - -interface MouseEvent extends UIEvent { - toElement: Element; - layerY: number; - fromElement: Element; - which: number; - pageX: number; - offsetY: number; - x: number; - y: number; - metaKey: boolean; - altKey: boolean; - ctrlKey: boolean; - offsetX: number; - screenX: number; - clientY: number; - shiftKey: boolean; - layerX: number; - screenY: number; - relatedTarget: EventTarget; - button: number; - pageY: number; - buttons: number; - clientX: number; - initMouseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget): void; - getModifierState(keyArg: string): boolean; -} -declare var MouseEvent: { - prototype: MouseEvent; - new(): MouseEvent; -} - -interface RangeException { - code: number; - message: string; - name: string; - toString(): string; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} -declare var RangeException: { - prototype: RangeException; - new(): RangeException; - INVALID_NODE_TYPE_ERR: number; - BAD_BOUNDARYPOINTS_ERR: number; -} - -interface SVGTextPositioningElement extends SVGTextContentElement { - y: SVGAnimatedLengthList; - rotate: SVGAnimatedNumberList; - dy: SVGAnimatedLengthList; - x: SVGAnimatedLengthList; - dx: SVGAnimatedLengthList; -} -declare var SVGTextPositioningElement: { - prototype: SVGTextPositioningElement; - new(): SVGTextPositioningElement; -} - -interface HTMLAppletElement extends HTMLElement, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { - width: number; - /** - * Sets or retrieves the Internet media type for the code associated with the object. - */ - codeType: string; - object: string; - form: HTMLFormElement; - code: string; - /** - * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. - */ - archive: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves a message to be displayed while an object is loading. - */ - standby: string; - /** - * Sets or retrieves the class identifier for the object. - */ - classid: string; - /** - * Sets or retrieves the shape of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the URL that references the data of the object. - */ - data: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Gets or sets the optional alternative HTML script to execute if the object fails to load. - */ - altHtml: string; - /** - * Address of a pointer to the document this page or frame contains. If there is no document, then null will be returned. - */ - contentDocument: Document; - /** - * Sets or retrieves the URL of the component. - */ - codeBase: string; - /** - * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. - */ - declare: boolean; - /** - * Returns the content type of the object. - */ - type: string; - /** - * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. - */ - BaseHref: string; -} -declare var HTMLAppletElement: { - prototype: HTMLAppletElement; - new(): HTMLAppletElement; -} - -interface TextMetrics { - width: number; -} -declare var TextMetrics: { - prototype: TextMetrics; - new(): TextMetrics; -} - -interface DocumentEvent { - createEvent(eventInterface: "AnimationEvent"): AnimationEvent; - createEvent(eventInterface: "CloseEvent"): CloseEvent; - createEvent(eventInterface: "CompositionEvent"): CompositionEvent; - createEvent(eventInterface: "CustomEvent"): CustomEvent; - createEvent(eventInterface: "DeviceMotionEvent"): DeviceMotionEvent; - createEvent(eventInterface: "DeviceOrientationEvent"): DeviceOrientationEvent; - createEvent(eventInterface: "DragEvent"): DragEvent; - createEvent(eventInterface: "ErrorEvent"): ErrorEvent; - createEvent(eventInterface: "Event"): Event; - createEvent(eventInterface: "Events"): Event; - createEvent(eventInterface: "FocusEvent"): FocusEvent; - createEvent(eventInterface: "HTMLEvents"): Event; - createEvent(eventInterface: "IDBVersionChangeEvent"): IDBVersionChangeEvent; - createEvent(eventInterface: "KeyboardEvent"): KeyboardEvent; - createEvent(eventInterface: "LongRunningScriptDetectedEvent"): LongRunningScriptDetectedEvent; - createEvent(eventInterface: "MessageEvent"): MessageEvent; - createEvent(eventInterface: "MouseEvent"): MouseEvent; - createEvent(eventInterface: "MouseEvents"): MouseEvent; - createEvent(eventInterface: "MouseWheelEvent"): MouseWheelEvent; - createEvent(eventInterface: "MSGestureEvent"): MSGestureEvent; - createEvent(eventInterface: "MSPointerEvent"): MSPointerEvent; - createEvent(eventInterface: "MutationEvent"): MutationEvent; - createEvent(eventInterface: "MutationEvents"): MutationEvent; - createEvent(eventInterface: "NavigationCompletedEvent"): NavigationCompletedEvent; - createEvent(eventInterface: "NavigationEvent"): NavigationEvent; - createEvent(eventInterface: "PageTransitionEvent"): PageTransitionEvent; - createEvent(eventInterface: "PointerEvent"): MSPointerEvent; - createEvent(eventInterface: "PopStateEvent"): PopStateEvent; - createEvent(eventInterface: "ProgressEvent"): ProgressEvent; - createEvent(eventInterface: "StorageEvent"): StorageEvent; - createEvent(eventInterface: "SVGZoomEvents"): SVGZoomEvent; - createEvent(eventInterface: "TextEvent"): TextEvent; - createEvent(eventInterface: "TrackEvent"): TrackEvent; - createEvent(eventInterface: "TransitionEvent"): TransitionEvent; - createEvent(eventInterface: "UIEvent"): UIEvent; - createEvent(eventInterface: "UIEvents"): UIEvent; - createEvent(eventInterface: "UnviewableContentIdentifiedEvent"): UnviewableContentIdentifiedEvent; - createEvent(eventInterface: "WebGLContextEvent"): WebGLContextEvent; - createEvent(eventInterface: "WheelEvent"): WheelEvent; - createEvent(eventInterface: string): Event; -} - -interface HTMLOListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { - /** - * The starting number. - */ - start: number; -} -declare var HTMLOListElement: { - prototype: HTMLOListElement; - new(): HTMLOListElement; -} - -interface SVGPathSegLinetoVerticalRel extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalRel: { - prototype: SVGPathSegLinetoVerticalRel; - new(): SVGPathSegLinetoVerticalRel; -} - -interface SVGAnimatedString { - animVal: string; - baseVal: string; -} -declare var SVGAnimatedString: { - prototype: SVGAnimatedString; - new(): SVGAnimatedString; -} - -interface CDATASection extends Text { -} -declare var CDATASection: { - prototype: CDATASection; - new(): CDATASection; -} - -interface StyleMedia { - type: string; - matchMedium(mediaquery: string): boolean; -} -declare var StyleMedia: { - prototype: StyleMedia; - new(): StyleMedia; -} - -interface HTMLSelectElement extends HTMLElement, MSHTMLCollectionExtensions, MSDataBindingExtensions { - options: HTMLSelectElement; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the number of rows in the list box. - */ - size: number; - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Sets or retrieves the index of the selected option in a select object. - */ - selectedIndex: number; - /** - * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. - */ - multiple: boolean; - /** - * Retrieves the type of select control based on the value of the MULTIPLE attribute. - */ - type: string; - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Removes an element from the collection. - * @param index Number that specifies the zero-based index of the element to remove from the collection. - */ - remove(index?: number): void; - /** - * Adds an element to the areas, controlRange, or options collection. - * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. - * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. - */ - add(element: HTMLElement, before?: any): void; - /** - * Retrieves a select object or an object from an options collection. - * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. - * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. - */ - item(name?: any, index?: any): any; - /** - * Retrieves a select object or an object from an options collection. - * @param namedItem A String that specifies the name or id property of the object to retrieve. A collection is returned if more than one match is made. - */ - namedItem(name: string): any; - [name: string]: any; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} -declare var HTMLSelectElement: { - prototype: HTMLSelectElement; - new(): HTMLSelectElement; -} - -interface TextRange { - boundingLeft: number; - htmlText: string; - offsetLeft: number; - boundingWidth: number; - boundingHeight: number; - boundingTop: number; - text: string; - offsetTop: number; - moveToPoint(x: number, y: number): void; - queryCommandValue(cmdID: string): any; - getBookmark(): string; - move(unit: string, count?: number): number; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(fStart?: boolean): void; - findText(string: string, count?: number, flags?: number): boolean; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - getBoundingClientRect(): ClientRect; - moveToBookmark(bookmark: string): boolean; - isEqual(range: TextRange): boolean; - duplicate(): TextRange; - collapse(start?: boolean): void; - queryCommandText(cmdID: string): string; - select(): void; - pasteHTML(html: string): void; - inRange(range: TextRange): boolean; - moveEnd(unit: string, count?: number): number; - getClientRects(): ClientRectList; - moveStart(unit: string, count?: number): number; - parentElement(): Element; - queryCommandState(cmdID: string): boolean; - compareEndPoints(how: string, sourceRange: TextRange): number; - execCommandShowHelp(cmdID: string): boolean; - moveToElementText(element: Element): void; - expand(Unit: string): boolean; - queryCommandSupported(cmdID: string): boolean; - setEndPoint(how: string, SourceRange: TextRange): void; - queryCommandEnabled(cmdID: string): boolean; -} -declare var TextRange: { - prototype: TextRange; - new(): TextRange; -} - -interface SVGTests { - requiredFeatures: SVGStringList; - requiredExtensions: SVGStringList; - systemLanguage: SVGStringList; - hasExtension(extension: string): boolean; -} - -interface HTMLBlockElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLBlockElement: { - prototype: HTMLBlockElement; - new(): HTMLBlockElement; -} - -interface CSSStyleSheet extends StyleSheet { - owningElement: Element; - imports: StyleSheetList; - isAlternate: boolean; - rules: MSCSSRuleList; - isPrefAlternate: boolean; - readOnly: boolean; - cssText: string; - ownerRule: CSSRule; - href: string; - cssRules: CSSRuleList; - id: string; - pages: StyleSheetPageList; - addImport(bstrURL: string, lIndex?: number): number; - addPageRule(bstrSelector: string, bstrStyle: string, lIndex?: number): number; - insertRule(rule: string, index?: number): number; - removeRule(lIndex: number): void; - deleteRule(index?: number): void; - addRule(bstrSelector: string, bstrStyle?: string, lIndex?: number): number; - removeImport(lIndex: number): void; -} -declare var CSSStyleSheet: { - prototype: CSSStyleSheet; - new(): CSSStyleSheet; -} - -interface MSSelection { - type: string; - typeDetail: string; - createRange(): TextRange; - clear(): void; - createRangeCollection(): TextRangeCollection; - empty(): void; -} -declare var MSSelection: { - prototype: MSSelection; - new(): MSSelection; -} - -interface HTMLMetaElement extends HTMLElement { - /** - * Gets or sets information used to bind the value of a content attribute of a meta element to an HTTP response header. - */ - httpEquiv: string; - /** - * Sets or retrieves the value specified in the content attribute of the meta object. - */ - name: string; - /** - * Gets or sets meta-information to associate with httpEquiv or name. - */ - content: string; - /** - * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. - */ - url: string; - /** - * Sets or retrieves a scheme to be used in interpreting the value of a property specified for the object. - */ - scheme: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; -} -declare var HTMLMetaElement: { - prototype: HTMLMetaElement; - new(): HTMLMetaElement; -} - -interface SVGPatternElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired, SVGURIReference { - patternUnits: SVGAnimatedEnumeration; - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - patternContentUnits: SVGAnimatedEnumeration; - patternTransform: SVGAnimatedTransformList; - height: SVGAnimatedLength; -} -declare var SVGPatternElement: { - prototype: SVGPatternElement; - new(): SVGPatternElement; -} - -interface SVGAnimatedAngle { - animVal: SVGAngle; - baseVal: SVGAngle; -} -declare var SVGAnimatedAngle: { - prototype: SVGAnimatedAngle; - new(): SVGAnimatedAngle; -} - -interface Selection { - isCollapsed: boolean; - anchorNode: Node; - focusNode: Node; - anchorOffset: number; - focusOffset: number; - rangeCount: number; - addRange(range: Range): void; - collapseToEnd(): void; - toString(): string; - selectAllChildren(parentNode: Node): void; - getRangeAt(index: number): Range; - collapse(parentNode: Node, offset: number): void; - removeAllRanges(): void; - collapseToStart(): void; - deleteFromDocument(): void; - removeRange(range: Range): void; -} -declare var Selection: { - prototype: Selection; - new(): Selection; -} - -interface SVGScriptElement extends SVGElement, SVGExternalResourcesRequired, SVGURIReference { - type: string; -} -declare var SVGScriptElement: { - prototype: SVGScriptElement; - new(): SVGScriptElement; -} - -interface HTMLDDElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDDElement: { - prototype: HTMLDDElement; - new(): HTMLDDElement; -} - -interface MSDataBindingRecordSetReadonlyExtensions { - recordset: any; - namedRecordset(dataMember: string, hierarchy?: any): any; -} - -interface CSSStyleRule extends CSSRule { - selectorText: string; - style: MSStyleCSSProperties; - readOnly: boolean; -} -declare var CSSStyleRule: { - prototype: CSSStyleRule; - new(): CSSStyleRule; -} - -interface NodeIterator { - whatToShow: number; - filter: NodeFilter; - root: Node; - expandEntityReferences: boolean; - nextNode(): Node; - detach(): void; - previousNode(): Node; -} -declare var NodeIterator: { - prototype: NodeIterator; - new(): NodeIterator; -} - -interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox, SVGExternalResourcesRequired { - viewTarget: SVGStringList; -} -declare var SVGViewElement: { - prototype: SVGViewElement; - new(): SVGViewElement; -} - -interface HTMLLinkElement extends HTMLElement, LinkStyle { - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rel: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or retrieves the media type. - */ - media: string; - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rev: string; - /** - * Sets or retrieves the MIME type of the object. - */ - type: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the language code of the object. - */ - hreflang: string; -} -declare var HTMLLinkElement: { - prototype: HTMLLinkElement; - new(): HTMLLinkElement; -} - -interface SVGLocatable { - farthestViewportElement: SVGElement; - nearestViewportElement: SVGElement; - getBBox(): SVGRect; - getTransformToElement(element: SVGElement): SVGMatrix; - getCTM(): SVGMatrix; - getScreenCTM(): SVGMatrix; -} - -interface HTMLFontElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { - /** - * Sets or retrieves the current typeface family. - */ - face: string; -} -declare var HTMLFontElement: { - prototype: HTMLFontElement; - new(): HTMLFontElement; -} - -interface SVGTitleElement extends SVGElement, SVGStylable, SVGLangSpace { -} -declare var SVGTitleElement: { - prototype: SVGTitleElement; - new(): SVGTitleElement; -} - -interface ControlRangeCollection { - length: number; - queryCommandValue(cmdID: string): any; - remove(index: number): void; - add(item: Element): void; - queryCommandIndeterm(cmdID: string): boolean; - scrollIntoView(varargStart?: any): void; - item(index: number): Element; - [index: number]: Element; - execCommand(cmdID: string, showUI?: boolean, value?: any): boolean; - addElement(item: Element): void; - queryCommandState(cmdID: string): boolean; - queryCommandSupported(cmdID: string): boolean; - queryCommandEnabled(cmdID: string): boolean; - queryCommandText(cmdID: string): string; - select(): void; -} -declare var ControlRangeCollection: { - prototype: ControlRangeCollection; - new(): ControlRangeCollection; -} - -interface MSNamespaceInfo extends MSEventAttachmentTarget { - urn: string; - onreadystatechange: (ev: Event) => any; - name: string; - readyState: string; - doImport(implementationUrl: string): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MSNamespaceInfo: { - prototype: MSNamespaceInfo; - new(): MSNamespaceInfo; -} - -interface WindowSessionStorage { - sessionStorage: Storage; -} - -interface SVGAnimatedTransformList { - animVal: SVGTransformList; - baseVal: SVGTransformList; -} -declare var SVGAnimatedTransformList: { - prototype: SVGAnimatedTransformList; - new(): SVGAnimatedTransformList; -} - -interface HTMLTableCaptionElement extends HTMLElement { - /** - * Sets or retrieves the alignment of the caption or legend. - */ - align: string; - /** - * Sets or retrieves whether the caption appears at the top or bottom of the table. - */ - vAlign: string; -} -declare var HTMLTableCaptionElement: { - prototype: HTMLTableCaptionElement; - new(): HTMLTableCaptionElement; -} - -interface HTMLOptionElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the ordinal position of an option in a list box. - */ - index: number; - /** - * Sets or retrieves the status of an option. - */ - defaultSelected: boolean; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Sets or retrieves the text string specified by the option tag. - */ - text: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves a value that you can use to implement your own label functionality for the object. - */ - label: string; - /** - * Sets or retrieves whether the option in the list box is the default item. - */ - selected: boolean; -} -declare var HTMLOptionElement: { - prototype: HTMLOptionElement; - new(): HTMLOptionElement; - create(): HTMLOptionElement; -} - -interface HTMLMapElement extends HTMLElement { - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Retrieves a collection of the area objects defined for the given map object. - */ - areas: HTMLAreasCollection; -} -declare var HTMLMapElement: { - prototype: HTMLMapElement; - new(): HTMLMapElement; -} - -interface HTMLMenuElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { - type: string; -} -declare var HTMLMenuElement: { - prototype: HTMLMenuElement; - new(): HTMLMenuElement; -} - -interface MouseWheelEvent extends MouseEvent { - wheelDelta: number; - initMouseWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, wheelDeltaArg: number): void; -} -declare var MouseWheelEvent: { - prototype: MouseWheelEvent; - new(): MouseWheelEvent; -} - -interface SVGFitToViewBox { - viewBox: SVGAnimatedRect; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; -} - -interface SVGPointList { - numberOfItems: number; - replaceItem(newItem: SVGPoint, index: number): SVGPoint; - getItem(index: number): SVGPoint; - clear(): void; - appendItem(newItem: SVGPoint): SVGPoint; - initialize(newItem: SVGPoint): SVGPoint; - removeItem(index: number): SVGPoint; - insertItemBefore(newItem: SVGPoint, index: number): SVGPoint; -} -declare var SVGPointList: { - prototype: SVGPointList; - new(): SVGPointList; -} - -interface SVGAnimatedLengthList { - animVal: SVGLengthList; - baseVal: SVGLengthList; -} -declare var SVGAnimatedLengthList: { - prototype: SVGAnimatedLengthList; - new(): SVGAnimatedLengthList; -} - -interface SVGAnimatedPreserveAspectRatio { - animVal: SVGPreserveAspectRatio; - baseVal: SVGPreserveAspectRatio; -} -declare var SVGAnimatedPreserveAspectRatio: { - prototype: SVGAnimatedPreserveAspectRatio; - new(): SVGAnimatedPreserveAspectRatio; -} - -interface MSSiteModeEvent extends Event { - buttonID: number; - actionURL: string; -} -declare var MSSiteModeEvent: { - prototype: MSSiteModeEvent; - new(): MSSiteModeEvent; -} - -interface DOML2DeprecatedTextFlowControl { - clear: string; -} - -interface StyleSheetPageList { - length: number; - item(index: number): CSSPageRule; - [index: number]: CSSPageRule; -} -declare var StyleSheetPageList: { - prototype: StyleSheetPageList; - new(): StyleSheetPageList; -} - -interface MSCSSProperties extends CSSStyleDeclaration { - scrollbarShadowColor: string; - scrollbarHighlightColor: string; - layoutGridChar: string; - layoutGridType: string; - textAutospace: string; - textKashidaSpace: string; - writingMode: string; - scrollbarFaceColor: string; - backgroundPositionY: string; - lineBreak: string; - imeMode: string; - msBlockProgression: string; - layoutGridLine: string; - scrollbarBaseColor: string; - layoutGrid: string; - layoutFlow: string; - textKashida: string; - filter: string; - zoom: string; - scrollbarArrowColor: string; - behavior: string; - backgroundPositionX: string; - accelerator: string; - layoutGridMode: string; - textJustifyTrim: string; - scrollbar3dLightColor: string; - msInterpolationMode: string; - scrollbarTrackColor: string; - scrollbarDarkShadowColor: string; - styleFloat: string; - getAttribute(attributeName: string, flags?: number): any; - setAttribute(attributeName: string, AttributeValue: any, flags?: number): void; - removeAttribute(attributeName: string, flags?: number): boolean; -} -declare var MSCSSProperties: { - prototype: MSCSSProperties; - new(): MSCSSProperties; -} - -interface SVGExternalResourcesRequired { - externalResourcesRequired: SVGAnimatedBoolean; -} - -interface HTMLImageElement extends HTMLElement, MSImageResourceExtensions, MSDataBindingExtensions, MSResourceMetadata { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * The original height of the image resource before sizing. - */ - naturalHeight: number; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * The original width of the image resource before sizing. - */ - naturalWidth: number; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: number; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - hspace: number; - /** - * Sets or retrieves a Uniform Resource Identifier (URI) to a long description of the object. - */ - longDesc: string; - /** - * Contains the hypertext reference (HREF) of the URL. - */ - href: string; - /** - * Sets or retrieves whether the image is a server-side image map. - */ - isMap: boolean; - /** - * Retrieves whether the object is fully loaded. - */ - complete: boolean; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; - crossOrigin: string; - msPlayToPreferredSourceUri: string; -} -declare var HTMLImageElement: { - prototype: HTMLImageElement; - new(): HTMLImageElement; - create(): HTMLImageElement; -} - -interface HTMLAreaElement extends HTMLElement { - /** - * Sets or retrieves the protocol portion of a URL. - */ - protocol: string; - /** - * Sets or retrieves the substring of the href property that follows the question mark. - */ - search: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the coordinates of the object. - */ - coords: string; - /** - * Sets or retrieves the host name part of the location or URL. - */ - hostname: string; - /** - * Sets or retrieves the port number associated with a URL. - */ - port: string; - /** - * Sets or retrieves the file name or path specified by the object. - */ - pathname: string; - /** - * Sets or retrieves the hostname and port number of the location or URL. - */ - host: string; - /** - * Sets or retrieves the subsection of the href property that follows the number sign (#). - */ - hash: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or gets whether clicks in this region cause action. - */ - noHref: boolean; - /** - * Sets or retrieves the shape of the object. - */ - shape: string; - /** - * Returns a string representation of an object. - */ - toString(): string; -} -declare var HTMLAreaElement: { - prototype: HTMLAreaElement; - new(): HTMLAreaElement; -} - -interface EventTarget { - removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - dispatchEvent(evt: Event): boolean; -} - -interface SVGAngle { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} -declare var SVGAngle: { - prototype: SVGAngle; - new(): SVGAngle; - SVG_ANGLETYPE_RAD: number; - SVG_ANGLETYPE_UNKNOWN: number; - SVG_ANGLETYPE_UNSPECIFIED: number; - SVG_ANGLETYPE_DEG: number; - SVG_ANGLETYPE_GRAD: number; -} - -interface HTMLButtonElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the default or selected value of the control. - */ - value: string; - status: any; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Gets the classification and default behavior of the button. - */ - type: string; - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Overrides the target attribute on a form element. - */ - formTarget: string; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Overrides the action attribute (where the data on a form is sent) on the parent form element. - */ - formAction: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. - */ - formNoValidate: string; - /** - * Used to override the encoding (formEnctype attribute) specified on the form element. - */ - formEnctype: string; - /** - * Overrides the submit method attribute previously specified on a form element. - */ - formMethod: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} -declare var HTMLButtonElement: { - prototype: HTMLButtonElement; - new(): HTMLButtonElement; -} - -interface HTMLSourceElement extends HTMLElement { - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Gets or sets the intended media type of the media source. - */ - media: string; - /** - * Gets or sets the MIME type of a media resource. - */ - type: string; - msKeySystem: string; -} -declare var HTMLSourceElement: { - prototype: HTMLSourceElement; - new(): HTMLSourceElement; -} - -interface CanvasGradient { - addColorStop(offset: number, color: string): void; -} -declare var CanvasGradient: { - prototype: CanvasGradient; - new(): CanvasGradient; -} - -interface KeyboardEvent extends UIEvent { - location: number; - keyCode: number; - shiftKey: boolean; - which: number; - locale: string; - key: string; - altKey: boolean; - metaKey: boolean; - char: string; - ctrlKey: boolean; - repeat: boolean; - charCode: number; - getModifierState(keyArg: string): boolean; - initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} -declare var KeyboardEvent: { - prototype: KeyboardEvent; - new(): KeyboardEvent; - DOM_KEY_LOCATION_RIGHT: number; - DOM_KEY_LOCATION_STANDARD: number; - DOM_KEY_LOCATION_LEFT: number; - DOM_KEY_LOCATION_NUMPAD: number; - DOM_KEY_LOCATION_JOYSTICK: number; - DOM_KEY_LOCATION_MOBILE: number; -} - -interface MessageEvent extends Event { - source: Window; - origin: string; - data: any; - ports: any; - initMessageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, dataArg: any, originArg: string, lastEventIdArg: string, sourceArg: Window): void; -} -declare var MessageEvent: { - prototype: MessageEvent; - new(): MessageEvent; -} - -interface SVGElement extends Element { - onmouseover: (ev: MouseEvent) => any; - viewportElement: SVGElement; - onmousemove: (ev: MouseEvent) => any; - onmouseout: (ev: MouseEvent) => any; - ondblclick: (ev: MouseEvent) => any; - onfocusout: (ev: FocusEvent) => any; - onfocusin: (ev: FocusEvent) => any; - xmlbase: string; - onmousedown: (ev: MouseEvent) => any; - onload: (ev: Event) => any; - onmouseup: (ev: MouseEvent) => any; - onclick: (ev: MouseEvent) => any; - ownerSVGElement: SVGSVGElement; - id: string; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var SVGElement: { - prototype: SVGElement; - new(): SVGElement; -} - -interface HTMLScriptElement extends HTMLElement { - /** - * Sets or retrieves the status of the script. - */ - defer: boolean; - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; - /** - * Retrieves the URL to an external file that contains the source code or data. - */ - src: string; - /** - * Sets or retrieves the object that is bound to the event script. - */ - htmlFor: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the MIME type for the associated scripting engine. - */ - type: string; - /** - * Sets or retrieves the event for which the script is written. - */ - event: string; - async: boolean; -} -declare var HTMLScriptElement: { - prototype: HTMLScriptElement; - new(): HTMLScriptElement; -} - -interface HTMLTableRowElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { - /** - * Retrieves the position of the object in the rows collection for the table. - */ - rowIndex: number; - /** - * Retrieves a collection of all cells in the table row. - */ - cells: HTMLCollection; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Retrieves the position of the object in the collection. - */ - sectionRowIndex: number; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; - /** - * Removes the specified cell from the table row, as well as from the cells collection. - * @param index Number that specifies the zero-based position of the cell to remove from the table row. If no value is provided, the last cell in the cells collection is deleted. - */ - deleteCell(index?: number): void; - /** - * Creates a new cell in the table row, and adds the cell to the cells collection. - * @param index Number that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection. - */ - insertCell(index?: number): HTMLElement; -} -declare var HTMLTableRowElement: { - prototype: HTMLTableRowElement; - new(): HTMLTableRowElement; -} - -interface CanvasRenderingContext2D { - miterLimit: number; - font: string; - globalCompositeOperation: string; - msFillRule: string; - lineCap: string; - msImageSmoothingEnabled: boolean; - lineDashOffset: number; - shadowColor: string; - lineJoin: string; - shadowOffsetX: number; - lineWidth: number; - canvas: HTMLCanvasElement; - strokeStyle: any; - globalAlpha: number; - shadowOffsetY: number; - fillStyle: any; - shadowBlur: number; - textAlign: string; - textBaseline: string; - restore(): void; - setTransform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - save(): void; - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - measureText(text: string): TextMetrics; - isPointInPath(x: number, y: number, fillRule?: string): boolean; - quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; - putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; - rotate(angle: number): void; - fillText(text: string, x: number, y: number, maxWidth?: number): void; - translate(x: number, y: number): void; - scale(x: number, y: number): void; - createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - lineTo(x: number, y: number): void; - getLineDash(): number[]; - fill(fillRule?: string): void; - createImageData(imageDataOrSw: any, sh?: number): ImageData; - createPattern(image: HTMLElement, repetition: string): CanvasPattern; - closePath(): void; - rect(x: number, y: number, w: number, h: number): void; - clip(fillRule?: string): void; - clearRect(x: number, y: number, w: number, h: number): void; - moveTo(x: number, y: number): void; - getImageData(sx: number, sy: number, sw: number, sh: number): ImageData; - fillRect(x: number, y: number, w: number, h: number): void; - bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; - drawImage(image: HTMLElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - transform(m11: number, m12: number, m21: number, m22: number, dx: number, dy: number): void; - stroke(): void; - strokeRect(x: number, y: number, w: number, h: number): void; - setLineDash(segments: number[]): void; - strokeText(text: string, x: number, y: number, maxWidth?: number): void; - beginPath(): void; - arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; - createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; -} -declare var CanvasRenderingContext2D: { - prototype: CanvasRenderingContext2D; - new(): CanvasRenderingContext2D; -} - -interface MSCSSRuleList { - length: number; - item(index?: number): CSSStyleRule; - [index: number]: CSSStyleRule; -} -declare var MSCSSRuleList: { - prototype: MSCSSRuleList; - new(): MSCSSRuleList; -} - -interface SVGPathSegLinetoHorizontalAbs extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalAbs: { - prototype: SVGPathSegLinetoHorizontalAbs; - new(): SVGPathSegLinetoHorizontalAbs; -} - -interface SVGPathSegArcAbs extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcAbs: { - prototype: SVGPathSegArcAbs; - new(): SVGPathSegArcAbs; -} - -interface SVGTransformList { - numberOfItems: number; - getItem(index: number): SVGTransform; - consolidate(): SVGTransform; - clear(): void; - appendItem(newItem: SVGTransform): SVGTransform; - initialize(newItem: SVGTransform): SVGTransform; - removeItem(index: number): SVGTransform; - insertItemBefore(newItem: SVGTransform, index: number): SVGTransform; - replaceItem(newItem: SVGTransform, index: number): SVGTransform; - createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; -} -declare var SVGTransformList: { - prototype: SVGTransformList; - new(): SVGTransformList; -} - -interface HTMLHtmlElement extends HTMLElement { - /** - * Sets or retrieves the DTD version that governs the current document. - */ - version: string; -} -declare var HTMLHtmlElement: { - prototype: HTMLHtmlElement; - new(): HTMLHtmlElement; -} - -interface SVGPathSegClosePath extends SVGPathSeg { -} -declare var SVGPathSegClosePath: { - prototype: SVGPathSegClosePath; - new(): SVGPathSegClosePath; -} - -interface HTMLFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: any; - /** - * Sets or retrieves whether the frame can be scrolled. - */ - scrolling: string; - /** - * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. - */ - marginHeight: string; - /** - * Sets or retrieves the left and right margin widths before displaying the text in a frame. - */ - marginWidth: string; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - /** - * Sets or retrieves whether the user can resize the frame. - */ - noResize: boolean; - /** - * Retrieves the object of the specified. - */ - contentWindow: Window; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the frame name. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Sets or retrieves a URI to a long description of the object. - */ - longDesc: string; - /** - * Raised when the object has been completely received from the server. - */ - onload: (ev: Event) => any; - /** - * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. - */ - security: any; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLFrameElement: { - prototype: HTMLFrameElement; - new(): HTMLFrameElement; -} - -interface SVGAnimatedLength { - animVal: SVGLength; - baseVal: SVGLength; -} -declare var SVGAnimatedLength: { - prototype: SVGAnimatedLength; - new(): SVGAnimatedLength; -} - -interface SVGAnimatedPoints { - points: SVGPointList; - animatedPoints: SVGPointList; -} - -interface SVGDefsElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGDefsElement: { - prototype: SVGDefsElement; - new(): SVGDefsElement; -} - -interface HTMLQuoteElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLQuoteElement: { - prototype: HTMLQuoteElement; - new(): HTMLQuoteElement; -} - -interface CSSMediaRule extends CSSRule { - media: MediaList; - cssRules: CSSRuleList; - insertRule(rule: string, index?: number): number; - deleteRule(index?: number): void; -} -declare var CSSMediaRule: { - prototype: CSSMediaRule; - new(): CSSMediaRule; -} - -interface WindowModal { - dialogArguments: any; - returnValue: any; -} - -interface XMLHttpRequest extends EventTarget { - responseBody: any; - status: number; - readyState: number; - responseText: string; - responseXML: any; - ontimeout: (ev: Event) => any; - statusText: string; - onreadystatechange: (ev: Event) => any; - timeout: number; - onload: (ev: Event) => any; - response: any; - withCredentials: boolean; - onprogress: (ev: ProgressEvent) => any; - onabort: (ev: UIEvent) => any; - responseType: string; - onloadend: (ev: ProgressEvent) => any; - upload: XMLHttpRequestEventTarget; - onerror: (ev: ErrorEvent) => any; - onloadstart: (ev: Event) => any; - msCaching: string; - open(method: string, url: string, async?: boolean, user?: string, password?: string): void; - send(data?: any): void; - abort(): void; - getAllResponseHeaders(): string; - setRequestHeader(header: string, value: string): void; - getResponseHeader(header: string): string; - msCachingEnabled(): boolean; - overrideMimeType(mime: string): void; - LOADING: number; - DONE: number; - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; - addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var XMLHttpRequest: { - prototype: XMLHttpRequest; - new(): XMLHttpRequest; - LOADING: number; - DONE: number; - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; - create(): XMLHttpRequest; -} - -interface HTMLTableHeaderCellElement extends HTMLTableCellElement { - /** - * Sets or retrieves the group of cells in a table to which the object's information applies. - */ - scope: string; -} -declare var HTMLTableHeaderCellElement: { - prototype: HTMLTableHeaderCellElement; - new(): HTMLTableHeaderCellElement; -} - -interface HTMLDListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction { -} -declare var HTMLDListElement: { - prototype: HTMLDListElement; - new(): HTMLDListElement; -} - -interface MSDataBindingExtensions { - dataSrc: string; - dataFormatAs: string; - dataFld: string; -} - -interface SVGPathSegLinetoHorizontalRel extends SVGPathSeg { - x: number; -} -declare var SVGPathSegLinetoHorizontalRel: { - prototype: SVGPathSegLinetoHorizontalRel; - new(): SVGPathSegLinetoHorizontalRel; -} - -interface SVGEllipseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - ry: SVGAnimatedLength; - cx: SVGAnimatedLength; - rx: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGEllipseElement: { - prototype: SVGEllipseElement; - new(): SVGEllipseElement; -} - -interface SVGAElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - target: SVGAnimatedString; -} -declare var SVGAElement: { - prototype: SVGAElement; - new(): SVGAElement; -} - -interface SVGStylable { - className: SVGAnimatedString; - style: CSSStyleDeclaration; -} - -interface SVGTransformable extends SVGLocatable { - transform: SVGAnimatedTransformList; -} - -interface HTMLFrameSetElement extends HTMLElement { - ononline: (ev: Event) => any; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves the frame heights of the object. - */ - rows: string; - /** - * Sets or retrieves the frame widths of the object. - */ - cols: string; - /** - * Fires when the object loses the input focus. - */ - onblur: (ev: FocusEvent) => any; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Fires when the object receives focus. - */ - onfocus: (ev: FocusEvent) => any; - onmessage: (ev: MessageEvent) => any; - onerror: (ev: ErrorEvent) => any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - onresize: (ev: UIEvent) => any; - name: string; - onafterprint: (ev: Event) => any; - onbeforeprint: (ev: Event) => any; - onoffline: (ev: Event) => any; - border: string; - onunload: (ev: Event) => any; - onhashchange: (ev: Event) => any; - onload: (ev: Event) => any; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - onstorage: (ev: StorageEvent) => any; - onpageshow: (ev: PageTransitionEvent) => any; - onpagehide: (ev: PageTransitionEvent) => any; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLFrameSetElement: { - prototype: HTMLFrameSetElement; - new(): HTMLFrameSetElement; -} - -interface Screen extends EventTarget { - width: number; - deviceXDPI: number; - fontSmoothingEnabled: boolean; - bufferDepth: number; - logicalXDPI: number; - systemXDPI: number; - availHeight: number; - height: number; - logicalYDPI: number; - systemYDPI: number; - updateInterval: number; - colorDepth: number; - availWidth: number; - deviceYDPI: number; - pixelDepth: number; - msOrientation: string; - onmsorientationchange: (ev: any) => any; - msLockOrientation(orientation: string): boolean; - msLockOrientation(orientations: string[]): boolean; - msUnlockOrientation(): void; - addEventListener(type: "msorientationchange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var Screen: { - prototype: Screen; - new(): Screen; -} - -interface Coordinates { - altitudeAccuracy: number; - longitude: number; - latitude: number; - speed: number; - heading: number; - altitude: number; - accuracy: number; -} -declare var Coordinates: { - prototype: Coordinates; - new(): Coordinates; -} - -interface NavigatorGeolocation { - geolocation: Geolocation; -} - -interface NavigatorContentUtils { -} - -interface EventListener { - (evt: Event): void; -} - -interface SVGLangSpace { - xmllang: string; - xmlspace: string; -} - -interface DataTransfer { - effectAllowed: string; - dropEffect: string; - types: DOMStringList; - files: FileList; - clearData(format?: string): boolean; - setData(format: string, data: string): boolean; - getData(format: string): string; -} -declare var DataTransfer: { - prototype: DataTransfer; - new(): DataTransfer; -} - -interface FocusEvent extends UIEvent { - relatedTarget: EventTarget; - initFocusEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, relatedTargetArg: EventTarget): void; -} -declare var FocusEvent: { - prototype: FocusEvent; - new(): FocusEvent; -} - -interface Range { - startOffset: number; - collapsed: boolean; - endOffset: number; - startContainer: Node; - endContainer: Node; - commonAncestorContainer: Node; - setStart(refNode: Node, offset: number): void; - setEndBefore(refNode: Node): void; - setStartBefore(refNode: Node): void; - selectNode(refNode: Node): void; - detach(): void; - getBoundingClientRect(): ClientRect; - toString(): string; - compareBoundaryPoints(how: number, sourceRange: Range): number; - insertNode(newNode: Node): void; - collapse(toStart: boolean): void; - selectNodeContents(refNode: Node): void; - cloneContents(): DocumentFragment; - setEnd(refNode: Node, offset: number): void; - cloneRange(): Range; - getClientRects(): ClientRectList; - surroundContents(newParent: Node): void; - deleteContents(): void; - setStartAfter(refNode: Node): void; - extractContents(): DocumentFragment; - setEndAfter(refNode: Node): void; - createContextualFragment(fragment: string): DocumentFragment; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} -declare var Range: { - prototype: Range; - new(): Range; - END_TO_END: number; - START_TO_START: number; - START_TO_END: number; - END_TO_START: number; -} - -interface SVGPoint { - y: number; - x: number; - matrixTransform(matrix: SVGMatrix): SVGPoint; -} -declare var SVGPoint: { - prototype: SVGPoint; - new(): SVGPoint; -} - -interface MSPluginsCollection { - length: number; - refresh(reload?: boolean): void; -} -declare var MSPluginsCollection: { - prototype: MSPluginsCollection; - new(): MSPluginsCollection; -} - -interface SVGAnimatedNumberList { - animVal: SVGNumberList; - baseVal: SVGNumberList; -} -declare var SVGAnimatedNumberList: { - prototype: SVGAnimatedNumberList; - new(): SVGAnimatedNumberList; -} - -interface SVGSVGElement extends SVGElement, SVGStylable, SVGZoomAndPan, DocumentEvent, SVGLangSpace, SVGLocatable, SVGTests, SVGFitToViewBox, SVGExternalResourcesRequired { - width: SVGAnimatedLength; - x: SVGAnimatedLength; - contentStyleType: string; - onzoom: (ev: any) => any; - y: SVGAnimatedLength; - viewport: SVGRect; - onerror: (ev: ErrorEvent) => any; - pixelUnitToMillimeterY: number; - onresize: (ev: UIEvent) => any; - screenPixelToMillimeterY: number; - height: SVGAnimatedLength; - onabort: (ev: UIEvent) => any; - contentScriptType: string; - pixelUnitToMillimeterX: number; - currentTranslate: SVGPoint; - onunload: (ev: Event) => any; - currentScale: number; - onscroll: (ev: UIEvent) => any; - screenPixelToMillimeterX: number; - setCurrentTime(seconds: number): void; - createSVGLength(): SVGLength; - getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeList; - unpauseAnimations(): void; - createSVGRect(): SVGRect; - checkIntersection(element: SVGElement, rect: SVGRect): boolean; - unsuspendRedrawAll(): void; - pauseAnimations(): void; - suspendRedraw(maxWaitMilliseconds: number): number; - deselectAll(): void; - createSVGAngle(): SVGAngle; - getEnclosureList(rect: SVGRect, referenceElement: SVGElement): NodeList; - createSVGTransform(): SVGTransform; - unsuspendRedraw(suspendHandleID: number): void; - forceRedraw(): void; - getCurrentTime(): number; - checkEnclosure(element: SVGElement, rect: SVGRect): boolean; - createSVGMatrix(): SVGMatrix; - createSVGPoint(): SVGPoint; - createSVGNumber(): SVGNumber; - createSVGTransformFromMatrix(matrix: SVGMatrix): SVGTransform; - getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; - getElementById(elementId: string): Element; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "zoom", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var SVGSVGElement: { - prototype: SVGSVGElement; - new(): SVGSVGElement; -} - -interface HTMLLabelElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the object to which the given label object is assigned. - */ - htmlFor: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLLabelElement: { - prototype: HTMLLabelElement; - new(): HTMLLabelElement; -} - -interface MSResourceMetadata { - protocol: string; - fileSize: string; - fileUpdatedDate: string; - nameProp: string; - fileCreatedDate: string; - fileModifiedDate: string; - mimeType: string; -} - -interface HTMLLegendElement extends HTMLElement, MSDataBindingExtensions { - /** - * Retrieves a reference to the form that the object is embedded in. - */ - align: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLLegendElement: { - prototype: HTMLLegendElement; - new(): HTMLLegendElement; -} - -interface HTMLDirectoryElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { -} -declare var HTMLDirectoryElement: { - prototype: HTMLDirectoryElement; - new(): HTMLDirectoryElement; -} - -interface SVGAnimatedInteger { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedInteger: { - prototype: SVGAnimatedInteger; - new(): SVGAnimatedInteger; -} - -interface SVGTextElement extends SVGTextPositioningElement, SVGTransformable { -} -declare var SVGTextElement: { - prototype: SVGTextElement; - new(): SVGTextElement; -} - -interface SVGTSpanElement extends SVGTextPositioningElement { -} -declare var SVGTSpanElement: { - prototype: SVGTSpanElement; - new(): SVGTSpanElement; -} - -interface HTMLLIElement extends HTMLElement, DOML2DeprecatedListNumberingAndBulletStyle { - /** - * Sets or retrieves the value of a list item. - */ - value: number; -} -declare var HTMLLIElement: { - prototype: HTMLLIElement; - new(): HTMLLIElement; -} - -interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg { - y: number; -} -declare var SVGPathSegLinetoVerticalAbs: { - prototype: SVGPathSegLinetoVerticalAbs; - new(): SVGPathSegLinetoVerticalAbs; -} - -interface MSStorageExtensions { - remainingSpace: number; -} - -interface SVGStyleElement extends SVGElement, SVGLangSpace { - media: string; - type: string; - title: string; -} -declare var SVGStyleElement: { - prototype: SVGStyleElement; - new(): SVGStyleElement; -} - -interface MSCurrentStyleCSSProperties extends MSCSSProperties { - blockDirection: string; - clipBottom: string; - clipLeft: string; - clipRight: string; - clipTop: string; - hasLayout: string; -} -declare var MSCurrentStyleCSSProperties: { - prototype: MSCurrentStyleCSSProperties; - new(): MSCurrentStyleCSSProperties; -} - -interface MSHTMLCollectionExtensions { - urns(urn: any): any; - tags(tagName: any): any; -} - -interface Storage extends MSStorageExtensions { - length: number; - getItem(key: string): any; - [key: string]: any; - setItem(key: string, data: string): void; - clear(): void; - removeItem(key: string): void; - key(index: number): string; - [index: number]: string; -} -declare var Storage: { - prototype: Storage; - new(): Storage; -} - -interface HTMLIFrameElement extends HTMLElement, GetSVGDocument, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves whether the frame can be scrolled. - */ - scrolling: string; - /** - * Sets or retrieves the top and bottom margin heights before displaying the text in a frame. - */ - marginHeight: string; - /** - * Sets or retrieves the left and right margin widths before displaying the text in a frame. - */ - marginWidth: string; - /** - * Sets or retrieves the amount of additional space between the frames. - */ - frameSpacing: any; - /** - * Sets or retrieves whether to display a border for the frame. - */ - frameBorder: string; - /** - * Sets or retrieves whether the user can resize the frame. - */ - noResize: boolean; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * Retrieves the object of the specified. - */ - contentWindow: Window; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the frame name. - */ - name: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Specifies the properties of a border drawn around an object. - */ - border: string; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Sets or retrieves the horizontal margin for the object. - */ - hspace: number; - /** - * Sets or retrieves a URI to a long description of the object. - */ - longDesc: string; - /** - * Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied. - */ - security: any; - /** - * Raised when the object has been completely received from the server. - */ - onload: (ev: Event) => any; - sandbox: DOMSettableTokenList; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLIFrameElement: { - prototype: HTMLIFrameElement; - new(): HTMLIFrameElement; -} - -interface TextRangeCollection { - length: number; - item(index: number): TextRange; - [index: number]: TextRange; -} -declare var TextRangeCollection: { - prototype: TextRangeCollection; - new(): TextRangeCollection; -} - -interface HTMLBodyElement extends HTMLElement, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - scroll: string; - ononline: (ev: Event) => any; - onblur: (ev: FocusEvent) => any; - noWrap: boolean; - onfocus: (ev: FocusEvent) => any; - onmessage: (ev: MessageEvent) => any; - text: any; - onerror: (ev: ErrorEvent) => any; - bgProperties: string; - onresize: (ev: UIEvent) => any; - link: any; - aLink: any; - bottomMargin: any; - topMargin: any; - onafterprint: (ev: Event) => any; - vLink: any; - onbeforeprint: (ev: Event) => any; - onoffline: (ev: Event) => any; - onunload: (ev: Event) => any; - onhashchange: (ev: Event) => any; - onload: (ev: Event) => any; - rightMargin: any; - onbeforeunload: (ev: BeforeUnloadEvent) => any; - leftMargin: any; - onstorage: (ev: StorageEvent) => any; - onpopstate: (ev: PopStateEvent) => any; - onpageshow: (ev: PageTransitionEvent) => any; - onpagehide: (ev: PageTransitionEvent) => any; - createTextRange(): TextRange; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; - addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLBodyElement: { - prototype: HTMLBodyElement; - new(): HTMLBodyElement; -} - -interface DocumentType extends Node { - name: string; - notations: NamedNodeMap; - systemId: string; - internalSubset: string; - entities: NamedNodeMap; - publicId: string; -} -declare var DocumentType: { - prototype: DocumentType; - new(): DocumentType; -} - -interface SVGRadialGradientElement extends SVGGradientElement { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; - fx: SVGAnimatedLength; - fy: SVGAnimatedLength; -} -declare var SVGRadialGradientElement: { - prototype: SVGRadialGradientElement; - new(): SVGRadialGradientElement; -} - -interface MutationEvent extends Event { - newValue: string; - attrChange: number; - attrName: string; - prevValue: string; - relatedNode: Node; - initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} -declare var MutationEvent: { - prototype: MutationEvent; - new(): MutationEvent; - MODIFICATION: number; - REMOVAL: number; - ADDITION: number; -} - -interface DragEvent extends MouseEvent { - dataTransfer: DataTransfer; - initDragEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, dataTransferArg: DataTransfer): void; - msConvertURL(file: File, targetType: string, targetURL?: string): void; -} -declare var DragEvent: { - prototype: DragEvent; - new(): DragEvent; -} - -interface HTMLTableSectionElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: HTMLCollection; - /** - * Removes the specified row (tr) from the element and from the rows collection. - * @param index Number that specifies the zero-based position in the rows collection of the row to remove. - */ - deleteRow(index?: number): void; - /** - * Moves a table row to a new position. - * @param indexFrom Number that specifies the index in the rows collection of the table row that is moved. - * @param indexTo Number that specifies where the row is moved within the rows collection. - */ - moveRow(indexFrom?: number, indexTo?: number): any; - /** - * Creates a new row (tr) in the table, and adds the row to the rows collection. - * @param index Number that specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. - */ - insertRow(index?: number): HTMLElement; -} -declare var HTMLTableSectionElement: { - prototype: HTMLTableSectionElement; - new(): HTMLTableSectionElement; -} - -interface DOML2DeprecatedListNumberingAndBulletStyle { - type: string; -} - -interface HTMLInputElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - status: boolean; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Gets or sets the starting position or offset of a text selection. - */ - selectionStart: number; - indeterminate: boolean; - readOnly: boolean; - size: number; - loop: number; - /** - * Gets or sets the end position or offset of a text selection. - */ - selectionEnd: number; - /** - * Sets or retrieves the URL of the virtual reality modeling language (VRML) world to be displayed in the window. - */ - vrml: string; - /** - * Sets or retrieves a lower resolution image to display. - */ - lowsrc: string; - /** - * Sets or retrieves the vertical margin for the object. - */ - vspace: number; - /** - * Sets or retrieves a comma-separated list of content types. - */ - accept: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the state of the check box or radio button. - */ - defaultChecked: boolean; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Returns the value of the data at the cursor's current position. - */ - value: string; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - border: string; - dynsrc: string; - /** - * Sets or retrieves the state of the check box or radio button. - */ - checked: boolean; - /** - * Sets or retrieves the width of the border to draw around the object. - */ - hspace: number; - /** - * Sets or retrieves the maximum number of characters that the user can enter in a text control. - */ - maxLength: number; - /** - * Returns the content type of the object. - */ - type: string; - /** - * Sets or retrieves the initial contents of the object. - */ - defaultValue: string; - /** - * Retrieves whether the object is fully loaded. - */ - complete: boolean; - start: string; - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a FileList object on a file type input object. - */ - files: FileList; - /** - * Defines the maximum acceptable value for an input element with type="number".When used with the min and step attributes, lets you control the range and increment (such as only even numbers) that the user can enter into an input field. - */ - max: string; - /** - * Overrides the target attribute on a form element. - */ - formTarget: string; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Defines an increment or jump between values that you want to allow the user to enter. When used with the max and min attributes, lets you control the range and increment (for example, allow only even numbers) that the user can enter into an input field. - */ - step: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Used to override the encoding (formEnctype attribute) specified on the form element. - */ - formEnctype: string; - /** - * Returns the input field value as a number. - */ - valueAsNumber: number; - /** - * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. - */ - placeholder: string; - /** - * Overrides the submit method attribute previously specified on a form element. - */ - formMethod: string; - /** - * Specifies the ID of a pre-defined datalist of options for an input element. - */ - list: HTMLElement; - /** - * Specifies whether autocomplete is applied to an editable text field. - */ - autocomplete: string; - /** - * Defines the minimum acceptable value for an input element with type="number". When used with the max and step attributes, lets you control the range and increment (such as even numbers only) that the user can enter into an input field. - */ - min: string; - /** - * Overrides the action attribute (where the data on a form is sent) on the parent form element. - */ - formAction: string; - /** - * Gets or sets a string containing a regular expression that the user's input must match. - */ - pattern: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Overrides any validation or required attributes on a form or form elements to allow it to be submitted without validation. This can be used to create a "save draft"-type submit option. - */ - formNoValidate: string; - /** - * Sets or retrieves the Boolean value indicating whether multiple items can be selected from a list. - */ - multiple: boolean; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; - /** - * Sets the start and end positions of a selection in a text field. - * @param start The offset into the text field for the start of the selection. - * @param end The offset into the text field for the end of the selection. - */ - setSelectionRange(start: number, end: number): void; - /** - * Makes the selection equal to the current object. - */ - select(): void; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Decrements a range input control's value by the value given by the Step attribute. If the optional parameter is used, it will decrement the input control's step value multiplied by the parameter's value. - * @param n Value to decrement the value by. - */ - stepDown(n?: number): void; - /** - * Increments a range input control's value by the value given by the Step attribute. If the optional parameter is used, will increment the input control's value by that value. - * @param n Value to increment the value by. - */ - stepUp(n?: number): void; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} -declare var HTMLInputElement: { - prototype: HTMLInputElement; - new(): HTMLInputElement; -} - -interface HTMLAnchorElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rel: string; - /** - * Contains the protocol of the URL. - */ - protocol: string; - /** - * Sets or retrieves the substring of the href property that follows the question mark. - */ - search: string; - /** - * Sets or retrieves the coordinates of the object. - */ - coords: string; - /** - * Contains the hostname of a URL. - */ - hostname: string; - /** - * Contains the pathname of the URL. - */ - pathname: string; - Methods: string; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - protocolLong: string; - /** - * Sets or retrieves a destination URL or an anchor point. - */ - href: string; - /** - * Sets or retrieves the shape of the object. - */ - name: string; - /** - * Sets or retrieves the character set used to encode the object. - */ - charset: string; - /** - * Sets or retrieves the language code of the object. - */ - hreflang: string; - /** - * Sets or retrieves the port number associated with a URL. - */ - port: string; - /** - * Contains the hostname and port values of the URL. - */ - host: string; - /** - * Contains the anchor portion of the URL including the hash sign (#). - */ - hash: string; - nameProp: string; - urn: string; - /** - * Sets or retrieves the relationship between the object and the destination of the link. - */ - rev: string; - /** - * Sets or retrieves the shape of the object. - */ - shape: string; - type: string; - mimeType: string; - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; - /** - * Returns a string representation of an object. - */ - toString(): string; -} -declare var HTMLAnchorElement: { - prototype: HTMLAnchorElement; - new(): HTMLAnchorElement; -} - -interface HTMLParamElement extends HTMLElement { - /** - * Sets or retrieves the value of an input parameter for an element. - */ - value: string; - /** - * Sets or retrieves the name of an input parameter for an element. - */ - name: string; - /** - * Sets or retrieves the content type of the resource designated by the value attribute. - */ - type: string; - /** - * Sets or retrieves the data type of the value attribute. - */ - valueType: string; -} -declare var HTMLParamElement: { - prototype: HTMLParamElement; - new(): HTMLParamElement; -} - -interface SVGImageElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGImageElement: { - prototype: SVGImageElement; - new(): SVGImageElement; -} - -interface SVGAnimatedNumber { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedNumber: { - prototype: SVGAnimatedNumber; - new(): SVGAnimatedNumber; -} - -interface PerformanceTiming { - redirectStart: number; - domainLookupEnd: number; - responseStart: number; - domComplete: number; - domainLookupStart: number; - loadEventStart: number; - msFirstPaint: number; - unloadEventEnd: number; - fetchStart: number; - requestStart: number; - domInteractive: number; - navigationStart: number; - connectEnd: number; - loadEventEnd: number; - connectStart: number; - responseEnd: number; - domLoading: number; - redirectEnd: number; - unloadEventStart: number; - domContentLoadedEventStart: number; - domContentLoadedEventEnd: number; - toJSON(): any; -} -declare var PerformanceTiming: { - prototype: PerformanceTiming; - new(): PerformanceTiming; -} - -interface HTMLPreElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or gets a value that you can use to implement your own width functionality for the object. - */ - width: number; - /** - * Indicates a citation by rendering text in italic type. - */ - cite: string; -} -declare var HTMLPreElement: { - prototype: HTMLPreElement; - new(): HTMLPreElement; -} - -interface EventException { - code: number; - message: string; - name: string; - toString(): string; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} -declare var EventException: { - prototype: EventException; - new(): EventException; - DISPATCH_REQUEST_ERR: number; - UNSPECIFIED_EVENT_TYPE_ERR: number; -} - -interface MSNavigatorDoNotTrack { - msDoNotTrack: string; - removeSiteSpecificTrackingException(args: ExceptionInformation): void; - removeWebWideTrackingException(args: ExceptionInformation): void; - storeWebWideTrackingException(args: StoreExceptionsInformation): void; - storeSiteSpecificTrackingException(args: StoreSiteSpecificExceptionsInformation): void; - confirmSiteSpecificTrackingException(args: ConfirmSiteSpecificExceptionsInformation): boolean; - confirmWebWideTrackingException(args: ExceptionInformation): boolean; -} - -interface NavigatorOnLine { - onLine: boolean; -} - -interface WindowLocalStorage { - localStorage: Storage; -} - -interface SVGMetadataElement extends SVGElement { -} -declare var SVGMetadataElement: { - prototype: SVGMetadataElement; - new(): SVGMetadataElement; -} - -interface SVGPathSegArcRel extends SVGPathSeg { - y: number; - sweepFlag: boolean; - r2: number; - x: number; - angle: number; - r1: number; - largeArcFlag: boolean; -} -declare var SVGPathSegArcRel: { - prototype: SVGPathSegArcRel; - new(): SVGPathSegArcRel; -} - -interface SVGPathSegMovetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegMovetoAbs: { - prototype: SVGPathSegMovetoAbs; - new(): SVGPathSegMovetoAbs; -} - -interface SVGStringList { - numberOfItems: number; - replaceItem(newItem: string, index: number): string; - getItem(index: number): string; - clear(): void; - appendItem(newItem: string): string; - initialize(newItem: string): string; - removeItem(index: number): string; - insertItemBefore(newItem: string, index: number): string; -} -declare var SVGStringList: { - prototype: SVGStringList; - new(): SVGStringList; -} - -interface XDomainRequest { - timeout: number; - onerror: (ev: ErrorEvent) => any; - onload: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - ontimeout: (ev: Event) => any; - responseText: string; - contentType: string; - open(method: string, url: string): void; - abort(): void; - send(data?: any): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var XDomainRequest: { - prototype: XDomainRequest; - new(): XDomainRequest; - create(): XDomainRequest; -} - -interface DOML2DeprecatedBackgroundColorStyle { - bgColor: any; -} - -interface ElementTraversal { - childElementCount: number; - previousElementSibling: Element; - lastElementChild: Element; - nextElementSibling: Element; - firstElementChild: Element; -} - -interface SVGLength { - valueAsString: string; - valueInSpecifiedUnits: number; - value: number; - unitType: number; - newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; - convertToSpecifiedUnits(unitType: number): void; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} -declare var SVGLength: { - prototype: SVGLength; - new(): SVGLength; - SVG_LENGTHTYPE_NUMBER: number; - SVG_LENGTHTYPE_CM: number; - SVG_LENGTHTYPE_PC: number; - SVG_LENGTHTYPE_PERCENTAGE: number; - SVG_LENGTHTYPE_MM: number; - SVG_LENGTHTYPE_PT: number; - SVG_LENGTHTYPE_IN: number; - SVG_LENGTHTYPE_EMS: number; - SVG_LENGTHTYPE_PX: number; - SVG_LENGTHTYPE_UNKNOWN: number; - SVG_LENGTHTYPE_EXS: number; -} - -interface SVGPolygonElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGPolygonElement: { - prototype: SVGPolygonElement; - new(): SVGPolygonElement; -} - -interface HTMLPhraseElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLPhraseElement: { - prototype: HTMLPhraseElement; - new(): HTMLPhraseElement; -} - -interface NavigatorStorageUtils { -} - -interface SVGPathSegCurvetoCubicRel extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicRel: { - prototype: SVGPathSegCurvetoCubicRel; - new(): SVGPathSegCurvetoCubicRel; -} - -interface SVGTextContentElement extends SVGElement, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - textLength: SVGAnimatedLength; - lengthAdjust: SVGAnimatedEnumeration; - getCharNumAtPosition(point: SVGPoint): number; - getStartPositionOfChar(charnum: number): SVGPoint; - getExtentOfChar(charnum: number): SVGRect; - getComputedTextLength(): number; - getSubStringLength(charnum: number, nchars: number): number; - selectSubString(charnum: number, nchars: number): void; - getNumberOfChars(): number; - getRotationOfChar(charnum: number): number; - getEndPositionOfChar(charnum: number): SVGPoint; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} -declare var SVGTextContentElement: { - prototype: SVGTextContentElement; - new(): SVGTextContentElement; - LENGTHADJUST_SPACING: number; - LENGTHADJUST_SPACINGANDGLYPHS: number; - LENGTHADJUST_UNKNOWN: number; -} - -interface DOML2DeprecatedColorProperty { - color: string; -} - -interface Location { - hash: string; - protocol: string; - search: string; - href: string; - hostname: string; - port: string; - pathname: string; - host: string; - reload(flag?: boolean): void; - replace(url: string): void; - assign(url: string): void; - toString(): string; -} -declare var Location: { - prototype: Location; - new(): Location; -} - -interface HTMLTitleElement extends HTMLElement { - /** - * Retrieves or sets the text of the object as a string. - */ - text: string; -} -declare var HTMLTitleElement: { - prototype: HTMLTitleElement; - new(): HTMLTitleElement; -} - -interface HTMLStyleElement extends HTMLElement, LinkStyle { - /** - * Sets or retrieves the media type. - */ - media: string; - /** - * Retrieves the CSS language in which the style sheet is written. - */ - type: string; -} -declare var HTMLStyleElement: { - prototype: HTMLStyleElement; - new(): HTMLStyleElement; -} - -interface PerformanceEntry { - name: string; - startTime: number; - duration: number; - entryType: string; -} -declare var PerformanceEntry: { - prototype: PerformanceEntry; - new(): PerformanceEntry; -} - -interface SVGTransform { - type: number; - angle: number; - matrix: SVGMatrix; - setTranslate(tx: number, ty: number): void; - setScale(sx: number, sy: number): void; - setMatrix(matrix: SVGMatrix): void; - setSkewY(angle: number): void; - setRotate(angle: number, cx: number, cy: number): void; - setSkewX(angle: number): void; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} -declare var SVGTransform: { - prototype: SVGTransform; - new(): SVGTransform; - SVG_TRANSFORM_SKEWX: number; - SVG_TRANSFORM_UNKNOWN: number; - SVG_TRANSFORM_SCALE: number; - SVG_TRANSFORM_TRANSLATE: number; - SVG_TRANSFORM_MATRIX: number; - SVG_TRANSFORM_ROTATE: number; - SVG_TRANSFORM_SKEWY: number; -} - -interface UIEvent extends Event { - detail: number; - view: Window; - initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; -} -declare var UIEvent: { - prototype: UIEvent; - new(): UIEvent; -} - -interface SVGURIReference { - href: SVGAnimatedString; -} - -interface SVGPathSeg { - pathSegType: number; - pathSegTypeAsLetter: string; - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} -declare var SVGPathSeg: { - prototype: SVGPathSeg; - new(): SVGPathSeg; - PATHSEG_MOVETO_REL: number; - PATHSEG_LINETO_VERTICAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; - PATHSEG_CURVETO_QUADRATIC_REL: number; - PATHSEG_CURVETO_CUBIC_ABS: number; - PATHSEG_LINETO_HORIZONTAL_ABS: number; - PATHSEG_CURVETO_QUADRATIC_ABS: number; - PATHSEG_LINETO_ABS: number; - PATHSEG_CLOSEPATH: number; - PATHSEG_LINETO_HORIZONTAL_REL: number; - PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; - PATHSEG_LINETO_REL: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; - PATHSEG_ARC_REL: number; - PATHSEG_CURVETO_CUBIC_REL: number; - PATHSEG_UNKNOWN: number; - PATHSEG_LINETO_VERTICAL_ABS: number; - PATHSEG_ARC_ABS: number; - PATHSEG_MOVETO_ABS: number; - PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; -} - -interface WheelEvent extends MouseEvent { - deltaZ: number; - deltaX: number; - deltaMode: number; - deltaY: number; - initWheelEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, buttonArg: number, relatedTargetArg: EventTarget, modifiersListArg: string, deltaXArg: number, deltaYArg: number, deltaZArg: number, deltaMode: number): void; - getCurrentPoint(element: Element): void; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} -declare var WheelEvent: { - prototype: WheelEvent; - new(): WheelEvent; - DOM_DELTA_PIXEL: number; - DOM_DELTA_LINE: number; - DOM_DELTA_PAGE: number; -} - -interface MSEventAttachmentTarget { - attachEvent(event: string, listener: EventListener): boolean; - detachEvent(event: string, listener: EventListener): void; -} - -interface SVGNumber { - value: number; -} -declare var SVGNumber: { - prototype: SVGNumber; - new(): SVGNumber; -} - -interface SVGPathElement extends SVGElement, SVGStylable, SVGAnimatedPathData, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - getPathSegAtLength(distance: number): number; - getPointAtLength(distance: number): SVGPoint; - createSVGPathSegCurvetoQuadraticAbs(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticAbs; - createSVGPathSegLinetoRel(x: number, y: number): SVGPathSegLinetoRel; - createSVGPathSegCurvetoQuadraticRel(x: number, y: number, x1: number, y1: number): SVGPathSegCurvetoQuadraticRel; - createSVGPathSegCurvetoCubicAbs(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicAbs; - createSVGPathSegLinetoAbs(x: number, y: number): SVGPathSegLinetoAbs; - createSVGPathSegClosePath(): SVGPathSegClosePath; - createSVGPathSegCurvetoCubicRel(x: number, y: number, x1: number, y1: number, x2: number, y2: number): SVGPathSegCurvetoCubicRel; - createSVGPathSegCurvetoQuadraticSmoothRel(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothRel; - createSVGPathSegMovetoRel(x: number, y: number): SVGPathSegMovetoRel; - createSVGPathSegCurvetoCubicSmoothAbs(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothAbs; - createSVGPathSegMovetoAbs(x: number, y: number): SVGPathSegMovetoAbs; - createSVGPathSegLinetoVerticalRel(y: number): SVGPathSegLinetoVerticalRel; - createSVGPathSegArcRel(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcRel; - createSVGPathSegCurvetoQuadraticSmoothAbs(x: number, y: number): SVGPathSegCurvetoQuadraticSmoothAbs; - createSVGPathSegLinetoHorizontalRel(x: number): SVGPathSegLinetoHorizontalRel; - getTotalLength(): number; - createSVGPathSegCurvetoCubicSmoothRel(x: number, y: number, x2: number, y2: number): SVGPathSegCurvetoCubicSmoothRel; - createSVGPathSegLinetoHorizontalAbs(x: number): SVGPathSegLinetoHorizontalAbs; - createSVGPathSegLinetoVerticalAbs(y: number): SVGPathSegLinetoVerticalAbs; - createSVGPathSegArcAbs(x: number, y: number, r1: number, r2: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean): SVGPathSegArcAbs; -} -declare var SVGPathElement: { - prototype: SVGPathElement; - new(): SVGPathElement; -} - -interface MSCompatibleInfo { - version: string; - userAgent: string; -} -declare var MSCompatibleInfo: { - prototype: MSCompatibleInfo; - new(): MSCompatibleInfo; -} - -interface Text extends CharacterData, MSNodeExtensions { - wholeText: string; - splitText(offset: number): Text; - replaceWholeText(content: string): Text; -} -declare var Text: { - prototype: Text; - new(): Text; -} - -interface SVGAnimatedRect { - animVal: SVGRect; - baseVal: SVGRect; -} -declare var SVGAnimatedRect: { - prototype: SVGAnimatedRect; - new(): SVGAnimatedRect; -} - -interface CSSNamespaceRule extends CSSRule { - namespaceURI: string; - prefix: string; -} -declare var CSSNamespaceRule: { - prototype: CSSNamespaceRule; - new(): CSSNamespaceRule; -} - -interface SVGPathSegList { - numberOfItems: number; - replaceItem(newItem: SVGPathSeg, index: number): SVGPathSeg; - getItem(index: number): SVGPathSeg; - clear(): void; - appendItem(newItem: SVGPathSeg): SVGPathSeg; - initialize(newItem: SVGPathSeg): SVGPathSeg; - removeItem(index: number): SVGPathSeg; - insertItemBefore(newItem: SVGPathSeg, index: number): SVGPathSeg; -} -declare var SVGPathSegList: { - prototype: SVGPathSegList; - new(): SVGPathSegList; -} - -interface HTMLUnknownElement extends HTMLElement, MSDataBindingRecordSetReadonlyExtensions { -} -declare var HTMLUnknownElement: { - prototype: HTMLUnknownElement; - new(): HTMLUnknownElement; -} - -interface HTMLAudioElement extends HTMLMediaElement { -} -declare var HTMLAudioElement: { - prototype: HTMLAudioElement; - new(): HTMLAudioElement; -} - -interface MSImageResourceExtensions { - dynsrc: string; - vrml: string; - lowsrc: string; - start: string; - loop: number; -} - -interface PositionError { - code: number; - message: string; - toString(): string; - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} -declare var PositionError: { - prototype: PositionError; - new(): PositionError; - POSITION_UNAVAILABLE: number; - PERMISSION_DENIED: number; - TIMEOUT: number; -} - -interface HTMLTableCellElement extends HTMLElement, HTMLTableAlignment, DOML2DeprecatedBackgroundStyle, DOML2DeprecatedBackgroundColorStyle { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves a list of header cells that provide information for the object. - */ - headers: string; - /** - * Retrieves the position of the object in the cells collection of a row. - */ - cellIndex: number; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorLight: any; - /** - * Sets or retrieves the number columns in the table that the object should span. - */ - colSpan: number; - /** - * Sets or retrieves the border color of the object. - */ - borderColor: any; - /** - * Sets or retrieves a comma-delimited list of conceptual categories associated with the object. - */ - axis: string; - /** - * Sets or retrieves the height of the object. - */ - height: any; - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; - /** - * Sets or retrieves abbreviated text for the object. - */ - abbr: string; - /** - * Sets or retrieves how many rows in a table the cell should span. - */ - rowSpan: number; - /** - * Sets or retrieves the group of cells in a table to which the object's information applies. - */ - scope: string; - /** - * Sets or retrieves the color for one of the two colors used to draw the 3-D border of the object. - */ - borderColorDark: any; -} -declare var HTMLTableCellElement: { - prototype: HTMLTableCellElement; - new(): HTMLTableCellElement; -} - -interface SVGElementInstance extends EventTarget { - previousSibling: SVGElementInstance; - parentNode: SVGElementInstance; - lastChild: SVGElementInstance; - nextSibling: SVGElementInstance; - childNodes: SVGElementInstanceList; - correspondingUseElement: SVGUseElement; - correspondingElement: SVGElement; - firstChild: SVGElementInstance; -} -declare var SVGElementInstance: { - prototype: SVGElementInstance; - new(): SVGElementInstance; -} - -interface MSNamespaceInfoCollection { - length: number; - add(namespace?: string, urn?: string, implementationUrl?: any): any; - item(index: any): any; - // [index: any]: any; -} -declare var MSNamespaceInfoCollection: { - prototype: MSNamespaceInfoCollection; - new(): MSNamespaceInfoCollection; -} - -interface SVGCircleElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - cx: SVGAnimatedLength; - r: SVGAnimatedLength; - cy: SVGAnimatedLength; -} -declare var SVGCircleElement: { - prototype: SVGCircleElement; - new(): SVGCircleElement; -} - -interface StyleSheetList { - length: number; - item(index?: number): StyleSheet; - [index: number]: StyleSheet; -} -declare var StyleSheetList: { - prototype: StyleSheetList; - new(): StyleSheetList; -} - -interface CSSImportRule extends CSSRule { - styleSheet: CSSStyleSheet; - href: string; - media: MediaList; -} -declare var CSSImportRule: { - prototype: CSSImportRule; - new(): CSSImportRule; -} - -interface CustomEvent extends Event { - detail: any; - initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void; -} -declare var CustomEvent: { - prototype: CustomEvent; - new(): CustomEvent; -} - -interface HTMLBaseFontElement extends HTMLElement, DOML2DeprecatedColorProperty { - /** - * Sets or retrieves the current typeface family. - */ - face: string; - /** - * Sets or retrieves the font size of the object. - */ - size: number; -} -declare var HTMLBaseFontElement: { - prototype: HTMLBaseFontElement; - new(): HTMLBaseFontElement; -} - -interface HTMLTextAreaElement extends HTMLElement, MSDataBindingExtensions { - /** - * Retrieves or sets the text in the entry field of the textArea element. - */ - value: string; - /** - * Sets or retrieves the value indicating whether the control is selected. - */ - status: any; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Gets or sets the starting position or offset of a text selection. - */ - selectionStart: number; - /** - * Sets or retrieves the number of horizontal rows contained in the object. - */ - rows: number; - /** - * Sets or retrieves the width of the object. - */ - cols: number; - /** - * Sets or retrieves the value indicated whether the content of the object is read-only. - */ - readOnly: boolean; - /** - * Sets or retrieves how to handle wordwrapping in the object. - */ - wrap: string; - /** - * Gets or sets the end position or offset of a text selection. - */ - selectionEnd: number; - /** - * Retrieves the type of control. - */ - type: string; - /** - * Sets or retrieves the initial contents of the object. - */ - defaultValue: string; - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing. - */ - autofocus: boolean; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * When present, marks an element that can't be submitted without a value. - */ - required: boolean; - /** - * Sets or retrieves the maximum number of characters that the user can enter in a text control. - */ - maxLength: number; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Gets or sets a text string that is displayed in an input field as a hint or prompt to users as the format or type of information they need to enter.The text appears in an input field until the user puts focus on the field. - */ - placeholder: string; - /** - * Creates a TextRange object for the element. - */ - createTextRange(): TextRange; - /** - * Sets the start and end positions of a selection in a text field. - * @param start The offset into the text field for the start of the selection. - * @param end The offset into the text field for the end of the selection. - */ - setSelectionRange(start: number, end: number): void; - /** - * Highlights the input area of a form element. - */ - select(): void; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} -declare var HTMLTextAreaElement: { - prototype: HTMLTextAreaElement; - new(): HTMLTextAreaElement; -} - -interface Geolocation { - clearWatch(watchId: number): void; - getCurrentPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): void; - watchPosition(successCallback: PositionCallback, errorCallback?: PositionErrorCallback, options?: PositionOptions): number; -} -declare var Geolocation: { - prototype: Geolocation; - new(): Geolocation; -} - -interface DOML2DeprecatedMarginStyle { - vspace: number; - hspace: number; -} - -interface MSWindowModeless { - dialogTop: any; - dialogLeft: any; - dialogWidth: any; - dialogHeight: any; - menuArguments: any; -} - -interface DOML2DeprecatedAlignmentStyle { - align: string; -} - -interface HTMLMarqueeElement extends HTMLElement, MSDataBindingExtensions, DOML2DeprecatedBackgroundColorStyle { - width: string; - onbounce: (ev: Event) => any; - vspace: number; - trueSpeed: boolean; - scrollAmount: number; - scrollDelay: number; - behavior: string; - height: string; - loop: number; - direction: string; - hspace: number; - onstart: (ev: Event) => any; - onfinish: (ev: Event) => any; - stop(): void; - start(): void; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "bounce", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "start", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "finish", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLMarqueeElement: { - prototype: HTMLMarqueeElement; - new(): HTMLMarqueeElement; -} - -interface SVGRect { - y: number; - width: number; - x: number; - height: number; -} -declare var SVGRect: { - prototype: SVGRect; - new(): SVGRect; -} - -interface MSNodeExtensions { - swapNode(otherNode: Node): Node; - removeNode(deep?: boolean): Node; - replaceNode(replacement: Node): Node; -} - -interface History { - length: number; - state: any; - back(distance?: any): void; - forward(distance?: any): void; - go(delta?: any): void; - replaceState(statedata: any, title: string, url?: string): void; - pushState(statedata: any, title: string, url?: string): void; -} -declare var History: { - prototype: History; - new(): History; -} - -interface SVGPathSegCurvetoCubicAbs extends SVGPathSeg { - y: number; - y1: number; - x2: number; - x: number; - x1: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicAbs: { - prototype: SVGPathSegCurvetoCubicAbs; - new(): SVGPathSegCurvetoCubicAbs; -} - -interface SVGPathSegCurvetoQuadraticAbs extends SVGPathSeg { - y: number; - y1: number; - x: number; - x1: number; -} -declare var SVGPathSegCurvetoQuadraticAbs: { - prototype: SVGPathSegCurvetoQuadraticAbs; - new(): SVGPathSegCurvetoQuadraticAbs; -} - -interface TimeRanges { - length: number; - start(index: number): number; - end(index: number): number; -} -declare var TimeRanges: { - prototype: TimeRanges; - new(): TimeRanges; -} - -interface CSSRule { - cssText: string; - parentStyleSheet: CSSStyleSheet; - parentRule: CSSRule; - type: number; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; - KEYFRAMES_RULE: number; - KEYFRAME_RULE: number; - VIEWPORT_RULE: number; -} -declare var CSSRule: { - prototype: CSSRule; - new(): CSSRule; - IMPORT_RULE: number; - MEDIA_RULE: number; - STYLE_RULE: number; - NAMESPACE_RULE: number; - PAGE_RULE: number; - UNKNOWN_RULE: number; - FONT_FACE_RULE: number; - CHARSET_RULE: number; - KEYFRAMES_RULE: number; - KEYFRAME_RULE: number; - VIEWPORT_RULE: number; -} - -interface SVGPathSegLinetoAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoAbs: { - prototype: SVGPathSegLinetoAbs; - new(): SVGPathSegLinetoAbs; -} - -interface HTMLModElement extends HTMLElement { - /** - * Sets or retrieves the date and time of a modification to the object. - */ - dateTime: string; - /** - * Sets or retrieves reference information about the object. - */ - cite: string; -} -declare var HTMLModElement: { - prototype: HTMLModElement; - new(): HTMLModElement; -} - -interface SVGMatrix { - e: number; - c: number; - a: number; - b: number; - d: number; - f: number; - multiply(secondMatrix: SVGMatrix): SVGMatrix; - flipY(): SVGMatrix; - skewY(angle: number): SVGMatrix; - inverse(): SVGMatrix; - scaleNonUniform(scaleFactorX: number, scaleFactorY: number): SVGMatrix; - rotate(angle: number): SVGMatrix; - flipX(): SVGMatrix; - translate(x: number, y: number): SVGMatrix; - scale(scaleFactor: number): SVGMatrix; - rotateFromVector(x: number, y: number): SVGMatrix; - skewX(angle: number): SVGMatrix; -} -declare var SVGMatrix: { - prototype: SVGMatrix; - new(): SVGMatrix; -} - -interface MSPopupWindow { - document: Document; - isOpen: boolean; - show(x: number, y: number, w: number, h: number, element?: any): void; - hide(): void; -} -declare var MSPopupWindow: { - prototype: MSPopupWindow; - new(): MSPopupWindow; -} - -interface BeforeUnloadEvent extends Event { - returnValue: string; -} -declare var BeforeUnloadEvent: { - prototype: BeforeUnloadEvent; - new(): BeforeUnloadEvent; -} - -interface SVGUseElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired, SVGURIReference { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - animatedInstanceRoot: SVGElementInstance; - instanceRoot: SVGElementInstance; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGUseElement: { - prototype: SVGUseElement; - new(): SVGUseElement; -} - -interface Event { - timeStamp: number; - defaultPrevented: boolean; - isTrusted: boolean; - currentTarget: EventTarget; - cancelBubble: boolean; - target: EventTarget; - eventPhase: number; - cancelable: boolean; - type: string; - srcElement: Element; - bubbles: boolean; - initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; - stopPropagation(): void; - stopImmediatePropagation(): void; - preventDefault(): void; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} -declare var Event: { - prototype: Event; - new(): Event; - CAPTURING_PHASE: number; - AT_TARGET: number; - BUBBLING_PHASE: number; -} - -interface ImageData { - width: number; - data: number[]; - height: number; -} -declare var ImageData: { - prototype: ImageData; - new(): ImageData; -} - -interface HTMLTableColElement extends HTMLElement, HTMLTableAlignment { - /** - * Sets or retrieves the width of the object. - */ - width: any; - /** - * Sets or retrieves the alignment of the object relative to the display or table. - */ - align: string; - /** - * Sets or retrieves the number of columns in the group. - */ - span: number; -} -declare var HTMLTableColElement: { - prototype: HTMLTableColElement; - new(): HTMLTableColElement; -} - -interface SVGException { - code: number; - message: string; - name: string; - toString(): string; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} -declare var SVGException: { - prototype: SVGException; - new(): SVGException; - SVG_MATRIX_NOT_INVERTABLE: number; - SVG_WRONG_TYPE_ERR: number; - SVG_INVALID_VALUE_ERR: number; -} - -interface SVGLinearGradientElement extends SVGGradientElement { - y1: SVGAnimatedLength; - x2: SVGAnimatedLength; - x1: SVGAnimatedLength; - y2: SVGAnimatedLength; -} -declare var SVGLinearGradientElement: { - prototype: SVGLinearGradientElement; - new(): SVGLinearGradientElement; -} - -interface HTMLTableAlignment { - /** - * Sets or retrieves a value that you can use to implement your own ch functionality for the object. - */ - ch: string; - /** - * Sets or retrieves how text and other content are vertically aligned within the object that contains them. - */ - vAlign: string; - /** - * Sets or retrieves a value that you can use to implement your own chOff functionality for the object. - */ - chOff: string; -} - -interface SVGAnimatedEnumeration { - animVal: number; - baseVal: number; -} -declare var SVGAnimatedEnumeration: { - prototype: SVGAnimatedEnumeration; - new(): SVGAnimatedEnumeration; -} - -interface DOML2DeprecatedSizeProperty { - size: number; -} - -interface HTMLUListElement extends HTMLElement, DOML2DeprecatedListSpaceReduction, DOML2DeprecatedListNumberingAndBulletStyle { -} -declare var HTMLUListElement: { - prototype: HTMLUListElement; - new(): HTMLUListElement; -} - -interface SVGRectElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - ry: SVGAnimatedLength; - rx: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGRectElement: { - prototype: SVGRectElement; - new(): SVGRectElement; -} - -interface ErrorEventHandler { - (event: Event, source: string, fileno: number, columnNumber: number): void; -} - -interface HTMLDivElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDivElement: { - prototype: HTMLDivElement; - new(): HTMLDivElement; -} - -interface DOML2DeprecatedBorderStyle { - border: string; -} - -interface NamedNodeMap { - length: number; - removeNamedItemNS(namespaceURI: string, localName: string): Attr; - item(index: number): Attr; - [index: number]: Attr; - removeNamedItem(name: string): Attr; - getNamedItem(name: string): Attr; - // [name: string]: Attr; - setNamedItem(arg: Attr): Attr; - getNamedItemNS(namespaceURI: string, localName: string): Attr; - setNamedItemNS(arg: Attr): Attr; -} -declare var NamedNodeMap: { - prototype: NamedNodeMap; - new(): NamedNodeMap; -} - -interface MediaList { - length: number; - mediaText: string; - deleteMedium(oldMedium: string): void; - appendMedium(newMedium: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} -declare var MediaList: { - prototype: MediaList; - new(): MediaList; -} - -interface SVGPathSegCurvetoQuadraticSmoothAbs extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegCurvetoQuadraticSmoothAbs: { - prototype: SVGPathSegCurvetoQuadraticSmoothAbs; - new(): SVGPathSegCurvetoQuadraticSmoothAbs; -} - -interface SVGPathSegCurvetoCubicSmoothRel extends SVGPathSeg { - y: number; - x2: number; - x: number; - y2: number; -} -declare var SVGPathSegCurvetoCubicSmoothRel: { - prototype: SVGPathSegCurvetoCubicSmoothRel; - new(): SVGPathSegCurvetoCubicSmoothRel; -} - -interface SVGLengthList { - numberOfItems: number; - replaceItem(newItem: SVGLength, index: number): SVGLength; - getItem(index: number): SVGLength; - clear(): void; - appendItem(newItem: SVGLength): SVGLength; - initialize(newItem: SVGLength): SVGLength; - removeItem(index: number): SVGLength; - insertItemBefore(newItem: SVGLength, index: number): SVGLength; -} -declare var SVGLengthList: { - prototype: SVGLengthList; - new(): SVGLengthList; -} - -interface ProcessingInstruction extends Node { - target: string; - data: string; -} -declare var ProcessingInstruction: { - prototype: ProcessingInstruction; - new(): ProcessingInstruction; -} - -interface MSWindowExtensions { - status: string; - onmouseleave: (ev: MouseEvent) => any; - screenLeft: number; - offscreenBuffering: any; - maxConnectionsPerServer: number; - onmouseenter: (ev: MouseEvent) => any; - clipboardData: DataTransfer; - defaultStatus: string; - clientInformation: Navigator; - closed: boolean; - onhelp: (ev: Event) => any; - external: External; - event: MSEventObj; - onfocusout: (ev: FocusEvent) => any; - screenTop: number; - onfocusin: (ev: FocusEvent) => any; - showModelessDialog(url?: string, argument?: any, options?: any): Window; - navigate(url: string): void; - resizeBy(x?: number, y?: number): void; - item(index: any): any; - resizeTo(x?: number, y?: number): void; - createPopup(arguments?: any): MSPopupWindow; - toStaticHTML(html: string): string; - execScript(code: string, language?: string): any; - msWriteProfilerMark(profilerMarkName: string): void; - moveTo(x?: number, y?: number): void; - moveBy(x?: number, y?: number): void; - showHelp(url: string, helpArg?: any, features?: string): void; - captureEvents(): void; - releaseEvents(): void; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface MSBehaviorUrnsCollection { - length: number; - item(index: number): string; -} -declare var MSBehaviorUrnsCollection: { - prototype: MSBehaviorUrnsCollection; - new(): MSBehaviorUrnsCollection; -} - -interface CSSFontFaceRule extends CSSRule { - style: CSSStyleDeclaration; -} -declare var CSSFontFaceRule: { - prototype: CSSFontFaceRule; - new(): CSSFontFaceRule; -} - -interface DOML2DeprecatedBackgroundStyle { - background: string; -} - -interface TextEvent extends UIEvent { - inputMethod: number; - data: string; - locale: string; - initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} -declare var TextEvent: { - prototype: TextEvent; - new(): TextEvent; - DOM_INPUT_METHOD_KEYBOARD: number; - DOM_INPUT_METHOD_DROP: number; - DOM_INPUT_METHOD_IME: number; - DOM_INPUT_METHOD_SCRIPT: number; - DOM_INPUT_METHOD_VOICE: number; - DOM_INPUT_METHOD_UNKNOWN: number; - DOM_INPUT_METHOD_PASTE: number; - DOM_INPUT_METHOD_HANDWRITING: number; - DOM_INPUT_METHOD_OPTION: number; - DOM_INPUT_METHOD_MULTIMODAL: number; -} - -interface DocumentFragment extends Node, NodeSelector, MSEventAttachmentTarget, MSNodeExtensions { -} -declare var DocumentFragment: { - prototype: DocumentFragment; - new(): DocumentFragment; -} - -interface SVGPolylineElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGAnimatedPoints, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGPolylineElement: { - prototype: SVGPolylineElement; - new(): SVGPolylineElement; -} - -interface SVGAnimatedPathData { - pathSegList: SVGPathSegList; -} - -interface Position { - timestamp: Date; - coords: Coordinates; -} -declare var Position: { - prototype: Position; - new(): Position; -} - -interface BookmarkCollection { - length: number; - item(index: number): any; - [index: number]: any; -} -declare var BookmarkCollection: { - prototype: BookmarkCollection; - new(): BookmarkCollection; -} - -interface PerformanceMark extends PerformanceEntry { -} -declare var PerformanceMark: { - prototype: PerformanceMark; - new(): PerformanceMark; -} - -interface CSSPageRule extends CSSRule { - pseudoClass: string; - selectorText: string; - selector: string; - style: CSSStyleDeclaration; -} -declare var CSSPageRule: { - prototype: CSSPageRule; - new(): CSSPageRule; -} - -interface HTMLBRElement extends HTMLElement { - /** - * Sets or retrieves the side on which floating objects are not to be positioned when any IHTMLBlockElement is inserted into the document. - */ - clear: string; -} -declare var HTMLBRElement: { - prototype: HTMLBRElement; - new(): HTMLBRElement; -} - -interface MSNavigatorExtensions { - userLanguage: string; - plugins: MSPluginsCollection; - cookieEnabled: boolean; - appCodeName: string; - cpuClass: string; - appMinorVersion: string; - connectionSpeed: number; - browserLanguage: string; - mimeTypes: MSMimeTypesCollection; - systemLanguage: string; - language: string; - javaEnabled(): boolean; - taintEnabled(): boolean; -} - -interface HTMLSpanElement extends HTMLElement, MSDataBindingExtensions { -} -declare var HTMLSpanElement: { - prototype: HTMLSpanElement; - new(): HTMLSpanElement; -} - -interface HTMLHeadElement extends HTMLElement { - profile: string; -} -declare var HTMLHeadElement: { - prototype: HTMLHeadElement; - new(): HTMLHeadElement; -} - -interface HTMLHeadingElement extends HTMLElement, DOML2DeprecatedTextFlowControl { - /** - * Sets or retrieves a value that indicates the table alignment. - */ - align: string; -} -declare var HTMLHeadingElement: { - prototype: HTMLHeadingElement; - new(): HTMLHeadingElement; -} - -interface HTMLFormElement extends HTMLElement, MSHTMLCollectionExtensions { - /** - * Sets or retrieves the number of objects in a collection. - */ - length: number; - /** - * Sets or retrieves the window or frame at which to target content. - */ - target: string; - /** - * Sets or retrieves a list of character encodings for input data that must be accepted by the server processing the form. - */ - acceptCharset: string; - /** - * Sets or retrieves the encoding type for the form. - */ - enctype: string; - /** - * Retrieves a collection, in source order, of all controls in a given form. - */ - elements: HTMLCollection; - /** - * Sets or retrieves the URL to which the form content is sent for processing. - */ - action: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves how to send the form data to the server. - */ - method: string; - /** - * Sets or retrieves the MIME encoding for the form. - */ - encoding: string; - /** - * Specifies whether autocomplete is applied to an editable text field. - */ - autocomplete: string; - /** - * Designates a form that is not validated when submitted. - */ - noValidate: boolean; - /** - * Fires when the user resets a form. - */ - reset(): void; - /** - * Retrieves a form object or an object from an elements collection. - * @param name Variant of type Number or String that specifies the object or collection to retrieve. If this parameter is a Number, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made. - * @param index Variant of type Number that specifies the zero-based index of the object to retrieve when a collection is returned. - */ - item(name?: any, index?: any): any; - /** - * Fires when a FORM is about to be submitted. - */ - submit(): void; - /** - * Retrieves a form object or an object from an elements collection. - */ - namedItem(name: string): any; - [name: string]: any; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; -} -declare var HTMLFormElement: { - prototype: HTMLFormElement; - new(): HTMLFormElement; -} - -interface SVGZoomAndPan { - zoomAndPan: number; - SVG_ZOOMANDPAN_MAGNIFY: number; - SVG_ZOOMANDPAN_UNKNOWN: number; - SVG_ZOOMANDPAN_DISABLE: number; -} -declare var SVGZoomAndPan: SVGZoomAndPan; - -interface HTMLMediaElement extends HTMLElement { - /** - * Gets the earliest possible position, in seconds, that the playback can begin. - */ - initialTime: number; - /** - * Gets TimeRanges for the current media resource that has been played. - */ - played: TimeRanges; - /** - * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. - */ - currentSrc: string; - readyState: any; - /** - * The autobuffer element is not supported by Internet Explorer 9. Use the preload element instead. - */ - autobuffer: boolean; - /** - * Gets or sets a flag to specify whether playback should restart after it completes. - */ - loop: boolean; - /** - * Gets information about whether the playback has ended or not. - */ - ended: boolean; - /** - * Gets a collection of buffered time ranges. - */ - buffered: TimeRanges; - /** - * Returns an object representing the current error state of the audio or video element. - */ - error: MediaError; - /** - * Returns a TimeRanges object that represents the ranges of the current media resource that can be seeked. - */ - seekable: TimeRanges; - /** - * Gets or sets a value that indicates whether to start playing the media automatically. - */ - autoplay: boolean; - /** - * Gets or sets a flag that indicates whether the client provides a set of controls for the media (in case the developer does not include controls for the player). - */ - controls: boolean; - /** - * Gets or sets the volume level for audio portions of the media element. - */ - volume: number; - /** - * The address or URL of the a media resource that is to be considered. - */ - src: string; - /** - * Gets or sets the current rate of speed for the media resource to play. This speed is expressed as a multiple of the normal speed of the media resource. - */ - playbackRate: number; - /** - * Returns the duration in seconds of the current media resource. A NaN value is returned if duration is not available, or Infinity if the media resource is streaming. - */ - duration: number; - /** - * Gets or sets a flag that indicates whether the audio (either audio or the audio track on video media) is muted. - */ - muted: boolean; - /** - * Gets or sets the default playback rate when the user is not using fast forward or reverse for a video or audio resource. - */ - defaultPlaybackRate: number; - /** - * Gets a flag that specifies whether playback is paused. - */ - paused: boolean; - /** - * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. - */ - seeking: boolean; - /** - * Gets or sets the current playback position, in seconds. - */ - currentTime: number; - /** - * Gets or sets the current playback position, in seconds. - */ - preload: string; - /** - * Gets the current network activity for the element. - */ - networkState: number; - /** - * Specifies the purpose of the audio or video media, such as background audio or alerts. - */ - msAudioCategory: string; - /** - * Specifies whether or not to enable low-latency playback on the media element. - */ - msRealTime: boolean; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - textTracks: TextTrackList; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - /** - * Returns an AudioTrackList object with the audio tracks for a given video element. - */ - audioTracks: AudioTrackList; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; - /** - * Specifies the output device id that the audio will be sent to. - */ - msAudioDeviceType: string; - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - onmsneedkey: (ev: MSMediaKeyNeededEvent) => any; - /** - * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. - */ - msKeys: MSMediaKeys; - msGraphicsTrustStatus: MSGraphicsTrust; - /** - * Pauses the current playback and sets paused to TRUE. This can be used to test whether the media is playing or paused. You can also use the pause or play events to tell whether the media is playing or not. - */ - pause(): void; - /** - * Loads and starts playback of a media resource. - */ - play(): void; - /** - * Fires immediately after the client loads the object. - */ - load(): void; - /** - * Returns a string that specifies whether the client can play a given media resource type. - */ - canPlayType(type: string): string; - /** - * Clears all effects from the media pipeline. - */ - msClearEffects(): void; - /** - * Specifies the media protection manager for a given media pipeline. - */ - msSetMediaProtectionManager(mediaProtectionManager?: any): void; - /** - * Inserts the specified audio effect into media pipeline. - */ - msInsertAudioEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; - msSetMediaKeys(mediaKeys: MSMediaKeys): void; - addTextTrack(kind: string, label?: string, language?: string): TextTrack; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLMediaElement: { - prototype: HTMLMediaElement; - new(): HTMLMediaElement; - HAVE_METADATA: number; - HAVE_CURRENT_DATA: number; - HAVE_NOTHING: number; - NETWORK_NO_SOURCE: number; - HAVE_ENOUGH_DATA: number; - NETWORK_EMPTY: number; - NETWORK_LOADING: number; - NETWORK_IDLE: number; - HAVE_FUTURE_DATA: number; -} - -interface ElementCSSInlineStyle { - runtimeStyle: MSStyleCSSProperties; - currentStyle: MSCurrentStyleCSSProperties; - doScroll(component?: any): void; - componentFromPoint(x: number, y: number): string; -} - -interface DOMParser { - parseFromString(source: string, mimeType: string): Document; -} -declare var DOMParser: { - prototype: DOMParser; - new(): DOMParser; -} - -interface MSMimeTypesCollection { - length: number; -} -declare var MSMimeTypesCollection: { - prototype: MSMimeTypesCollection; - new(): MSMimeTypesCollection; -} - -interface StyleSheet { - disabled: boolean; - ownerNode: Node; - parentStyleSheet: StyleSheet; - href: string; - media: MediaList; - type: string; - title: string; -} -declare var StyleSheet: { - prototype: StyleSheet; - new(): StyleSheet; -} - -interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { - startOffset: SVGAnimatedLength; - method: SVGAnimatedEnumeration; - spacing: SVGAnimatedEnumeration; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} -declare var SVGTextPathElement: { - prototype: SVGTextPathElement; - new(): SVGTextPathElement; - TEXTPATH_SPACINGTYPE_EXACT: number; - TEXTPATH_METHODTYPE_STRETCH: number; - TEXTPATH_SPACINGTYPE_AUTO: number; - TEXTPATH_SPACINGTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_UNKNOWN: number; - TEXTPATH_METHODTYPE_ALIGN: number; -} - -interface HTMLDTElement extends HTMLElement { - /** - * Sets or retrieves whether the browser automatically performs wordwrap. - */ - noWrap: boolean; -} -declare var HTMLDTElement: { - prototype: HTMLDTElement; - new(): HTMLDTElement; -} - -interface NodeList { - length: number; - item(index: number): Node; - [index: number]: Node; -} -declare var NodeList: { - prototype: NodeList; - new(): NodeList; -} - -interface XMLSerializer { - serializeToString(target: Node): string; -} -declare var XMLSerializer: { - prototype: XMLSerializer; - new(): XMLSerializer; -} - -interface PerformanceMeasure extends PerformanceEntry { -} -declare var PerformanceMeasure: { - prototype: PerformanceMeasure; - new(): PerformanceMeasure; -} - -interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGExternalResourcesRequired, SVGURIReference { - spreadMethod: SVGAnimatedEnumeration; - gradientTransform: SVGAnimatedTransformList; - gradientUnits: SVGAnimatedEnumeration; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} -declare var SVGGradientElement: { - prototype: SVGGradientElement; - new(): SVGGradientElement; - SVG_SPREADMETHOD_REFLECT: number; - SVG_SPREADMETHOD_PAD: number; - SVG_SPREADMETHOD_UNKNOWN: number; - SVG_SPREADMETHOD_REPEAT: number; -} - -interface NodeFilter { - acceptNode(n: Node): number; - SHOW_ENTITY_REFERENCE: number; - SHOW_NOTATION: number; - SHOW_ENTITY: number; - SHOW_DOCUMENT: number; - SHOW_PROCESSING_INSTRUCTION: number; - FILTER_REJECT: number; - SHOW_CDATA_SECTION: number; - FILTER_ACCEPT: number; - SHOW_ALL: number; - SHOW_DOCUMENT_TYPE: number; - SHOW_TEXT: number; - SHOW_ELEMENT: number; - SHOW_COMMENT: number; - FILTER_SKIP: number; - SHOW_ATTRIBUTE: number; - SHOW_DOCUMENT_FRAGMENT: number; -} -declare var NodeFilter: NodeFilter; - -interface SVGNumberList { - numberOfItems: number; - replaceItem(newItem: SVGNumber, index: number): SVGNumber; - getItem(index: number): SVGNumber; - clear(): void; - appendItem(newItem: SVGNumber): SVGNumber; - initialize(newItem: SVGNumber): SVGNumber; - removeItem(index: number): SVGNumber; - insertItemBefore(newItem: SVGNumber, index: number): SVGNumber; -} -declare var SVGNumberList: { - prototype: SVGNumberList; - new(): SVGNumberList; -} - -interface MediaError { - code: number; - msExtendedCode: number; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; - MS_MEDIA_ERR_ENCRYPTED: number; -} -declare var MediaError: { - prototype: MediaError; - new(): MediaError; - MEDIA_ERR_ABORTED: number; - MEDIA_ERR_NETWORK: number; - MEDIA_ERR_SRC_NOT_SUPPORTED: number; - MEDIA_ERR_DECODE: number; - MS_MEDIA_ERR_ENCRYPTED: number; -} - -interface HTMLFieldSetElement extends HTMLElement { - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} -declare var HTMLFieldSetElement: { - prototype: HTMLFieldSetElement; - new(): HTMLFieldSetElement; -} - -interface HTMLBGSoundElement extends HTMLElement { - /** - * Sets or gets the value indicating how the volume of the background sound is divided between the left speaker and the right speaker. - */ - balance: any; - /** - * Sets or gets the volume setting for the sound. - */ - volume: any; - /** - * Sets or gets the URL of a sound to play. - */ - src: string; - /** - * Sets or retrieves the number of times a sound or video clip will loop when activated. - */ - loop: number; -} -declare var HTMLBGSoundElement: { - prototype: HTMLBGSoundElement; - new(): HTMLBGSoundElement; -} - -interface Comment extends CharacterData { - text: string; -} -declare var Comment: { - prototype: Comment; - new(): Comment; -} - -interface PerformanceResourceTiming extends PerformanceEntry { - redirectStart: number; - redirectEnd: number; - domainLookupEnd: number; - responseStart: number; - domainLookupStart: number; - fetchStart: number; - requestStart: number; - connectEnd: number; - connectStart: number; - initiatorType: string; - responseEnd: number; -} -declare var PerformanceResourceTiming: { - prototype: PerformanceResourceTiming; - new(): PerformanceResourceTiming; -} - -interface CanvasPattern { -} -declare var CanvasPattern: { - prototype: CanvasPattern; - new(): CanvasPattern; -} - -interface HTMLHRElement extends HTMLElement, DOML2DeprecatedColorProperty, DOML2DeprecatedSizeProperty { - /** - * Sets or retrieves the width of the object. - */ - width: number; - /** - * Sets or retrieves how the object is aligned with adjacent text. - */ - align: string; - /** - * Sets or retrieves whether the horizontal rule is drawn with 3-D shading. - */ - noShade: boolean; -} -declare var HTMLHRElement: { - prototype: HTMLHRElement; - new(): HTMLHRElement; -} - -interface HTMLObjectElement extends HTMLElement, GetSVGDocument, DOML2DeprecatedMarginStyle, DOML2DeprecatedBorderStyle, DOML2DeprecatedAlignmentStyle, MSDataBindingExtensions, MSDataBindingRecordSetExtensions { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Sets or retrieves the Internet media type for the code associated with the object. - */ - codeType: string; - /** - * Retrieves the contained object. - */ - object: any; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the URL of the file containing the compiled Java class. - */ - code: string; - /** - * Sets or retrieves a character string that can be used to implement your own archive functionality for the object. - */ - archive: string; - /** - * Sets or retrieves a message to be displayed while an object is loading. - */ - standby: string; - /** - * Sets or retrieves a text alternative to the graphic. - */ - alt: string; - /** - * Sets or retrieves the class identifier for the object. - */ - classid: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - /** - * Sets or retrieves the URL, often with a bookmark extension (#name), to use as a client-side image map. - */ - useMap: string; - /** - * Sets or retrieves the URL that references the data of the object. - */ - data: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Retrieves the document object of the page or frame. - */ - contentDocument: Document; - /** - * Gets or sets the optional alternative HTML script to execute if the object fails to load. - */ - altHtml: string; - /** - * Sets or retrieves the URL of the component. - */ - codeBase: string; - declare: boolean; - /** - * Sets or retrieves the MIME type of the object. - */ - type: string; - /** - * Retrieves a string of the URL where the object tag can be found. This is often the href of the document that the object is in, or the value set by a base element. - */ - BaseHref: string; - /** - * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. - */ - validationMessage: string; - /** - * Returns a ValidityState object that represents the validity states of an element. - */ - validity: ValidityState; - /** - * Returns whether an element will successfully validate based on forms validation rules and constraints. - */ - willValidate: boolean; - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - readyState: number; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; - /** - * Returns whether a form will validate when it is submitted, without having to submit it. - */ - checkValidity(): boolean; - /** - * Sets a custom error message that is displayed when a form is submitted. - * @param error Sets a custom error message that is displayed when a form is submitted. - */ - setCustomValidity(error: string): void; -} -declare var HTMLObjectElement: { - prototype: HTMLObjectElement; - new(): HTMLObjectElement; -} - -interface HTMLEmbedElement extends HTMLElement, GetSVGDocument { - /** - * Sets or retrieves the width of the object. - */ - width: string; - /** - * Retrieves the palette used for the embedded document. - */ - palette: string; - /** - * Sets or retrieves a URL to be loaded by the object. - */ - src: string; - /** - * Sets or retrieves the name of the object. - */ - name: string; - hidden: string; - /** - * Retrieves the URL of the plug-in used to view an embedded document. - */ - pluginspage: string; - /** - * Sets or retrieves the height of the object. - */ - height: string; - /** - * Sets or retrieves the height and width units of the embed object. - */ - units: string; - /** - * Gets or sets the path to the preferred media source. This enables the Play To target device to stream the media content, which can be DRM protected, from a different location, such as a cloud media server. - */ - msPlayToPreferredSourceUri: string; - /** - * Gets or sets the primary DLNA PlayTo device. - */ - msPlayToPrimary: boolean; - /** - * Gets or sets whether the DLNA PlayTo device is available. - */ - msPlayToDisabled: boolean; - readyState: string; - /** - * Gets the source associated with the media element for use by the PlayToManager. - */ - msPlayToSource: any; -} -declare var HTMLEmbedElement: { - prototype: HTMLEmbedElement; - new(): HTMLEmbedElement; -} - -interface StorageEvent extends Event { - oldValue: any; - newValue: any; - url: string; - storageArea: Storage; - key: string; - initStorageEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, keyArg: string, oldValueArg: any, newValueArg: any, urlArg: string, storageAreaArg: Storage): void; -} -declare var StorageEvent: { - prototype: StorageEvent; - new(): StorageEvent; -} - -interface CharacterData extends Node { - length: number; - data: string; - deleteData(offset: number, count: number): void; - replaceData(offset: number, count: number, arg: string): void; - appendData(arg: string): void; - insertData(offset: number, arg: string): void; - substringData(offset: number, count: number): string; -} -declare var CharacterData: { - prototype: CharacterData; - new(): CharacterData; -} - -interface HTMLOptGroupElement extends HTMLElement, MSDataBindingExtensions { - /** - * Sets or retrieves the ordinal position of an option in a list box. - */ - index: number; - /** - * Sets or retrieves the status of an option. - */ - defaultSelected: boolean; - /** - * Sets or retrieves the text string specified by the option tag. - */ - text: string; - /** - * Sets or retrieves the value which is returned to the server when the form control is submitted. - */ - value: string; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves a value that you can use to implement your own label functionality for the object. - */ - label: string; - /** - * Sets or retrieves whether the option in the list box is the default item. - */ - selected: boolean; -} -declare var HTMLOptGroupElement: { - prototype: HTMLOptGroupElement; - new(): HTMLOptGroupElement; -} - -interface HTMLIsIndexElement extends HTMLElement { - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; - /** - * Sets or retrieves the URL to which the form content is sent for processing. - */ - action: string; - prompt: string; -} -declare var HTMLIsIndexElement: { - prototype: HTMLIsIndexElement; - new(): HTMLIsIndexElement; -} - -interface SVGPathSegLinetoRel extends SVGPathSeg { - y: number; - x: number; -} -declare var SVGPathSegLinetoRel: { - prototype: SVGPathSegLinetoRel; - new(): SVGPathSegLinetoRel; -} - -interface DOMException { - code: number; - message: string; - name: string; - toString(): string; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; - INVALID_NODE_TYPE_ERR: number; - DATA_CLONE_ERR: number; - TIMEOUT_ERR: number; -} -declare var DOMException: { - prototype: DOMException; - new(): DOMException; - HIERARCHY_REQUEST_ERR: number; - NO_MODIFICATION_ALLOWED_ERR: number; - INVALID_MODIFICATION_ERR: number; - NAMESPACE_ERR: number; - INVALID_CHARACTER_ERR: number; - TYPE_MISMATCH_ERR: number; - ABORT_ERR: number; - INVALID_STATE_ERR: number; - SECURITY_ERR: number; - NETWORK_ERR: number; - WRONG_DOCUMENT_ERR: number; - QUOTA_EXCEEDED_ERR: number; - INDEX_SIZE_ERR: number; - DOMSTRING_SIZE_ERR: number; - SYNTAX_ERR: number; - SERIALIZE_ERR: number; - VALIDATION_ERR: number; - NOT_FOUND_ERR: number; - URL_MISMATCH_ERR: number; - PARSE_ERR: number; - NO_DATA_ALLOWED_ERR: number; - NOT_SUPPORTED_ERR: number; - INVALID_ACCESS_ERR: number; - INUSE_ATTRIBUTE_ERR: number; - INVALID_NODE_TYPE_ERR: number; - DATA_CLONE_ERR: number; - TIMEOUT_ERR: number; -} - -interface SVGAnimatedBoolean { - animVal: boolean; - baseVal: boolean; -} -declare var SVGAnimatedBoolean: { - prototype: SVGAnimatedBoolean; - new(): SVGAnimatedBoolean; -} - -interface MSCompatibleInfoCollection { - length: number; - item(index: number): MSCompatibleInfo; -} -declare var MSCompatibleInfoCollection: { - prototype: MSCompatibleInfoCollection; - new(): MSCompatibleInfoCollection; -} - -interface SVGSwitchElement extends SVGElement, SVGStylable, SVGTransformable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { -} -declare var SVGSwitchElement: { - prototype: SVGSwitchElement; - new(): SVGSwitchElement; -} - -interface SVGPreserveAspectRatio { - align: number; - meetOrSlice: number; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} -declare var SVGPreserveAspectRatio: { - prototype: SVGPreserveAspectRatio; - new(): SVGPreserveAspectRatio; - SVG_PRESERVEASPECTRATIO_NONE: number; - SVG_PRESERVEASPECTRATIO_XMINYMID: number; - SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; - SVG_PRESERVEASPECTRATIO_XMINYMAX: number; - SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; - SVG_MEETORSLICE_UNKNOWN: number; - SVG_PRESERVEASPECTRATIO_XMAXYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; - SVG_PRESERVEASPECTRATIO_XMINYMIN: number; - SVG_MEETORSLICE_MEET: number; - SVG_PRESERVEASPECTRATIO_XMIDYMID: number; - SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; - SVG_MEETORSLICE_SLICE: number; - SVG_PRESERVEASPECTRATIO_UNKNOWN: number; -} - -interface Attr extends Node { - expando: boolean; - specified: boolean; - ownerElement: Element; - value: string; - name: string; -} -declare var Attr: { - prototype: Attr; - new(): Attr; -} - -interface PerformanceNavigation { - redirectCount: number; - type: number; - toJSON(): any; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} -declare var PerformanceNavigation: { - prototype: PerformanceNavigation; - new(): PerformanceNavigation; - TYPE_RELOAD: number; - TYPE_RESERVED: number; - TYPE_BACK_FORWARD: number; - TYPE_NAVIGATE: number; -} - -interface SVGStopElement extends SVGElement, SVGStylable { - offset: SVGAnimatedNumber; -} -declare var SVGStopElement: { - prototype: SVGStopElement; - new(): SVGStopElement; -} - -interface PositionCallback { - (position: Position): void; -} - -interface SVGSymbolElement extends SVGElement, SVGStylable, SVGLangSpace, SVGFitToViewBox, SVGExternalResourcesRequired { -} -declare var SVGSymbolElement: { - prototype: SVGSymbolElement; - new(): SVGSymbolElement; -} - -interface SVGElementInstanceList { - length: number; - item(index: number): SVGElementInstance; -} -declare var SVGElementInstanceList: { - prototype: SVGElementInstanceList; - new(): SVGElementInstanceList; -} - -interface CSSRuleList { - length: number; - item(index: number): CSSRule; - [index: number]: CSSRule; -} -declare var CSSRuleList: { - prototype: CSSRuleList; - new(): CSSRuleList; -} - -interface MSDataBindingRecordSetExtensions { - recordset: any; - namedRecordset(dataMember: string, hierarchy?: any): any; -} - -interface LinkStyle { - styleSheet: StyleSheet; - sheet: StyleSheet; -} - -interface HTMLVideoElement extends HTMLMediaElement { - /** - * Gets or sets the width of the video element. - */ - width: number; - /** - * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. - */ - videoWidth: number; - /** - * Gets the intrinsic height of a video in CSS pixels, or zero if the dimensions are not known. - */ - videoHeight: number; - /** - * Gets or sets the height of the video element. - */ - height: number; - /** - * Gets or sets a URL of an image to display, for example, like a movie poster. This can be a still frame from the video, or another image if no video data is available. - */ - poster: string; - msIsStereo3D: boolean; - msStereo3DPackingMode: string; - onMSVideoOptimalLayoutChanged: (ev: any) => any; - onMSVideoFrameStepCompleted: (ev: any) => any; - msStereo3DRenderMode: string; - msIsLayoutOptimalForPlayback: boolean; - msHorizontalMirror: boolean; - onMSVideoFormatChanged: (ev: any) => any; - msZoom: boolean; - msInsertVideoEffect(activatableClassId: string, effectRequired: boolean, config?: any): void; - msSetVideoRectangle(left: number, top: number, right: number, bottom: number): void; - msFrameStep(forward: boolean): void; - getVideoPlaybackQuality(): VideoPlaybackQuality; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgotpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mslostpointercapture", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "lostpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "gotpointercapture", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "move", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "deactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "datasetchanged", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsdelete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "losecapture", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "controlselect", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "layoutcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "beforeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforeupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "filterchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "datasetcomplete", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "errorupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; - addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cellchange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowexit", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "rowsinserted", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "propertychange", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforepaste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforecopy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "paste", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "moveend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "beforeeditfocus", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "afterupdate", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resizeend", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "dataavailable", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "beforedeactivate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "activate", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "movestart", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "selectstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; - addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "cut", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "copy", listener: (ev: DragEvent) => any, useCapture?: boolean): void; - addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "rowenter", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "mscontentzoom", listener: (ev: MSEventObj) => any, useCapture?: boolean): void; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "msmanipulationstatechanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "msneedkey", listener: (ev: MSMediaKeyNeededEvent) => any, useCapture?: boolean): void; - addEventListener(type: "MSVideoOptimalLayoutChanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "MSVideoFrameStepCompleted", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "MSVideoFormatChanged", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var HTMLVideoElement: { - prototype: HTMLVideoElement; - new(): HTMLVideoElement; -} - -interface ClientRectList { - length: number; - item(index: number): ClientRect; - [index: number]: ClientRect; -} -declare var ClientRectList: { - prototype: ClientRectList; - new(): ClientRectList; -} - -interface SVGMaskElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGTests, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - maskUnits: SVGAnimatedEnumeration; - maskContentUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; -} -declare var SVGMaskElement: { - prototype: SVGMaskElement; - new(): SVGMaskElement; -} - -interface External { -} -declare var External: { - prototype: External; - new(): External; -} - -interface MSGestureEvent extends UIEvent { - offsetY: number; - translationY: number; - velocityExpansion: number; - velocityY: number; - velocityAngular: number; - translationX: number; - velocityX: number; - hwTimestamp: number; - offsetX: number; - screenX: number; - rotation: number; - expansion: number; - clientY: number; - screenY: number; - scale: number; - gestureObject: any; - clientX: number; - initGestureEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, offsetXArg: number, offsetYArg: number, translationXArg: number, translationYArg: number, scaleArg: number, expansionArg: number, rotationArg: number, velocityXArg: number, velocityYArg: number, velocityExpansionArg: number, velocityAngularArg: number, hwTimestampArg: number): void; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} -declare var MSGestureEvent: { - prototype: MSGestureEvent; - new(): MSGestureEvent; - MSGESTURE_FLAG_BEGIN: number; - MSGESTURE_FLAG_END: number; - MSGESTURE_FLAG_CANCEL: number; - MSGESTURE_FLAG_INERTIA: number; - MSGESTURE_FLAG_NONE: number; -} - -interface ErrorEvent extends Event { - colno: number; - filename: string; - error: any; - lineno: number; - message: string; - initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; -} -declare var ErrorEvent: { - prototype: ErrorEvent; - new(): ErrorEvent; -} - -interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGStylable, SVGLangSpace, SVGURIReference, SVGExternalResourcesRequired { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - filterResX: SVGAnimatedInteger; - filterUnits: SVGAnimatedEnumeration; - primitiveUnits: SVGAnimatedEnumeration; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - filterResY: SVGAnimatedInteger; - setFilterRes(filterResX: number, filterResY: number): void; -} -declare var SVGFilterElement: { - prototype: SVGFilterElement; - new(): SVGFilterElement; -} - -interface TrackEvent extends Event { - track: any; -} -declare var TrackEvent: { - prototype: TrackEvent; - new(): TrackEvent; -} - -interface SVGFEMergeNodeElement extends SVGElement { - in1: SVGAnimatedString; -} -declare var SVGFEMergeNodeElement: { - prototype: SVGFEMergeNodeElement; - new(): SVGFEMergeNodeElement; -} - -interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { -} -declare var SVGFEFloodElement: { - prototype: SVGFEFloodElement; - new(): SVGFEFloodElement; -} - -interface MSGesture { - target: Element; - addPointer(pointerId: number): void; - stop(): void; -} -declare var MSGesture: { - prototype: MSGesture; - new(): MSGesture; -} - -interface TextTrackCue extends EventTarget { - onenter: (ev: Event) => any; - track: TextTrack; - endTime: number; - text: string; - pauseOnExit: boolean; - id: string; - startTime: number; - onexit: (ev: Event) => any; - getCueAsHTML(): DocumentFragment; - addEventListener(type: "enter", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "exit", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var TextTrackCue: { - prototype: TextTrackCue; - new(startTime: number, endTime: number, text: string): TextTrackCue; -} - -interface MSStreamReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(stream: MSStream, size?: number): void; - readAsBlob(stream: MSStream, size?: number): void; - readAsDataURL(stream: MSStream, size?: number): void; - readAsText(stream: MSStream, encoding?: string, size?: number): void; -} -declare var MSStreamReader: { - prototype: MSStreamReader; - new(): MSStreamReader; -} - -interface DOMTokenList { - length: number; - contains(token: string): boolean; - remove(token: string): void; - toggle(token: string): boolean; - add(token: string): void; - item(index: number): string; - [index: number]: string; - toString(): string; -} -declare var DOMTokenList: { - prototype: DOMTokenList; - new(): DOMTokenList; -} - -interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncAElement: { - prototype: SVGFEFuncAElement; - new(): SVGFEFuncAElement; -} - -interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; -} -declare var SVGFETileElement: { - prototype: SVGFETileElement; - new(): SVGFETileElement; -} - -interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in2: SVGAnimatedString; - mode: SVGAnimatedEnumeration; - in1: SVGAnimatedString; - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_UNKNOWN: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_LIGHTEN: number; -} -declare var SVGFEBlendElement: { - prototype: SVGFEBlendElement; - new(): SVGFEBlendElement; - SVG_FEBLEND_MODE_DARKEN: number; - SVG_FEBLEND_MODE_UNKNOWN: number; - SVG_FEBLEND_MODE_MULTIPLY: number; - SVG_FEBLEND_MODE_NORMAL: number; - SVG_FEBLEND_MODE_SCREEN: number; - SVG_FEBLEND_MODE_LIGHTEN: number; -} - -interface MessageChannel { - port2: MessagePort; - port1: MessagePort; -} -declare var MessageChannel: { - prototype: MessageChannel; - new(): MessageChannel; -} - -interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { -} -declare var SVGFEMergeElement: { - prototype: SVGFEMergeElement; - new(): SVGFEMergeElement; -} - -interface TransitionEvent extends Event { - propertyName: string; - elapsedTime: number; - initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; -} -declare var TransitionEvent: { - prototype: TransitionEvent; - new(): TransitionEvent; -} - -interface MediaQueryList { - matches: boolean; - media: string; - addListener(listener: MediaQueryListListener): void; - removeListener(listener: MediaQueryListListener): void; -} -declare var MediaQueryList: { - prototype: MediaQueryList; - new(): MediaQueryList; -} - -interface DOMError { - name: string; - toString(): string; -} -declare var DOMError: { - prototype: DOMError; - new(): DOMError; -} - -interface CloseEvent extends Event { - wasClean: boolean; - reason: string; - code: number; - initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; -} -declare var CloseEvent: { - prototype: CloseEvent; - new(): CloseEvent; -} - -interface WebSocket extends EventTarget { - protocol: string; - readyState: number; - bufferedAmount: number; - onopen: (ev: Event) => any; - extensions: string; - onmessage: (ev: MessageEvent) => any; - onclose: (ev: CloseEvent) => any; - onerror: (ev: ErrorEvent) => any; - binaryType: string; - url: string; - close(code?: number, reason?: string): void; - send(data: any): void; - OPEN: number; - CLOSING: number; - CONNECTING: number; - CLOSED: number; - addEventListener(type: "open", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: "close", listener: (ev: CloseEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var WebSocket: { - prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: string[]): WebSocket; - OPEN: number; - CLOSING: number; - CONNECTING: number; - CLOSED: number; -} - -interface SVGFEPointLightElement extends SVGElement { - y: SVGAnimatedNumber; - x: SVGAnimatedNumber; - z: SVGAnimatedNumber; -} -declare var SVGFEPointLightElement: { - prototype: SVGFEPointLightElement; - new(): SVGFEPointLightElement; -} - -interface ProgressEvent extends Event { - loaded: number; - lengthComputable: boolean; - total: number; - initProgressEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, lengthComputableArg: boolean, loadedArg: number, totalArg: number): void; -} -declare var ProgressEvent: { - prototype: ProgressEvent; - new(): ProgressEvent; -} - -interface IDBObjectStore { - indexNames: DOMStringList; - name: string; - transaction: IDBTransaction; - keyPath: string; - count(key?: any): IDBRequest; - add(value: any, key?: any): IDBRequest; - clear(): IDBRequest; - createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex; - put(value: any, key?: any): IDBRequest; - openCursor(range?: any, direction?: string): IDBRequest; - deleteIndex(indexName: string): void; - index(name: string): IDBIndex; - get(key: any): IDBRequest; - delete(key: any): IDBRequest; -} -declare var IDBObjectStore: { - prototype: IDBObjectStore; - new(): IDBObjectStore; -} - -interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - stdDeviationX: SVGAnimatedNumber; - in1: SVGAnimatedString; - stdDeviationY: SVGAnimatedNumber; - setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; -} -declare var SVGFEGaussianBlurElement: { - prototype: SVGFEGaussianBlurElement; - new(): SVGFEGaussianBlurElement; -} - -interface SVGFilterPrimitiveStandardAttributes extends SVGStylable { - y: SVGAnimatedLength; - width: SVGAnimatedLength; - x: SVGAnimatedLength; - height: SVGAnimatedLength; - result: SVGAnimatedString; -} - -interface IDBVersionChangeEvent extends Event { - newVersion: number; - oldVersion: number; -} -declare var IDBVersionChangeEvent: { - prototype: IDBVersionChangeEvent; - new(): IDBVersionChangeEvent; -} - -interface IDBIndex { - unique: boolean; - name: string; - keyPath: string; - objectStore: IDBObjectStore; - count(key?: any): IDBRequest; - getKey(key: any): IDBRequest; - openKeyCursor(range?: IDBKeyRange, direction?: string): IDBRequest; - get(key: any): IDBRequest; - openCursor(range?: IDBKeyRange, direction?: string): IDBRequest; -} -declare var IDBIndex: { - prototype: IDBIndex; - new(): IDBIndex; -} - -interface FileList { - length: number; - item(index: number): File; - [index: number]: File; -} -declare var FileList: { - prototype: FileList; - new(): FileList; -} - -interface IDBCursor { - source: any; - direction: string; - key: any; - primaryKey: any; - advance(count: number): void; - delete(): IDBRequest; - continue(key?: any): void; - update(value: any): IDBRequest; - PREV: string; - PREV_NO_DUPLICATE: string; - NEXT: string; - NEXT_NO_DUPLICATE: string; -} -declare var IDBCursor: { - prototype: IDBCursor; - new(): IDBCursor; - PREV: string; - PREV_NO_DUPLICATE: string; - NEXT: string; - NEXT_NO_DUPLICATE: string; -} - -interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - specularConstant: SVGAnimatedNumber; -} -declare var SVGFESpecularLightingElement: { - prototype: SVGFESpecularLightingElement; - new(): SVGFESpecularLightingElement; -} - -interface File extends Blob { - lastModifiedDate: any; - name: string; -} -declare var File: { - prototype: File; - new(): File; -} - -interface URL { - revokeObjectURL(url: string): void; - createObjectURL(object: any, options?: ObjectURLOptions): string; -} -declare var URL: URL; - -interface IDBCursorWithValue extends IDBCursor { - value: any; -} -declare var IDBCursorWithValue: { - prototype: IDBCursorWithValue; - new(): IDBCursorWithValue; -} - -interface XMLHttpRequestEventTarget extends EventTarget { - onprogress: (ev: ProgressEvent) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: Event) => any; - ontimeout: (ev: Event) => any; - onabort: (ev: UIEvent) => any; - onloadstart: (ev: Event) => any; - onloadend: (ev: ProgressEvent) => any; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "timeout", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var XMLHttpRequestEventTarget: { - prototype: XMLHttpRequestEventTarget; - new(): XMLHttpRequestEventTarget; -} - -interface IDBEnvironment { - msIndexedDB: IDBFactory; - indexedDB: IDBFactory; -} - -interface AudioTrackList extends EventTarget { - length: number; - onchange: (ev: Event) => any; - onaddtrack: (ev: TrackEvent) => any; - onremovetrack: (ev: any /*PluginArray*/) => any; - getTrackById(id: string): AudioTrack; - item(index: number): AudioTrack; - [index: number]: AudioTrack; - addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; - addEventListener(type: "removetrack", listener: (ev: any /*PluginArray*/) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var AudioTrackList: { - prototype: AudioTrackList; - new(): AudioTrackList; -} - -interface MSBaseReader extends EventTarget { - onprogress: (ev: ProgressEvent) => any; - readyState: number; - onabort: (ev: UIEvent) => any; - onloadend: (ev: ProgressEvent) => any; - onerror: (ev: ErrorEvent) => any; - onload: (ev: Event) => any; - onloadstart: (ev: Event) => any; - result: any; - abort(): void; - LOADING: number; - EMPTY: number; - DONE: number; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - operator: SVGAnimatedEnumeration; - radiusX: SVGAnimatedNumber; - radiusY: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; -} -declare var SVGFEMorphologyElement: { - prototype: SVGFEMorphologyElement; - new(): SVGFEMorphologyElement; - SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; - SVG_MORPHOLOGY_OPERATOR_ERODE: number; - SVG_MORPHOLOGY_OPERATOR_DILATE: number; -} - -interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncRElement: { - prototype: SVGFEFuncRElement; - new(): SVGFEFuncRElement; -} - -interface WindowTimersExtension { - msSetImmediate(expression: any, ...args: any[]): number; - clearImmediate(handle: number): void; - msClearImmediate(handle: number): void; - setImmediate(expression: any, ...args: any[]): number; -} - -interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in2: SVGAnimatedString; - xChannelSelector: SVGAnimatedEnumeration; - yChannelSelector: SVGAnimatedEnumeration; - scale: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} -declare var SVGFEDisplacementMapElement: { - prototype: SVGFEDisplacementMapElement; - new(): SVGFEDisplacementMapElement; - SVG_CHANNEL_B: number; - SVG_CHANNEL_R: number; - SVG_CHANNEL_G: number; - SVG_CHANNEL_UNKNOWN: number; - SVG_CHANNEL_A: number; -} - -interface AnimationEvent extends Event { - animationName: string; - elapsedTime: number; - initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; -} -declare var AnimationEvent: { - prototype: AnimationEvent; - new(): AnimationEvent; -} - -interface SVGComponentTransferFunctionElement extends SVGElement { - tableValues: SVGAnimatedNumberList; - slope: SVGAnimatedNumber; - type: SVGAnimatedEnumeration; - exponent: SVGAnimatedNumber; - amplitude: SVGAnimatedNumber; - intercept: SVGAnimatedNumber; - offset: SVGAnimatedNumber; - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; -} -declare var SVGComponentTransferFunctionElement: { - prototype: SVGComponentTransferFunctionElement; - new(): SVGComponentTransferFunctionElement; - SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; - SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; - SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; - SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; - SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; - SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; -} - -interface MSRangeCollection { - length: number; - item(index: number): Range; - [index: number]: Range; -} -declare var MSRangeCollection: { - prototype: MSRangeCollection; - new(): MSRangeCollection; -} - -interface SVGFEDistantLightElement extends SVGElement { - azimuth: SVGAnimatedNumber; - elevation: SVGAnimatedNumber; -} -declare var SVGFEDistantLightElement: { - prototype: SVGFEDistantLightElement; - new(): SVGFEDistantLightElement; -} - -interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncBElement: { - prototype: SVGFEFuncBElement; - new(): SVGFEFuncBElement; -} - -interface IDBKeyRange { - upper: any; - upperOpen: boolean; - lower: any; - lowerOpen: boolean; -} -declare var IDBKeyRange: { - prototype: IDBKeyRange; - new(): IDBKeyRange; - bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; - only(value: any): IDBKeyRange; - lowerBound(bound: any, open?: boolean): IDBKeyRange; - upperBound(bound: any, open?: boolean): IDBKeyRange; -} - -interface WindowConsole { - console: Console; -} - -interface IDBTransaction extends EventTarget { - oncomplete: (ev: Event) => any; - db: IDBDatabase; - mode: string; - error: DOMError; - onerror: (ev: ErrorEvent) => any; - onabort: (ev: UIEvent) => any; - abort(): void; - objectStore(name: string): IDBObjectStore; - READ_ONLY: string; - VERSION_CHANGE: string; - READ_WRITE: string; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBTransaction: { - prototype: IDBTransaction; - new(): IDBTransaction; - READ_ONLY: string; - VERSION_CHANGE: string; - READ_WRITE: string; -} - -interface AudioTrack { - kind: string; - language: string; - id: string; - label: string; - enabled: boolean; - sourceBuffer: SourceBuffer; -} -declare var AudioTrack: { - prototype: AudioTrack; - new(): AudioTrack; -} - -interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - orderY: SVGAnimatedInteger; - kernelUnitLengthY: SVGAnimatedNumber; - orderX: SVGAnimatedInteger; - preserveAlpha: SVGAnimatedBoolean; - kernelMatrix: SVGAnimatedNumberList; - edgeMode: SVGAnimatedEnumeration; - kernelUnitLengthX: SVGAnimatedNumber; - bias: SVGAnimatedNumber; - targetX: SVGAnimatedInteger; - targetY: SVGAnimatedInteger; - divisor: SVGAnimatedNumber; - in1: SVGAnimatedString; - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} -declare var SVGFEConvolveMatrixElement: { - prototype: SVGFEConvolveMatrixElement; - new(): SVGFEConvolveMatrixElement; - SVG_EDGEMODE_WRAP: number; - SVG_EDGEMODE_DUPLICATE: number; - SVG_EDGEMODE_UNKNOWN: number; - SVG_EDGEMODE_NONE: number; -} - -interface TextTrackCueList { - length: number; - item(index: number): TextTrackCue; - [index: number]: TextTrackCue; - getCueById(id: string): TextTrackCue; -} -declare var TextTrackCueList: { - prototype: TextTrackCueList; - new(): TextTrackCueList; -} - -interface CSSKeyframesRule extends CSSRule { - name: string; - cssRules: CSSRuleList; - findRule(rule: string): CSSKeyframeRule; - deleteRule(rule: string): void; - appendRule(rule: string): void; -} -declare var CSSKeyframesRule: { - prototype: CSSKeyframesRule; - new(): CSSKeyframesRule; -} - -interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - baseFrequencyX: SVGAnimatedNumber; - numOctaves: SVGAnimatedInteger; - type: SVGAnimatedEnumeration; - baseFrequencyY: SVGAnimatedNumber; - stitchTiles: SVGAnimatedEnumeration; - seed: SVGAnimatedNumber; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} -declare var SVGFETurbulenceElement: { - prototype: SVGFETurbulenceElement; - new(): SVGFETurbulenceElement; - SVG_STITCHTYPE_UNKNOWN: number; - SVG_STITCHTYPE_NOSTITCH: number; - SVG_TURBULENCE_TYPE_UNKNOWN: number; - SVG_TURBULENCE_TYPE_TURBULENCE: number; - SVG_TURBULENCE_TYPE_FRACTALNOISE: number; - SVG_STITCHTYPE_STITCH: number; -} - -interface TextTrackList extends EventTarget { - length: number; - onaddtrack: (ev: TrackEvent) => any; - item(index: number): TextTrack; - [index: number]: TextTrack; - addEventListener(type: "addtrack", listener: (ev: TrackEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var TextTrackList: { - prototype: TextTrackList; - new(): TextTrackList; -} - -interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { -} -declare var SVGFEFuncGElement: { - prototype: SVGFEFuncGElement; - new(): SVGFEFuncGElement; -} - -interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; - type: SVGAnimatedEnumeration; - values: SVGAnimatedNumberList; - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; -} -declare var SVGFEColorMatrixElement: { - prototype: SVGFEColorMatrixElement; - new(): SVGFEColorMatrixElement; - SVG_FECOLORMATRIX_TYPE_SATURATE: number; - SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; - SVG_FECOLORMATRIX_TYPE_MATRIX: number; - SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; - SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; -} - -interface SVGFESpotLightElement extends SVGElement { - pointsAtY: SVGAnimatedNumber; - y: SVGAnimatedNumber; - limitingConeAngle: SVGAnimatedNumber; - specularExponent: SVGAnimatedNumber; - x: SVGAnimatedNumber; - pointsAtZ: SVGAnimatedNumber; - z: SVGAnimatedNumber; - pointsAtX: SVGAnimatedNumber; -} -declare var SVGFESpotLightElement: { - prototype: SVGFESpotLightElement; - new(): SVGFESpotLightElement; -} - -interface WindowBase64 { - btoa(rawString: string): string; - atob(encodedString: string): string; -} - -interface IDBDatabase extends EventTarget { - version: string; - name: string; - objectStoreNames: DOMStringList; - onerror: (ev: ErrorEvent) => any; - onabort: (ev: UIEvent) => any; - createObjectStore(name: string, optionalParameters?: any): IDBObjectStore; - close(): void; - transaction(storeNames: any, mode?: string): IDBTransaction; - deleteObjectStore(name: string): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBDatabase: { - prototype: IDBDatabase; - new(): IDBDatabase; -} - -interface DOMStringList { - length: number; - contains(str: string): boolean; - item(index: number): string; - [index: number]: string; -} -declare var DOMStringList: { - prototype: DOMStringList; - new(): DOMStringList; -} - -interface IDBOpenDBRequest extends IDBRequest { - onupgradeneeded: (ev: IDBVersionChangeEvent) => any; - onblocked: (ev: Event) => any; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "upgradeneeded", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; - addEventListener(type: "blocked", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBOpenDBRequest: { - prototype: IDBOpenDBRequest; - new(): IDBOpenDBRequest; -} - -interface HTMLProgressElement extends HTMLElement { - /** - * Sets or gets the current value of a progress element. The value must be a non-negative number between 0 and the max value. - */ - value: number; - /** - * Defines the maximum, or "done" value for a progress element. - */ - max: number; - /** - * Returns the quotient of value/max when the value attribute is set (determinate progress bar), or -1 when the value attribute is missing (indeterminate progress bar). - */ - position: number; - /** - * Retrieves a reference to the form that the object is embedded in. - */ - form: HTMLFormElement; -} -declare var HTMLProgressElement: { - prototype: HTMLProgressElement; - new(): HTMLProgressElement; -} - -interface MSLaunchUriCallback { - (): void; -} - -interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - dy: SVGAnimatedNumber; - in1: SVGAnimatedString; - dx: SVGAnimatedNumber; -} -declare var SVGFEOffsetElement: { - prototype: SVGFEOffsetElement; - new(): SVGFEOffsetElement; -} - -interface MSUnsafeFunctionCallback { - (): any; -} - -interface TextTrack extends EventTarget { - language: string; - mode: any; - readyState: number; - activeCues: TextTrackCueList; - cues: TextTrackCueList; - oncuechange: (ev: Event) => any; - kind: string; - onload: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - label: string; - addCue(cue: TextTrackCue): void; - removeCue(cue: TextTrackCue): void; - ERROR: number; - SHOWING: number; - LOADING: number; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; - addEventListener(type: "cuechange", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var TextTrack: { - prototype: TextTrack; - new(): TextTrack; - ERROR: number; - SHOWING: number; - LOADING: number; - LOADED: number; - NONE: number; - HIDDEN: number; - DISABLED: number; -} - -interface MediaQueryListListener { - (mql: MediaQueryList): void; -} - -interface IDBRequest extends EventTarget { - source: any; - onsuccess: (ev: Event) => any; - error: DOMError; - transaction: IDBTransaction; - onerror: (ev: ErrorEvent) => any; - readyState: string; - result: any; - addEventListener(type: "success", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var IDBRequest: { - prototype: IDBRequest; - new(): IDBRequest; -} - -interface MessagePort extends EventTarget { - onmessage: (ev: MessageEvent) => any; - close(): void; - postMessage(message?: any, ports?: any): void; - start(): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MessagePort: { - prototype: MessagePort; - new(): MessagePort; -} - -interface FileReader extends MSBaseReader { - error: DOMError; - readAsArrayBuffer(blob: Blob): void; - readAsDataURL(blob: Blob): void; - readAsText(blob: Blob, encoding?: string): void; -} -declare var FileReader: { - prototype: FileReader; - new(): FileReader; -} - -interface ApplicationCache extends EventTarget { - status: number; - ondownloading: (ev: Event) => any; - onprogress: (ev: ProgressEvent) => any; - onupdateready: (ev: Event) => any; - oncached: (ev: Event) => any; - onobsolete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onchecking: (ev: Event) => any; - onnoupdate: (ev: Event) => any; - swapCache(): void; - abort(): void; - update(): void; - CHECKING: number; - UNCACHED: number; - UPDATEREADY: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; - addEventListener(type: "downloading", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "updateready", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "cached", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "obsolete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "checking", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "noupdate", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var ApplicationCache: { - prototype: ApplicationCache; - new(): ApplicationCache; - CHECKING: number; - UNCACHED: number; - UPDATEREADY: number; - DOWNLOADING: number; - IDLE: number; - OBSOLETE: number; -} - -interface FrameRequestCallback { - (time: number): void; -} - -interface PopStateEvent extends Event { - state: any; - initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; -} -declare var PopStateEvent: { - prototype: PopStateEvent; - new(): PopStateEvent; -} - -interface CSSKeyframeRule extends CSSRule { - keyText: string; - style: CSSStyleDeclaration; -} -declare var CSSKeyframeRule: { - prototype: CSSKeyframeRule; - new(): CSSKeyframeRule; -} - -interface MSFileSaver { - msSaveBlob(blob: any, defaultName?: string): boolean; - msSaveOrOpenBlob(blob: any, defaultName?: string): boolean; -} - -interface MSStream { - type: string; - msDetachStream(): any; - msClose(): void; -} -declare var MSStream: { - prototype: MSStream; - new(): MSStream; -} - -interface MSBlobBuilder { - append(data: any, endings?: string): void; - getBlob(contentType?: string): Blob; -} -declare var MSBlobBuilder: { - prototype: MSBlobBuilder; - new(): MSBlobBuilder; -} - -interface DOMSettableTokenList extends DOMTokenList { - value: string; -} -declare var DOMSettableTokenList: { - prototype: DOMSettableTokenList; - new(): DOMSettableTokenList; -} - -interface IDBFactory { - open(name: string, version?: number): IDBOpenDBRequest; - cmp(first: any, second: any): number; - deleteDatabase(name: string): IDBOpenDBRequest; -} -declare var IDBFactory: { - prototype: IDBFactory; - new(): IDBFactory; -} - -interface MSPointerEvent extends MouseEvent { - width: number; - rotation: number; - pressure: number; - pointerType: any; - isPrimary: boolean; - tiltY: number; - height: number; - intermediatePoints: any; - currentPoint: any; - tiltX: number; - hwTimestamp: number; - pointerId: number; - initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; - getCurrentPoint(element: Element): void; - getIntermediatePoints(element: Element): void; - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} -declare var MSPointerEvent: { - prototype: MSPointerEvent; - new(): MSPointerEvent; - MSPOINTER_TYPE_PEN: number; - MSPOINTER_TYPE_MOUSE: number; - MSPOINTER_TYPE_TOUCH: number; -} - -interface MSManipulationEvent extends UIEvent { - lastState: number; - currentState: number; - initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; - MS_MANIPULATION_STATE_STOPPED: number; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_INERTIA: number; - MS_MANIPULATION_STATE_SELECTING: number; - MS_MANIPULATION_STATE_COMMITTED: number; - MS_MANIPULATION_STATE_PRESELECT: number; - MS_MANIPULATION_STATE_DRAGGING: number; - MS_MANIPULATION_STATE_CANCELLED: number; -} -declare var MSManipulationEvent: { - prototype: MSManipulationEvent; - new(): MSManipulationEvent; - MS_MANIPULATION_STATE_STOPPED: number; - MS_MANIPULATION_STATE_ACTIVE: number; - MS_MANIPULATION_STATE_INERTIA: number; - MS_MANIPULATION_STATE_SELECTING: number; - MS_MANIPULATION_STATE_COMMITTED: number; - MS_MANIPULATION_STATE_PRESELECT: number; - MS_MANIPULATION_STATE_DRAGGING: number; - MS_MANIPULATION_STATE_CANCELLED: number; -} - -interface FormData { - append(name: any, value: any, blobName?: string): void; -} -declare var FormData: { - prototype: FormData; - new(): FormData; -} - -interface HTMLDataListElement extends HTMLElement { - options: HTMLCollection; -} -declare var HTMLDataListElement: { - prototype: HTMLDataListElement; - new(): HTMLDataListElement; -} - -interface SVGFEImageElement extends SVGElement, SVGLangSpace, SVGFilterPrimitiveStandardAttributes, SVGURIReference, SVGExternalResourcesRequired { - preserveAspectRatio: SVGAnimatedPreserveAspectRatio; -} -declare var SVGFEImageElement: { - prototype: SVGFEImageElement; - new(): SVGFEImageElement; -} - -interface AbstractWorker extends EventTarget { - onerror: (ev: ErrorEvent) => any; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - operator: SVGAnimatedEnumeration; - in2: SVGAnimatedString; - k2: SVGAnimatedNumber; - k1: SVGAnimatedNumber; - k3: SVGAnimatedNumber; - in1: SVGAnimatedString; - k4: SVGAnimatedNumber; - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; -} -declare var SVGFECompositeElement: { - prototype: SVGFECompositeElement; - new(): SVGFECompositeElement; - SVG_FECOMPOSITE_OPERATOR_OUT: number; - SVG_FECOMPOSITE_OPERATOR_OVER: number; - SVG_FECOMPOSITE_OPERATOR_XOR: number; - SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; - SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; - SVG_FECOMPOSITE_OPERATOR_IN: number; - SVG_FECOMPOSITE_OPERATOR_ATOP: number; -} - -interface ValidityState { - customError: boolean; - valueMissing: boolean; - stepMismatch: boolean; - rangeUnderflow: boolean; - rangeOverflow: boolean; - typeMismatch: boolean; - patternMismatch: boolean; - tooLong: boolean; - valid: boolean; -} -declare var ValidityState: { - prototype: ValidityState; - new(): ValidityState; -} - -interface HTMLTrackElement extends HTMLElement { - kind: string; - src: string; - srclang: string; - track: TextTrack; - label: string; - default: boolean; - readyState: number; - ERROR: number; - LOADING: number; - LOADED: number; - NONE: number; -} -declare var HTMLTrackElement: { - prototype: HTMLTrackElement; - new(): HTMLTrackElement; - ERROR: number; - LOADING: number; - LOADED: number; - NONE: number; -} - -interface MSApp { - createFileFromStorageFile(storageFile: any): File; - createBlobFromRandomAccessStream(type: string, seeker: any): Blob; - createStreamFromInputStream(type: string, inputStream: any): MSStream; - terminateApp(exceptionObject: any): void; - createDataPackage(object: any): any; - execUnsafeLocalFunction(unsafeFunction: MSUnsafeFunctionCallback): any; - getHtmlPrintDocumentSource(htmlDoc: any): any; - addPublicLocalApplicationUri(uri: string): void; - createDataPackageFromSelection(): any; - getViewOpener(): MSAppView; - suppressSubdownloadCredentialPrompts(suppress: boolean): void; - execAsyncAtPriority(asynchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): void; - isTaskScheduledAtPriorityOrHigher(priority: string): boolean; - execAtPriority(synchronousCallback: MSExecAtPriorityFunctionCallback, priority: string, ...args: any[]): any; - createNewView(uri: string): MSAppView; - getCurrentPriority(): string; - NORMAL: string; - HIGH: string; - IDLE: string; - CURRENT: string; -} -declare var MSApp: MSApp; - -interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - in1: SVGAnimatedString; -} -declare var SVGFEComponentTransferElement: { - prototype: SVGFEComponentTransferElement; - new(): SVGFEComponentTransferElement; -} - -interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { - kernelUnitLengthY: SVGAnimatedNumber; - surfaceScale: SVGAnimatedNumber; - in1: SVGAnimatedString; - kernelUnitLengthX: SVGAnimatedNumber; - diffuseConstant: SVGAnimatedNumber; -} -declare var SVGFEDiffuseLightingElement: { - prototype: SVGFEDiffuseLightingElement; - new(): SVGFEDiffuseLightingElement; -} - -interface MSCSSMatrix { - m24: number; - m34: number; - a: number; - d: number; - m32: number; - m41: number; - m11: number; - f: number; - e: number; - m23: number; - m14: number; - m33: number; - m22: number; - m21: number; - c: number; - m12: number; - b: number; - m42: number; - m31: number; - m43: number; - m13: number; - m44: number; - multiply(secondMatrix: MSCSSMatrix): MSCSSMatrix; - skewY(angle: number): MSCSSMatrix; - setMatrixValue(value: string): void; - inverse(): MSCSSMatrix; - rotateAxisAngle(x: number, y: number, z: number, angle: number): MSCSSMatrix; - toString(): string; - rotate(angleX: number, angleY?: number, angleZ?: number): MSCSSMatrix; - translate(x: number, y: number, z?: number): MSCSSMatrix; - scale(scaleX: number, scaleY?: number, scaleZ?: number): MSCSSMatrix; - skewX(angle: number): MSCSSMatrix; -} -declare var MSCSSMatrix: { - prototype: MSCSSMatrix; - new(text?: string): MSCSSMatrix; -} - -interface Worker extends AbstractWorker { - onmessage: (ev: MessageEvent) => any; - postMessage(message: any, ports?: any): void; - terminate(): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var Worker: { - prototype: Worker; - new(stringUrl: string): Worker; -} - -interface MSExecAtPriorityFunctionCallback { - (...args: any[]): any; -} - -interface MSGraphicsTrust { - status: string; - constrictionActive: boolean; -} -declare var MSGraphicsTrust: { - prototype: MSGraphicsTrust; - new(): MSGraphicsTrust; -} - -interface SubtleCrypto { - unwrapKey(wrappedKey: ArrayBufferView, keyAlgorithm: any, keyEncryptionKey: Key, extractable?: boolean, keyUsages?: string[]): KeyOperation; - encrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; - importKey(format: string, keyData: ArrayBufferView, algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - wrapKey(key: Key, keyEncryptionKey: Key, keyWrappingAlgorithm: any): KeyOperation; - verify(algorithm: any, key: Key, signature: ArrayBufferView, buffer?: ArrayBufferView): CryptoOperation; - deriveKey(algorithm: any, baseKey: Key, derivedKeyType: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - digest(algorithm: any, buffer?: ArrayBufferView): CryptoOperation; - exportKey(format: string, key: Key): KeyOperation; - generateKey(algorithm: any, extractable?: boolean, keyUsages?: string[]): KeyOperation; - sign(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; - decrypt(algorithm: any, key: Key, buffer?: ArrayBufferView): CryptoOperation; -} -declare var SubtleCrypto: { - prototype: SubtleCrypto; - new(): SubtleCrypto; -} - -interface Crypto extends RandomSource { - subtle: SubtleCrypto; -} -declare var Crypto: { - prototype: Crypto; - new(): Crypto; -} - -interface VideoPlaybackQuality { - totalFrameDelay: number; - creationTime: number; - totalVideoFrames: number; - droppedVideoFrames: number; -} -declare var VideoPlaybackQuality: { - prototype: VideoPlaybackQuality; - new(): VideoPlaybackQuality; -} - -interface GlobalEventHandlers { - onpointerenter: (ev: PointerEvent) => any; - onpointerout: (ev: PointerEvent) => any; - onpointerdown: (ev: PointerEvent) => any; - onpointerup: (ev: PointerEvent) => any; - onpointercancel: (ev: PointerEvent) => any; - onpointerover: (ev: PointerEvent) => any; - onpointermove: (ev: PointerEvent) => any; - onpointerleave: (ev: PointerEvent) => any; - addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} - -interface Key { - algorithm: Algorithm; - type: string; - extractable: boolean; - keyUsage: string[]; -} -declare var Key: { - prototype: Key; - new(): Key; -} - -interface DeviceAcceleration { - y: number; - x: number; - z: number; -} -declare var DeviceAcceleration: { - prototype: DeviceAcceleration; - new(): DeviceAcceleration; -} - -interface HTMLAllCollection extends HTMLCollection { - namedItem(name: string): Element; - // [name: string]: Element; -} -declare var HTMLAllCollection: { - prototype: HTMLAllCollection; - new(): HTMLAllCollection; -} - -interface AesGcmEncryptResult { - ciphertext: ArrayBuffer; - tag: ArrayBuffer; -} -declare var AesGcmEncryptResult: { - prototype: AesGcmEncryptResult; - new(): AesGcmEncryptResult; -} - -interface NavigationCompletedEvent extends NavigationEvent { - webErrorStatus: number; - isSuccess: boolean; -} -declare var NavigationCompletedEvent: { - prototype: NavigationCompletedEvent; - new(): NavigationCompletedEvent; -} - -interface MutationRecord { - oldValue: string; - previousSibling: Node; - addedNodes: NodeList; - attributeName: string; - removedNodes: NodeList; - target: Node; - nextSibling: Node; - attributeNamespace: string; - type: string; -} -declare var MutationRecord: { - prototype: MutationRecord; - new(): MutationRecord; -} - -interface MimeTypeArray { - length: number; - item(index: number): Plugin; - [index: number]: Plugin; - namedItem(type: string): Plugin; - // [type: string]: Plugin; -} -declare var MimeTypeArray: { - prototype: MimeTypeArray; - new(): MimeTypeArray; -} - -interface KeyOperation extends EventTarget { - oncomplete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - result: any; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var KeyOperation: { - prototype: KeyOperation; - new(): KeyOperation; -} - -interface DOMStringMap { -} -declare var DOMStringMap: { - prototype: DOMStringMap; - new(): DOMStringMap; -} - -interface DeviceOrientationEvent extends Event { - gamma: number; - alpha: number; - absolute: boolean; - beta: number; - initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number, beta: number, gamma: number, absolute: boolean): void; -} -declare var DeviceOrientationEvent: { - prototype: DeviceOrientationEvent; - new(): DeviceOrientationEvent; -} - -interface MSMediaKeys { - keySystem: string; - createSession(type: string, initData: Uint8Array, cdmData?: Uint8Array): MSMediaKeySession; -} -declare var MSMediaKeys: { - prototype: MSMediaKeys; - new(keySystem: string): MSMediaKeys; - isTypeSupported(keySystem: string, type?: string): boolean; -} - -interface MSMediaKeyMessageEvent extends Event { - destinationURL: string; - message: Uint8Array; -} -declare var MSMediaKeyMessageEvent: { - prototype: MSMediaKeyMessageEvent; - new(): MSMediaKeyMessageEvent; -} - -interface MSHTMLWebViewElement extends HTMLElement { - documentTitle: string; - width: number; - src: string; - canGoForward: boolean; - height: number; - canGoBack: boolean; - navigateWithHttpRequestMessage(requestMessage: any): void; - goBack(): void; - navigate(uri: string): void; - stop(): void; - navigateToString(contents: string): void; - captureSelectedContentToDataPackageAsync(): MSWebViewAsyncOperation; - capturePreviewToBlobAsync(): MSWebViewAsyncOperation; - refresh(): void; - goForward(): void; - navigateToLocalStreamUri(source: string, streamResolver: any): void; - invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; - buildLocalStreamUri(contentIdentifier: string, relativePath: string): string; -} -declare var MSHTMLWebViewElement: { - prototype: MSHTMLWebViewElement; - new(): MSHTMLWebViewElement; -} - -interface NavigationEvent extends Event { - uri: string; -} -declare var NavigationEvent: { - prototype: NavigationEvent; - new(): NavigationEvent; -} - -interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; -} - -interface SourceBuffer extends EventTarget { - updating: boolean; - appendWindowStart: number; - appendWindowEnd: number; - buffered: TimeRanges; - timestampOffset: number; - audioTracks: AudioTrackList; - appendBuffer(data: ArrayBuffer): void; - remove(start: number, end: number): void; - abort(): void; - appendStream(stream: MSStream, maxSize?: number): void; -} -declare var SourceBuffer: { - prototype: SourceBuffer; - new(): SourceBuffer; -} - -interface MSInputMethodContext extends EventTarget { - oncandidatewindowshow: (ev: any) => any; - target: HTMLElement; - compositionStartOffset: number; - oncandidatewindowhide: (ev: any) => any; - oncandidatewindowupdate: (ev: any) => any; - compositionEndOffset: number; - getCompositionAlternatives(): string[]; - getCandidateWindowClientRect(): ClientRect; - hasComposition(): boolean; - isCandidateWindowVisible(): boolean; - addEventListener(type: "candidatewindowshow", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "candidatewindowhide", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: "candidatewindowupdate", listener: (ev: any) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MSInputMethodContext: { - prototype: MSInputMethodContext; - new(): MSInputMethodContext; -} - -interface DeviceRotationRate { - gamma: number; - alpha: number; - beta: number; -} -declare var DeviceRotationRate: { - prototype: DeviceRotationRate; - new(): DeviceRotationRate; -} - -interface PluginArray { - length: number; - refresh(reload?: boolean): void; - item(index: number): Plugin; - [index: number]: Plugin; - namedItem(name: string): Plugin; - // [name: string]: Plugin; -} -declare var PluginArray: { - prototype: PluginArray; - new(): PluginArray; -} - -interface MSMediaKeyError { - systemCode: number; - code: number; - MS_MEDIA_KEYERR_SERVICE: number; - MS_MEDIA_KEYERR_HARDWARECHANGE: number; - MS_MEDIA_KEYERR_OUTPUT: number; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_UNKNOWN: number; - MS_MEDIA_KEYERR_CLIENT: number; -} -declare var MSMediaKeyError: { - prototype: MSMediaKeyError; - new(): MSMediaKeyError; - MS_MEDIA_KEYERR_SERVICE: number; - MS_MEDIA_KEYERR_HARDWARECHANGE: number; - MS_MEDIA_KEYERR_OUTPUT: number; - MS_MEDIA_KEYERR_DOMAIN: number; - MS_MEDIA_KEYERR_UNKNOWN: number; - MS_MEDIA_KEYERR_CLIENT: number; -} - -interface Plugin { - length: number; - filename: string; - version: string; - name: string; - description: string; - item(index: number): MimeType; - [index: number]: MimeType; - namedItem(type: string): MimeType; - // [type: string]: MimeType; -} -declare var Plugin: { - prototype: Plugin; - new(): Plugin; -} - -interface MediaSource extends EventTarget { - sourceBuffers: SourceBufferList; - duration: number; - readyState: string; - activeSourceBuffers: SourceBufferList; - addSourceBuffer(type: string): SourceBuffer; - endOfStream(error?: string): void; - removeSourceBuffer(sourceBuffer: SourceBuffer): void; -} -declare var MediaSource: { - prototype: MediaSource; - new(): MediaSource; - isTypeSupported(type: string): boolean; -} - -interface SourceBufferList extends EventTarget { - length: number; - item(index: number): SourceBuffer; - [index: number]: SourceBuffer; -} -declare var SourceBufferList: { - prototype: SourceBufferList; - new(): SourceBufferList; -} - -interface XMLDocument extends Document { -} -declare var XMLDocument: { - prototype: XMLDocument; - new(): XMLDocument; -} - -interface DeviceMotionEvent extends Event { - rotationRate: DeviceRotationRate; - acceleration: DeviceAcceleration; - interval: number; - accelerationIncludingGravity: DeviceAcceleration; - initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict, accelerationIncludingGravity: DeviceAccelerationDict, rotationRate: DeviceRotationRateDict, interval: number): void; -} -declare var DeviceMotionEvent: { - prototype: DeviceMotionEvent; - new(): DeviceMotionEvent; -} - -interface MimeType { - enabledPlugin: Plugin; - suffixes: string; - type: string; - description: string; -} -declare var MimeType: { - prototype: MimeType; - new(): MimeType; -} - -interface PointerEvent extends MouseEvent { - width: number; - rotation: number; - pressure: number; - pointerType: any; - isPrimary: boolean; - tiltY: number; - height: number; - intermediatePoints: any; - currentPoint: any; - tiltX: number; - hwTimestamp: number; - pointerId: number; - initPointerEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, screenXArg: number, screenYArg: number, clientXArg: number, clientYArg: number, ctrlKeyArg: boolean, altKeyArg: boolean, shiftKeyArg: boolean, metaKeyArg: boolean, buttonArg: number, relatedTargetArg: EventTarget, offsetXArg: number, offsetYArg: number, widthArg: number, heightArg: number, pressure: number, rotation: number, tiltX: number, tiltY: number, pointerIdArg: number, pointerType: any, hwTimestampArg: number, isPrimary: boolean): void; - getCurrentPoint(element: Element): void; - getIntermediatePoints(element: Element): void; -} -declare var PointerEvent: { - prototype: PointerEvent; - new(): PointerEvent; -} - -interface MSDocumentExtensions { - captureEvents(): void; - releaseEvents(): void; -} - -interface MutationObserver { - observe(target: Node, options: MutationObserverInit): void; - takeRecords(): MutationRecord[]; - disconnect(): void; -} -declare var MutationObserver: { - prototype: MutationObserver; - new (callback: (arr: MutationRecord[], observer: MutationObserver)=>any): MutationObserver; -} - -interface MSWebViewAsyncOperation extends EventTarget { - target: MSHTMLWebViewElement; - oncomplete: (ev: Event) => any; - error: DOMError; - onerror: (ev: ErrorEvent) => any; - readyState: number; - type: number; - result: any; - start(): void; - ERROR: number; - TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; - TYPE_INVOKE_SCRIPT: number; - COMPLETED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - STARTED: number; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var MSWebViewAsyncOperation: { - prototype: MSWebViewAsyncOperation; - new(): MSWebViewAsyncOperation; - ERROR: number; - TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; - TYPE_INVOKE_SCRIPT: number; - COMPLETED: number; - TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; - STARTED: number; -} - -interface ScriptNotifyEvent extends Event { - value: string; - callingUri: string; -} -declare var ScriptNotifyEvent: { - prototype: ScriptNotifyEvent; - new(): ScriptNotifyEvent; -} - -interface PerformanceNavigationTiming extends PerformanceEntry { - redirectStart: number; - domainLookupEnd: number; - responseStart: number; - domComplete: number; - domainLookupStart: number; - loadEventStart: number; - unloadEventEnd: number; - fetchStart: number; - requestStart: number; - domInteractive: number; - navigationStart: number; - connectEnd: number; - loadEventEnd: number; - connectStart: number; - responseEnd: number; - domLoading: number; - redirectEnd: number; - redirectCount: number; - unloadEventStart: number; - domContentLoadedEventStart: number; - domContentLoadedEventEnd: number; - type: string; -} -declare var PerformanceNavigationTiming: { - prototype: PerformanceNavigationTiming; - new(): PerformanceNavigationTiming; -} - -interface MSMediaKeyNeededEvent extends Event { - initData: Uint8Array; -} -declare var MSMediaKeyNeededEvent: { - prototype: MSMediaKeyNeededEvent; - new(): MSMediaKeyNeededEvent; -} - -interface LongRunningScriptDetectedEvent extends Event { - stopPageScriptExecution: boolean; - executionTime: number; -} -declare var LongRunningScriptDetectedEvent: { - prototype: LongRunningScriptDetectedEvent; - new(): LongRunningScriptDetectedEvent; -} - -interface MSAppView { - viewId: number; - close(): void; - postMessage(message: any, targetOrigin: string, ports?: any): void; -} -declare var MSAppView: { - prototype: MSAppView; - new(): MSAppView; -} - -interface PerfWidgetExternal { - maxCpuSpeed: number; - independentRenderingEnabled: boolean; - irDisablingContentString: string; - irStatusAvailable: boolean; - performanceCounter: number; - averagePaintTime: number; - activeNetworkRequestCount: number; - paintRequestsPerSecond: number; - extraInformationEnabled: boolean; - performanceCounterFrequency: number; - averageFrameTime: number; - repositionWindow(x: number, y: number): void; - getRecentMemoryUsage(last: number): any; - getMemoryUsage(): number; - resizeWindow(width: number, height: number): void; - getProcessCpuUsage(): number; - removeEventListener(eventType: string, callback: (ev: any) => any): void; - getRecentCpuUsage(last: number): any; - addEventListener(eventType: string, callback: (ev: any) => any): void; - getRecentFrames(last: number): any; - getRecentPaintRequests(last: number): any; -} -declare var PerfWidgetExternal: { - prototype: PerfWidgetExternal; - new(): PerfWidgetExternal; -} - -interface PageTransitionEvent extends Event { - persisted: boolean; -} -declare var PageTransitionEvent: { - prototype: PageTransitionEvent; - new(): PageTransitionEvent; -} - -interface MutationCallback { - (mutations: MutationRecord[], observer: MutationObserver): void; -} - -interface HTMLDocument extends Document { -} -declare var HTMLDocument: { - prototype: HTMLDocument; - new(): HTMLDocument; -} - -interface KeyPair { - privateKey: Key; - publicKey: Key; -} -declare var KeyPair: { - prototype: KeyPair; - new(): KeyPair; -} - -interface MSMediaKeySession extends EventTarget { - sessionId: string; - error: MSMediaKeyError; - keySystem: string; - close(): void; - update(key: Uint8Array): void; -} -declare var MSMediaKeySession: { - prototype: MSMediaKeySession; - new(): MSMediaKeySession; -} - -interface UnviewableContentIdentifiedEvent extends NavigationEvent { - referrer: string; -} -declare var UnviewableContentIdentifiedEvent: { - prototype: UnviewableContentIdentifiedEvent; - new(): UnviewableContentIdentifiedEvent; -} - -interface CryptoOperation extends EventTarget { - algorithm: Algorithm; - oncomplete: (ev: Event) => any; - onerror: (ev: ErrorEvent) => any; - onprogress: (ev: ProgressEvent) => any; - onabort: (ev: UIEvent) => any; - key: Key; - result: any; - abort(): void; - finish(): void; - process(buffer: ArrayBufferView): void; - addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void; - addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void; - addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; - addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -} -declare var CryptoOperation: { - prototype: CryptoOperation; - new(): CryptoOperation; -} - -interface WebGLTexture extends WebGLObject { -} -declare var WebGLTexture: { - prototype: WebGLTexture; - new(): WebGLTexture; -} - -interface OES_texture_float { -} -declare var OES_texture_float: { - prototype: OES_texture_float; - new(): OES_texture_float; -} - -interface WebGLContextEvent extends Event { - statusMessage: string; -} -declare var WebGLContextEvent: { - prototype: WebGLContextEvent; - new(): WebGLContextEvent; -} - -interface WebGLRenderbuffer extends WebGLObject { -} -declare var WebGLRenderbuffer: { - prototype: WebGLRenderbuffer; - new(): WebGLRenderbuffer; -} - -interface WebGLUniformLocation { -} -declare var WebGLUniformLocation: { - prototype: WebGLUniformLocation; - new(): WebGLUniformLocation; -} - -interface WebGLActiveInfo { - name: string; - type: number; - size: number; -} -declare var WebGLActiveInfo: { - prototype: WebGLActiveInfo; - new(): WebGLActiveInfo; -} - -interface WEBGL_compressed_texture_s3tc { - COMPRESSED_RGBA_S3TC_DXT1_EXT: number; - COMPRESSED_RGBA_S3TC_DXT5_EXT: number; - COMPRESSED_RGBA_S3TC_DXT3_EXT: number; - COMPRESSED_RGB_S3TC_DXT1_EXT: number; -} -declare var WEBGL_compressed_texture_s3tc: { - prototype: WEBGL_compressed_texture_s3tc; - new(): WEBGL_compressed_texture_s3tc; - COMPRESSED_RGBA_S3TC_DXT1_EXT: number; - COMPRESSED_RGBA_S3TC_DXT5_EXT: number; - COMPRESSED_RGBA_S3TC_DXT3_EXT: number; - COMPRESSED_RGB_S3TC_DXT1_EXT: number; -} - -interface WebGLRenderingContext { - drawingBufferWidth: number; - drawingBufferHeight: number; - canvas: HTMLCanvasElement; - getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation; - bindTexture(target: number, texture: WebGLTexture): void; - bufferData(target: number, data: ArrayBufferView, usage: number): void; - bufferData(target: number, data: ArrayBuffer, usage: number): void; - bufferData(target: number, size: number, usage: number): void; - depthMask(flag: boolean): void; - getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; - vertexAttrib3fv(indx: number, values: number[]): void; - vertexAttrib3fv(indx: number, values: Float32Array): void; - linkProgram(program: WebGLProgram): void; - getSupportedExtensions(): string[]; - bufferSubData(target: number, offset: number, data: ArrayBuffer): void; - bufferSubData(target: number, offset: number, data: ArrayBufferView): void; - vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; - polygonOffset(factor: number, units: number): void; - blendColor(red: number, green: number, blue: number, alpha: number): void; - createTexture(): WebGLTexture; - hint(target: number, mode: number): void; - getVertexAttrib(index: number, pname: number): any; - enableVertexAttribArray(index: number): void; - depthRange(zNear: number, zFar: number): void; - cullFace(mode: number): void; - createFramebuffer(): WebGLFramebuffer; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; - uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; - framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; - deleteFramebuffer(framebuffer: WebGLFramebuffer): void; - colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; - compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; - uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; - getExtension(name: string): any; - createProgram(): WebGLProgram; - deleteShader(shader: WebGLShader): void; - getAttachedShaders(program: WebGLProgram): WebGLShader[]; - enable(cap: number): void; - blendEquation(mode: number): void; - texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; - texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; - texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; - texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; - texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; - createBuffer(): WebGLBuffer; - deleteTexture(texture: WebGLTexture): void; - useProgram(program: WebGLProgram): void; - vertexAttrib2fv(indx: number, values: number[]): void; - vertexAttrib2fv(indx: number, values: Float32Array): void; - checkFramebufferStatus(target: number): number; - frontFace(mode: number): void; - getBufferParameter(target: number, pname: number): any; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; - copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; - getVertexAttribOffset(index: number, pname: number): number; - disableVertexAttribArray(index: number): void; - blendFunc(sfactor: number, dfactor: number): void; - drawElements(mode: number, count: number, type: number, offset: number): void; - isFramebuffer(framebuffer: WebGLFramebuffer): boolean; - uniform3iv(location: WebGLUniformLocation, v: number[]): void; - uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; - lineWidth(width: number): void; - getShaderInfoLog(shader: WebGLShader): string; - getTexParameter(target: number, pname: number): any; - getParameter(pname: number): any; - getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat; - getContextAttributes(): WebGLContextAttributes; - vertexAttrib1f(indx: number, x: number): void; - bindFramebuffer(target: number, framebuffer: WebGLFramebuffer): void; - compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; - isContextLost(): boolean; - uniform1iv(location: WebGLUniformLocation, v: number[]): void; - uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; - getRenderbufferParameter(target: number, pname: number): any; - uniform2fv(location: WebGLUniformLocation, v: number[]): void; - uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; - isTexture(texture: WebGLTexture): boolean; - getError(): number; - shaderSource(shader: WebGLShader, source: string): void; - deleteRenderbuffer(renderbuffer: WebGLRenderbuffer): void; - stencilMask(mask: number): void; - bindBuffer(target: number, buffer: WebGLBuffer): void; - getAttribLocation(program: WebGLProgram, name: string): number; - uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; - blendEquationSeparate(modeRGB: number, modeAlpha: number): void; - clear(mask: number): void; - blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; - stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; - readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; - scissor(x: number, y: number, width: number, height: number): void; - uniform2i(location: WebGLUniformLocation, x: number, y: number): void; - getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; - getShaderSource(shader: WebGLShader): string; - generateMipmap(target: number): void; - bindAttribLocation(program: WebGLProgram, index: number, name: string): void; - uniform1fv(location: WebGLUniformLocation, v: number[]): void; - uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; - uniform2iv(location: WebGLUniformLocation, v: number[]): void; - uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; - stencilOp(fail: number, zfail: number, zpass: number): void; - uniform4fv(location: WebGLUniformLocation, v: number[]): void; - uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; - vertexAttrib1fv(indx: number, values: number[]): void; - vertexAttrib1fv(indx: number, values: Float32Array): void; - flush(): void; - uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - deleteProgram(program: WebGLProgram): void; - isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; - uniform1i(location: WebGLUniformLocation, x: number): void; - getProgramParameter(program: WebGLProgram, pname: number): any; - getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; - stencilFunc(func: number, ref: number, mask: number): void; - pixelStorei(pname: number, param: number): void; - disable(cap: number): void; - vertexAttrib4fv(indx: number, values: number[]): void; - vertexAttrib4fv(indx: number, values: Float32Array): void; - createRenderbuffer(): WebGLRenderbuffer; - isBuffer(buffer: WebGLBuffer): boolean; - stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; - getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): any; - uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; - sampleCoverage(value: number, invert: boolean): void; - depthFunc(func: number): void; - texParameterf(target: number, pname: number, param: number): void; - vertexAttrib3f(indx: number, x: number, y: number, z: number): void; - drawArrays(mode: number, first: number, count: number): void; - texParameteri(target: number, pname: number, param: number): void; - vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; - getShaderParameter(shader: WebGLShader, pname: number): any; - clearDepth(depth: number): void; - activeTexture(texture: number): void; - viewport(x: number, y: number, width: number, height: number): void; - detachShader(program: WebGLProgram, shader: WebGLShader): void; - uniform1f(location: WebGLUniformLocation, x: number): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; - uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; - deleteBuffer(buffer: WebGLBuffer): void; - copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; - uniform3fv(location: WebGLUniformLocation, v: number[]): void; - uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; - stencilMaskSeparate(face: number, mask: number): void; - attachShader(program: WebGLProgram, shader: WebGLShader): void; - compileShader(shader: WebGLShader): void; - clearColor(red: number, green: number, blue: number, alpha: number): void; - isShader(shader: WebGLShader): boolean; - clearStencil(s: number): void; - framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; - finish(): void; - uniform2f(location: WebGLUniformLocation, x: number, y: number): void; - renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; - uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; - getProgramInfoLog(program: WebGLProgram): string; - validateProgram(program: WebGLProgram): void; - isEnabled(cap: number): boolean; - vertexAttrib2f(indx: number, x: number, y: number): void; - isProgram(program: WebGLProgram): boolean; - createShader(type: number): WebGLShader; - bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer): void; - uniform4iv(location: WebGLUniformLocation, v: number[]): void; - uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; - DEPTH_FUNC: number; - DEPTH_COMPONENT16: number; - REPLACE: number; - REPEAT: number; - VERTEX_ATTRIB_ARRAY_ENABLED: number; - FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; - STENCIL_BUFFER_BIT: number; - RENDERER: number; - STENCIL_BACK_REF: number; - TEXTURE26: number; - RGB565: number; - DITHER: number; - CONSTANT_COLOR: number; - GENERATE_MIPMAP_HINT: number; - POINTS: number; - DECR: number; - INT_VEC3: number; - TEXTURE28: number; - ONE_MINUS_CONSTANT_ALPHA: number; - BACK: number; - RENDERBUFFER_STENCIL_SIZE: number; - UNPACK_FLIP_Y_WEBGL: number; - BLEND: number; - TEXTURE9: number; - ARRAY_BUFFER_BINDING: number; - MAX_VIEWPORT_DIMS: number; - INVALID_FRAMEBUFFER_OPERATION: number; - TEXTURE: number; - TEXTURE0: number; - TEXTURE31: number; - TEXTURE24: number; - HIGH_INT: number; - RENDERBUFFER_BINDING: number; - BLEND_COLOR: number; - FASTEST: number; - STENCIL_WRITEMASK: number; - ALIASED_POINT_SIZE_RANGE: number; - TEXTURE12: number; - DST_ALPHA: number; - BLEND_EQUATION_RGB: number; - FRAMEBUFFER_COMPLETE: number; - NEAREST_MIPMAP_NEAREST: number; - VERTEX_ATTRIB_ARRAY_SIZE: number; - TEXTURE3: number; - DEPTH_WRITEMASK: number; - CONTEXT_LOST_WEBGL: number; - INVALID_VALUE: number; - TEXTURE_MAG_FILTER: number; - ONE_MINUS_CONSTANT_COLOR: number; - ONE_MINUS_SRC_ALPHA: number; - TEXTURE_CUBE_MAP_POSITIVE_Z: number; - NOTEQUAL: number; - ALPHA: number; - DEPTH_STENCIL: number; - MAX_VERTEX_UNIFORM_VECTORS: number; - DEPTH_COMPONENT: number; - RENDERBUFFER_RED_SIZE: number; - TEXTURE20: number; - RED_BITS: number; - RENDERBUFFER_BLUE_SIZE: number; - SCISSOR_BOX: number; - VENDOR: number; - FRONT_AND_BACK: number; - CONSTANT_ALPHA: number; - VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; - NEAREST: number; - CULL_FACE: number; - ALIASED_LINE_WIDTH_RANGE: number; - TEXTURE19: number; - FRONT: number; - DEPTH_CLEAR_VALUE: number; - GREEN_BITS: number; - TEXTURE29: number; - TEXTURE23: number; - MAX_RENDERBUFFER_SIZE: number; - STENCIL_ATTACHMENT: number; - TEXTURE27: number; - BOOL_VEC2: number; - OUT_OF_MEMORY: number; - MIRRORED_REPEAT: number; - POLYGON_OFFSET_UNITS: number; - TEXTURE_MIN_FILTER: number; - STENCIL_BACK_PASS_DEPTH_PASS: number; - LINE_LOOP: number; - FLOAT_MAT3: number; - TEXTURE14: number; - LINEAR: number; - RGB5_A1: number; - ONE_MINUS_SRC_COLOR: number; - SAMPLE_COVERAGE_INVERT: number; - DONT_CARE: number; - FRAMEBUFFER_BINDING: number; - RENDERBUFFER_ALPHA_SIZE: number; - STENCIL_REF: number; - ZERO: number; - DECR_WRAP: number; - SAMPLE_COVERAGE: number; - STENCIL_BACK_FUNC: number; - TEXTURE30: number; - VIEWPORT: number; - STENCIL_BITS: number; - FLOAT: number; - COLOR_WRITEMASK: number; - SAMPLE_COVERAGE_VALUE: number; - TEXTURE_CUBE_MAP_NEGATIVE_Y: number; - STENCIL_BACK_FAIL: number; - FLOAT_MAT4: number; - UNSIGNED_SHORT_4_4_4_4: number; - TEXTURE6: number; - RENDERBUFFER_WIDTH: number; - RGBA4: number; - ALWAYS: number; - BLEND_EQUATION_ALPHA: number; - COLOR_BUFFER_BIT: number; - TEXTURE_CUBE_MAP: number; - DEPTH_BUFFER_BIT: number; - STENCIL_CLEAR_VALUE: number; - BLEND_EQUATION: number; - RENDERBUFFER_GREEN_SIZE: number; - NEAREST_MIPMAP_LINEAR: number; - VERTEX_ATTRIB_ARRAY_TYPE: number; - INCR_WRAP: number; - ONE_MINUS_DST_COLOR: number; - HIGH_FLOAT: number; - BYTE: number; - FRONT_FACE: number; - SAMPLE_ALPHA_TO_COVERAGE: number; - CCW: number; - TEXTURE13: number; - MAX_VERTEX_ATTRIBS: number; - MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; - TEXTURE_WRAP_T: number; - UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; - FLOAT_VEC2: number; - LUMINANCE: number; - GREATER: number; - INT_VEC2: number; - VALIDATE_STATUS: number; - FRAMEBUFFER: number; - FRAMEBUFFER_UNSUPPORTED: number; - TEXTURE5: number; - FUNC_SUBTRACT: number; - BLEND_DST_ALPHA: number; - SAMPLER_CUBE: number; - ONE_MINUS_DST_ALPHA: number; - LESS: number; - TEXTURE_CUBE_MAP_POSITIVE_X: number; - BLUE_BITS: number; - DEPTH_TEST: number; - VERTEX_ATTRIB_ARRAY_STRIDE: number; - DELETE_STATUS: number; - TEXTURE18: number; - POLYGON_OFFSET_FACTOR: number; - UNSIGNED_INT: number; - TEXTURE_2D: number; - DST_COLOR: number; - FLOAT_MAT2: number; - COMPRESSED_TEXTURE_FORMATS: number; - MAX_FRAGMENT_UNIFORM_VECTORS: number; - DEPTH_STENCIL_ATTACHMENT: number; - LUMINANCE_ALPHA: number; - CW: number; - VERTEX_ATTRIB_ARRAY_NORMALIZED: number; - TEXTURE_CUBE_MAP_NEGATIVE_Z: number; - LINEAR_MIPMAP_LINEAR: number; - BUFFER_SIZE: number; - SAMPLE_BUFFERS: number; - TEXTURE15: number; - ACTIVE_TEXTURE: number; - VERTEX_SHADER: number; - TEXTURE22: number; - VERTEX_ATTRIB_ARRAY_POINTER: number; - INCR: number; - COMPILE_STATUS: number; - MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; - TEXTURE7: number; - UNSIGNED_SHORT_5_5_5_1: number; - DEPTH_BITS: number; - RGBA: number; - TRIANGLE_STRIP: number; - COLOR_CLEAR_VALUE: number; - BROWSER_DEFAULT_WEBGL: number; - INVALID_ENUM: number; - SCISSOR_TEST: number; - LINE_STRIP: number; - FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; - STENCIL_FUNC: number; - FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; - RENDERBUFFER_HEIGHT: number; - TEXTURE8: number; - TRIANGLES: number; - FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; - STENCIL_BACK_VALUE_MASK: number; - TEXTURE25: number; - RENDERBUFFER: number; - LEQUAL: number; - TEXTURE1: number; - STENCIL_INDEX8: number; - FUNC_ADD: number; - STENCIL_FAIL: number; - BLEND_SRC_ALPHA: number; - BOOL: number; - ALPHA_BITS: number; - LOW_INT: number; - TEXTURE10: number; - SRC_COLOR: number; - MAX_VARYING_VECTORS: number; - BLEND_DST_RGB: number; - TEXTURE_BINDING_CUBE_MAP: number; - STENCIL_INDEX: number; - TEXTURE_BINDING_2D: number; - MEDIUM_INT: number; - SHADER_TYPE: number; - POLYGON_OFFSET_FILL: number; - DYNAMIC_DRAW: number; - TEXTURE4: number; - STENCIL_BACK_PASS_DEPTH_FAIL: number; - STREAM_DRAW: number; - MAX_CUBE_MAP_TEXTURE_SIZE: number; - TEXTURE17: number; - TRIANGLE_FAN: number; - UNPACK_ALIGNMENT: number; - CURRENT_PROGRAM: number; - LINES: number; - INVALID_OPERATION: number; - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; - LINEAR_MIPMAP_NEAREST: number; - CLAMP_TO_EDGE: number; - RENDERBUFFER_DEPTH_SIZE: number; - TEXTURE_WRAP_S: number; - ELEMENT_ARRAY_BUFFER: number; - UNSIGNED_SHORT_5_6_5: number; - ACTIVE_UNIFORMS: number; - FLOAT_VEC3: number; - NO_ERROR: number; - ATTACHED_SHADERS: number; - DEPTH_ATTACHMENT: number; - TEXTURE11: number; - STENCIL_TEST: number; - ONE: number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; - STATIC_DRAW: number; - GEQUAL: number; - BOOL_VEC4: number; - COLOR_ATTACHMENT0: number; - PACK_ALIGNMENT: number; - MAX_TEXTURE_SIZE: number; - STENCIL_PASS_DEPTH_FAIL: number; - CULL_FACE_MODE: number; - TEXTURE16: number; - STENCIL_BACK_WRITEMASK: number; - SRC_ALPHA: number; - UNSIGNED_SHORT: number; - TEXTURE21: number; - FUNC_REVERSE_SUBTRACT: number; - SHADING_LANGUAGE_VERSION: number; - EQUAL: number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; - BOOL_VEC3: number; - SAMPLER_2D: number; - TEXTURE_CUBE_MAP_NEGATIVE_X: number; - MAX_TEXTURE_IMAGE_UNITS: number; - TEXTURE_CUBE_MAP_POSITIVE_Y: number; - RENDERBUFFER_INTERNAL_FORMAT: number; - STENCIL_VALUE_MASK: number; - ELEMENT_ARRAY_BUFFER_BINDING: number; - ARRAY_BUFFER: number; - DEPTH_RANGE: number; - NICEST: number; - ACTIVE_ATTRIBUTES: number; - NEVER: number; - FLOAT_VEC4: number; - CURRENT_VERTEX_ATTRIB: number; - STENCIL_PASS_DEPTH_PASS: number; - INVERT: number; - LINK_STATUS: number; - RGB: number; - INT_VEC4: number; - TEXTURE2: number; - UNPACK_COLORSPACE_CONVERSION_WEBGL: number; - MEDIUM_FLOAT: number; - SRC_ALPHA_SATURATE: number; - BUFFER_USAGE: number; - SHORT: number; - NONE: number; - UNSIGNED_BYTE: number; - INT: number; - SUBPIXEL_BITS: number; - KEEP: number; - SAMPLES: number; - FRAGMENT_SHADER: number; - LINE_WIDTH: number; - BLEND_SRC_RGB: number; - LOW_FLOAT: number; - VERSION: number; -} -declare var WebGLRenderingContext: { - prototype: WebGLRenderingContext; - new(): WebGLRenderingContext; - DEPTH_FUNC: number; - DEPTH_COMPONENT16: number; - REPLACE: number; - REPEAT: number; - VERTEX_ATTRIB_ARRAY_ENABLED: number; - FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; - STENCIL_BUFFER_BIT: number; - RENDERER: number; - STENCIL_BACK_REF: number; - TEXTURE26: number; - RGB565: number; - DITHER: number; - CONSTANT_COLOR: number; - GENERATE_MIPMAP_HINT: number; - POINTS: number; - DECR: number; - INT_VEC3: number; - TEXTURE28: number; - ONE_MINUS_CONSTANT_ALPHA: number; - BACK: number; - RENDERBUFFER_STENCIL_SIZE: number; - UNPACK_FLIP_Y_WEBGL: number; - BLEND: number; - TEXTURE9: number; - ARRAY_BUFFER_BINDING: number; - MAX_VIEWPORT_DIMS: number; - INVALID_FRAMEBUFFER_OPERATION: number; - TEXTURE: number; - TEXTURE0: number; - TEXTURE31: number; - TEXTURE24: number; - HIGH_INT: number; - RENDERBUFFER_BINDING: number; - BLEND_COLOR: number; - FASTEST: number; - STENCIL_WRITEMASK: number; - ALIASED_POINT_SIZE_RANGE: number; - TEXTURE12: number; - DST_ALPHA: number; - BLEND_EQUATION_RGB: number; - FRAMEBUFFER_COMPLETE: number; - NEAREST_MIPMAP_NEAREST: number; - VERTEX_ATTRIB_ARRAY_SIZE: number; - TEXTURE3: number; - DEPTH_WRITEMASK: number; - CONTEXT_LOST_WEBGL: number; - INVALID_VALUE: number; - TEXTURE_MAG_FILTER: number; - ONE_MINUS_CONSTANT_COLOR: number; - ONE_MINUS_SRC_ALPHA: number; - TEXTURE_CUBE_MAP_POSITIVE_Z: number; - NOTEQUAL: number; - ALPHA: number; - DEPTH_STENCIL: number; - MAX_VERTEX_UNIFORM_VECTORS: number; - DEPTH_COMPONENT: number; - RENDERBUFFER_RED_SIZE: number; - TEXTURE20: number; - RED_BITS: number; - RENDERBUFFER_BLUE_SIZE: number; - SCISSOR_BOX: number; - VENDOR: number; - FRONT_AND_BACK: number; - CONSTANT_ALPHA: number; - VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; - NEAREST: number; - CULL_FACE: number; - ALIASED_LINE_WIDTH_RANGE: number; - TEXTURE19: number; - FRONT: number; - DEPTH_CLEAR_VALUE: number; - GREEN_BITS: number; - TEXTURE29: number; - TEXTURE23: number; - MAX_RENDERBUFFER_SIZE: number; - STENCIL_ATTACHMENT: number; - TEXTURE27: number; - BOOL_VEC2: number; - OUT_OF_MEMORY: number; - MIRRORED_REPEAT: number; - POLYGON_OFFSET_UNITS: number; - TEXTURE_MIN_FILTER: number; - STENCIL_BACK_PASS_DEPTH_PASS: number; - LINE_LOOP: number; - FLOAT_MAT3: number; - TEXTURE14: number; - LINEAR: number; - RGB5_A1: number; - ONE_MINUS_SRC_COLOR: number; - SAMPLE_COVERAGE_INVERT: number; - DONT_CARE: number; - FRAMEBUFFER_BINDING: number; - RENDERBUFFER_ALPHA_SIZE: number; - STENCIL_REF: number; - ZERO: number; - DECR_WRAP: number; - SAMPLE_COVERAGE: number; - STENCIL_BACK_FUNC: number; - TEXTURE30: number; - VIEWPORT: number; - STENCIL_BITS: number; - FLOAT: number; - COLOR_WRITEMASK: number; - SAMPLE_COVERAGE_VALUE: number; - TEXTURE_CUBE_MAP_NEGATIVE_Y: number; - STENCIL_BACK_FAIL: number; - FLOAT_MAT4: number; - UNSIGNED_SHORT_4_4_4_4: number; - TEXTURE6: number; - RENDERBUFFER_WIDTH: number; - RGBA4: number; - ALWAYS: number; - BLEND_EQUATION_ALPHA: number; - COLOR_BUFFER_BIT: number; - TEXTURE_CUBE_MAP: number; - DEPTH_BUFFER_BIT: number; - STENCIL_CLEAR_VALUE: number; - BLEND_EQUATION: number; - RENDERBUFFER_GREEN_SIZE: number; - NEAREST_MIPMAP_LINEAR: number; - VERTEX_ATTRIB_ARRAY_TYPE: number; - INCR_WRAP: number; - ONE_MINUS_DST_COLOR: number; - HIGH_FLOAT: number; - BYTE: number; - FRONT_FACE: number; - SAMPLE_ALPHA_TO_COVERAGE: number; - CCW: number; - TEXTURE13: number; - MAX_VERTEX_ATTRIBS: number; - MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; - TEXTURE_WRAP_T: number; - UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; - FLOAT_VEC2: number; - LUMINANCE: number; - GREATER: number; - INT_VEC2: number; - VALIDATE_STATUS: number; - FRAMEBUFFER: number; - FRAMEBUFFER_UNSUPPORTED: number; - TEXTURE5: number; - FUNC_SUBTRACT: number; - BLEND_DST_ALPHA: number; - SAMPLER_CUBE: number; - ONE_MINUS_DST_ALPHA: number; - LESS: number; - TEXTURE_CUBE_MAP_POSITIVE_X: number; - BLUE_BITS: number; - DEPTH_TEST: number; - VERTEX_ATTRIB_ARRAY_STRIDE: number; - DELETE_STATUS: number; - TEXTURE18: number; - POLYGON_OFFSET_FACTOR: number; - UNSIGNED_INT: number; - TEXTURE_2D: number; - DST_COLOR: number; - FLOAT_MAT2: number; - COMPRESSED_TEXTURE_FORMATS: number; - MAX_FRAGMENT_UNIFORM_VECTORS: number; - DEPTH_STENCIL_ATTACHMENT: number; - LUMINANCE_ALPHA: number; - CW: number; - VERTEX_ATTRIB_ARRAY_NORMALIZED: number; - TEXTURE_CUBE_MAP_NEGATIVE_Z: number; - LINEAR_MIPMAP_LINEAR: number; - BUFFER_SIZE: number; - SAMPLE_BUFFERS: number; - TEXTURE15: number; - ACTIVE_TEXTURE: number; - VERTEX_SHADER: number; - TEXTURE22: number; - VERTEX_ATTRIB_ARRAY_POINTER: number; - INCR: number; - COMPILE_STATUS: number; - MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; - TEXTURE7: number; - UNSIGNED_SHORT_5_5_5_1: number; - DEPTH_BITS: number; - RGBA: number; - TRIANGLE_STRIP: number; - COLOR_CLEAR_VALUE: number; - BROWSER_DEFAULT_WEBGL: number; - INVALID_ENUM: number; - SCISSOR_TEST: number; - LINE_STRIP: number; - FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; - STENCIL_FUNC: number; - FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; - RENDERBUFFER_HEIGHT: number; - TEXTURE8: number; - TRIANGLES: number; - FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; - STENCIL_BACK_VALUE_MASK: number; - TEXTURE25: number; - RENDERBUFFER: number; - LEQUAL: number; - TEXTURE1: number; - STENCIL_INDEX8: number; - FUNC_ADD: number; - STENCIL_FAIL: number; - BLEND_SRC_ALPHA: number; - BOOL: number; - ALPHA_BITS: number; - LOW_INT: number; - TEXTURE10: number; - SRC_COLOR: number; - MAX_VARYING_VECTORS: number; - BLEND_DST_RGB: number; - TEXTURE_BINDING_CUBE_MAP: number; - STENCIL_INDEX: number; - TEXTURE_BINDING_2D: number; - MEDIUM_INT: number; - SHADER_TYPE: number; - POLYGON_OFFSET_FILL: number; - DYNAMIC_DRAW: number; - TEXTURE4: number; - STENCIL_BACK_PASS_DEPTH_FAIL: number; - STREAM_DRAW: number; - MAX_CUBE_MAP_TEXTURE_SIZE: number; - TEXTURE17: number; - TRIANGLE_FAN: number; - UNPACK_ALIGNMENT: number; - CURRENT_PROGRAM: number; - LINES: number; - INVALID_OPERATION: number; - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; - LINEAR_MIPMAP_NEAREST: number; - CLAMP_TO_EDGE: number; - RENDERBUFFER_DEPTH_SIZE: number; - TEXTURE_WRAP_S: number; - ELEMENT_ARRAY_BUFFER: number; - UNSIGNED_SHORT_5_6_5: number; - ACTIVE_UNIFORMS: number; - FLOAT_VEC3: number; - NO_ERROR: number; - ATTACHED_SHADERS: number; - DEPTH_ATTACHMENT: number; - TEXTURE11: number; - STENCIL_TEST: number; - ONE: number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; - STATIC_DRAW: number; - GEQUAL: number; - BOOL_VEC4: number; - COLOR_ATTACHMENT0: number; - PACK_ALIGNMENT: number; - MAX_TEXTURE_SIZE: number; - STENCIL_PASS_DEPTH_FAIL: number; - CULL_FACE_MODE: number; - TEXTURE16: number; - STENCIL_BACK_WRITEMASK: number; - SRC_ALPHA: number; - UNSIGNED_SHORT: number; - TEXTURE21: number; - FUNC_REVERSE_SUBTRACT: number; - SHADING_LANGUAGE_VERSION: number; - EQUAL: number; - FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; - BOOL_VEC3: number; - SAMPLER_2D: number; - TEXTURE_CUBE_MAP_NEGATIVE_X: number; - MAX_TEXTURE_IMAGE_UNITS: number; - TEXTURE_CUBE_MAP_POSITIVE_Y: number; - RENDERBUFFER_INTERNAL_FORMAT: number; - STENCIL_VALUE_MASK: number; - ELEMENT_ARRAY_BUFFER_BINDING: number; - ARRAY_BUFFER: number; - DEPTH_RANGE: number; - NICEST: number; - ACTIVE_ATTRIBUTES: number; - NEVER: number; - FLOAT_VEC4: number; - CURRENT_VERTEX_ATTRIB: number; - STENCIL_PASS_DEPTH_PASS: number; - INVERT: number; - LINK_STATUS: number; - RGB: number; - INT_VEC4: number; - TEXTURE2: number; - UNPACK_COLORSPACE_CONVERSION_WEBGL: number; - MEDIUM_FLOAT: number; - SRC_ALPHA_SATURATE: number; - BUFFER_USAGE: number; - SHORT: number; - NONE: number; - UNSIGNED_BYTE: number; - INT: number; - SUBPIXEL_BITS: number; - KEEP: number; - SAMPLES: number; - FRAGMENT_SHADER: number; - LINE_WIDTH: number; - BLEND_SRC_RGB: number; - LOW_FLOAT: number; - VERSION: number; -} - -interface WebGLProgram extends WebGLObject { -} -declare var WebGLProgram: { - prototype: WebGLProgram; - new(): WebGLProgram; -} - -interface OES_standard_derivatives { - FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; -} -declare var OES_standard_derivatives: { - prototype: OES_standard_derivatives; - new(): OES_standard_derivatives; - FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; -} - -interface WebGLFramebuffer extends WebGLObject { -} -declare var WebGLFramebuffer: { - prototype: WebGLFramebuffer; - new(): WebGLFramebuffer; -} - -interface WebGLShader extends WebGLObject { -} -declare var WebGLShader: { - prototype: WebGLShader; - new(): WebGLShader; -} - -interface OES_texture_float_linear { -} -declare var OES_texture_float_linear: { - prototype: OES_texture_float_linear; - new(): OES_texture_float_linear; -} - -interface WebGLObject { -} -declare var WebGLObject: { - prototype: WebGLObject; - new(): WebGLObject; -} - -interface WebGLBuffer extends WebGLObject { -} -declare var WebGLBuffer: { - prototype: WebGLBuffer; - new(): WebGLBuffer; -} - -interface WebGLShaderPrecisionFormat { - rangeMin: number; - rangeMax: number; - precision: number; -} -declare var WebGLShaderPrecisionFormat: { - prototype: WebGLShaderPrecisionFormat; - new(): WebGLShaderPrecisionFormat; -} - -interface EXT_texture_filter_anisotropic { - TEXTURE_MAX_ANISOTROPY_EXT: number; - MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; -} -declare var EXT_texture_filter_anisotropic: { - prototype: EXT_texture_filter_anisotropic; - new(): EXT_texture_filter_anisotropic; - TEXTURE_MAX_ANISOTROPY_EXT: number; - MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; -} - -declare var Option: { new(text?: string, value?: string, defaultSelected?: boolean, selected?:boolean): HTMLOptionElement; }; -declare var Image: { new(width?: number, height?: number): HTMLImageElement; }; -declare var Audio: { new(src?: string): HTMLAudioElement; }; - -declare var ondragend: (ev: DragEvent) => any; -declare var onkeydown: (ev: KeyboardEvent) => any; -declare var ondragover: (ev: DragEvent) => any; -declare var onkeyup: (ev: KeyboardEvent) => any; -declare var onreset: (ev: Event) => any; -declare var onmouseup: (ev: MouseEvent) => any; -declare var ondragstart: (ev: DragEvent) => any; -declare var ondrag: (ev: DragEvent) => any; -declare var screenX: number; -declare var onmouseover: (ev: MouseEvent) => any; -declare var ondragleave: (ev: DragEvent) => any; -declare var history: History; -declare var pageXOffset: number; -declare var name: string; -declare var onafterprint: (ev: Event) => any; -declare var onpause: (ev: Event) => any; -declare var onbeforeprint: (ev: Event) => any; -declare var top: Window; -declare var onmousedown: (ev: MouseEvent) => any; -declare var onseeked: (ev: Event) => any; -declare var opener: Window; -declare var onclick: (ev: MouseEvent) => any; -declare var innerHeight: number; -declare var onwaiting: (ev: Event) => any; -declare var ononline: (ev: Event) => any; -declare var ondurationchange: (ev: Event) => any; -declare var frames: Window; -declare var onblur: (ev: FocusEvent) => any; -declare var onemptied: (ev: Event) => any; -declare var onseeking: (ev: Event) => any; -declare var oncanplay: (ev: Event) => any; -declare var outerWidth: number; -declare var onstalled: (ev: Event) => any; -declare var onmousemove: (ev: MouseEvent) => any; -declare var innerWidth: number; -declare var onoffline: (ev: Event) => any; -declare var length: number; -declare var screen: Screen; -declare var onbeforeunload: (ev: BeforeUnloadEvent) => any; -declare var onratechange: (ev: Event) => any; -declare var onstorage: (ev: StorageEvent) => any; -declare var onloadstart: (ev: Event) => any; -declare var ondragenter: (ev: DragEvent) => any; -declare var onsubmit: (ev: Event) => any; -declare var self: Window; -declare var document: Document; -declare var onprogress: (ev: ProgressEvent) => any; -declare var ondblclick: (ev: MouseEvent) => any; -declare var pageYOffset: number; -declare var oncontextmenu: (ev: MouseEvent) => any; -declare var onchange: (ev: Event) => any; -declare var onloadedmetadata: (ev: Event) => any; -declare var onplay: (ev: Event) => any; -declare var onerror: ErrorEventHandler; -declare var onplaying: (ev: Event) => any; -declare var parent: Window; -declare var location: Location; -declare var oncanplaythrough: (ev: Event) => any; -declare var onabort: (ev: UIEvent) => any; -declare var onreadystatechange: (ev: Event) => any; -declare var outerHeight: number; -declare var onkeypress: (ev: KeyboardEvent) => any; -declare var frameElement: Element; -declare var onloadeddata: (ev: Event) => any; -declare var onsuspend: (ev: Event) => any; -declare var window: Window; -declare var onfocus: (ev: FocusEvent) => any; -declare var onmessage: (ev: MessageEvent) => any; -declare var ontimeupdate: (ev: Event) => any; -declare var onresize: (ev: UIEvent) => any; -declare var onselect: (ev: UIEvent) => any; -declare var navigator: Navigator; -declare var styleMedia: StyleMedia; -declare var ondrop: (ev: DragEvent) => any; -declare var onmouseout: (ev: MouseEvent) => any; -declare var onended: (ev: Event) => any; -declare var onhashchange: (ev: Event) => any; -declare var onunload: (ev: Event) => any; -declare var onscroll: (ev: UIEvent) => any; -declare var screenY: number; -declare var onmousewheel: (ev: MouseWheelEvent) => any; -declare var onload: (ev: Event) => any; -declare var onvolumechange: (ev: Event) => any; -declare var oninput: (ev: Event) => any; -declare var performance: Performance; -declare var onmspointerdown: (ev: any) => any; -declare var animationStartTime: number; -declare var onmsgesturedoubletap: (ev: any) => any; -declare var onmspointerhover: (ev: any) => any; -declare var onmsgesturehold: (ev: any) => any; -declare var onmspointermove: (ev: any) => any; -declare var onmsgesturechange: (ev: any) => any; -declare var onmsgesturestart: (ev: any) => any; -declare var onmspointercancel: (ev: any) => any; -declare var onmsgestureend: (ev: any) => any; -declare var onmsgesturetap: (ev: any) => any; -declare var onmspointerout: (ev: any) => any; -declare var msAnimationStartTime: number; -declare var applicationCache: ApplicationCache; -declare var onmsinertiastart: (ev: any) => any; -declare var onmspointerover: (ev: any) => any; -declare var onpopstate: (ev: PopStateEvent) => any; -declare var onmspointerup: (ev: any) => any; -declare var onpageshow: (ev: PageTransitionEvent) => any; -declare var ondevicemotion: (ev: DeviceMotionEvent) => any; -declare var devicePixelRatio: number; -declare var msCrypto: Crypto; -declare var ondeviceorientation: (ev: DeviceOrientationEvent) => any; -declare var doNotTrack: string; -declare var onmspointerenter: (ev: any) => any; -declare var onpagehide: (ev: PageTransitionEvent) => any; -declare var onmspointerleave: (ev: any) => any; -declare function alert(message?: any): void; -declare function scroll(x?: number, y?: number): void; -declare function focus(): void; -declare function scrollTo(x?: number, y?: number): void; -declare function print(): void; -declare function prompt(message?: string, _default?: string): string; -declare function toString(): string; -declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; -declare function scrollBy(x?: number, y?: number): void; -declare function confirm(message?: string): boolean; -declare function close(): void; -declare function postMessage(message: any, targetOrigin: string, ports?: any): void; -declare function showModalDialog(url?: string, argument?: any, options?: any): any; -declare function blur(): void; -declare function getSelection(): Selection; -declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; -declare function msCancelRequestAnimationFrame(handle: number): void; -declare function matchMedia(mediaQuery: string): MediaQueryList; -declare function cancelAnimationFrame(handle: number): void; -declare function msIsStaticHTML(html: string): boolean; -declare function msMatchMedia(mediaQuery: string): MediaQueryList; -declare function requestAnimationFrame(callback: FrameRequestCallback): number; -declare function msRequestAnimationFrame(callback: FrameRequestCallback): number; -declare function removeEventListener(type: string, listener: EventListener, useCapture?: boolean): void; -declare function dispatchEvent(evt: Event): boolean; -declare function attachEvent(event: string, listener: EventListener): boolean; -declare function detachEvent(event: string, listener: EventListener): void; -declare var localStorage: Storage; -declare var status: string; -declare var onmouseleave: (ev: MouseEvent) => any; -declare var screenLeft: number; -declare var offscreenBuffering: any; -declare var maxConnectionsPerServer: number; -declare var onmouseenter: (ev: MouseEvent) => any; -declare var clipboardData: DataTransfer; -declare var defaultStatus: string; -declare var clientInformation: Navigator; -declare var closed: boolean; -declare var onhelp: (ev: Event) => any; -declare var external: External; -declare var event: MSEventObj; -declare var onfocusout: (ev: FocusEvent) => any; -declare var screenTop: number; -declare var onfocusin: (ev: FocusEvent) => any; -declare function showModelessDialog(url?: string, argument?: any, options?: any): Window; -declare function navigate(url: string): void; -declare function resizeBy(x?: number, y?: number): void; -declare function item(index: any): any; -declare function resizeTo(x?: number, y?: number): void; -declare function createPopup(arguments?: any): MSPopupWindow; -declare function toStaticHTML(html: string): string; -declare function execScript(code: string, language?: string): any; -declare function msWriteProfilerMark(profilerMarkName: string): void; -declare function moveTo(x?: number, y?: number): void; -declare function moveBy(x?: number, y?: number): void; -declare function showHelp(url: string, helpArg?: any, features?: string): void; -declare function captureEvents(): void; -declare function releaseEvents(): void; -declare var sessionStorage: Storage; -declare function clearTimeout(handle: number): void; -declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; -declare function clearInterval(handle: number): void; -declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; -declare function msSetImmediate(expression: any, ...args: any[]): number; -declare function clearImmediate(handle: number): void; -declare function msClearImmediate(handle: number): void; -declare function setImmediate(expression: any, ...args: any[]): number; -declare function btoa(rawString: string): string; -declare function atob(encodedString: string): string; -declare var msIndexedDB: IDBFactory; -declare var indexedDB: IDBFactory; -declare var console: Console; -declare var onpointerenter: (ev: PointerEvent) => any; -declare var onpointerout: (ev: PointerEvent) => any; -declare var onpointerdown: (ev: PointerEvent) => any; -declare var onpointerup: (ev: PointerEvent) => any; -declare var onpointercancel: (ev: PointerEvent) => any; -declare var onpointerover: (ev: PointerEvent) => any; -declare var onpointermove: (ev: PointerEvent) => any; -declare var onpointerleave: (ev: PointerEvent) => any; -declare function addEventListener(type: "mouseleave", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mouseenter", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "help", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "focusout", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "focusin", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerenter", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerout", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerdown", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerup", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointercancel", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerover", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointermove", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pointerleave", listener: (ev: PointerEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragend", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragover", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "keyup", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "reset", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mouseup", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragstart", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "drag", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mouseover", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragleave", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "afterprint", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "beforeprint", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mousedown", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "seeked", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "click", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "online", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "durationchange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "blur", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "emptied", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "seeking", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "canplay", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "stalled", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mousemove", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "offline", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "beforeunload", listener: (ev: BeforeUnloadEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "ratechange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "storage", listener: (ev: StorageEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "loadstart", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dragenter", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "submit", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "dblclick", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "contextmenu", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "change", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "loadedmetadata", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "play", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "playing", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "canplaythrough", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "readystatechange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "keypress", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "loadeddata", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "suspend", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "focus", listener: (ev: FocusEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "timeupdate", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "resize", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "select", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "drop", listener: (ev: DragEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mouseout", listener: (ev: MouseEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "ended", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "hashchange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "unload", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "scroll", listener: (ev: UIEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mousewheel", listener: (ev: MouseWheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "input", listener: (ev: Event) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mspointerdown", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "msgesturedoubletap", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mspointerhover", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "msgesturehold", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mspointermove", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "msgesturechange", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "msgesturestart", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mspointercancel", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "msgestureend", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "msgesturetap", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mspointerout", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "msinertiastart", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mspointerover", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "popstate", listener: (ev: PopStateEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mspointerup", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pageshow", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "devicemotion", listener: (ev: DeviceMotionEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "deviceorientation", listener: (ev: DeviceOrientationEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mspointerenter", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: "pagehide", listener: (ev: PageTransitionEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: "mspointerleave", listener: (ev: any) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListener, useCapture?: boolean): void; - -///////////////////////////// -/// WorkerGlobalScope APIs -///////////////////////////// -// These are only available in a Web Worker -declare function importScripts(...urls: string[]): void; - - -///////////////////////////// -/// Windows Script Host APIS -///////////////////////////// - -declare var ActiveXObject: { new (s: string): any; }; - -interface ITextWriter { - Write(s: string): void; - WriteLine(s: string): void; - Close(): void; -} - -declare var WScript: { - Echo(s: any): void; - StdErr: ITextWriter; - StdOut: ITextWriter; - Arguments: { length: number; Item(n: number): string; }; - ScriptFullName: string; - Quit(exitCode?: number): number; -} diff --git a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/resources/tsc.js b/org.kevoree.modeling.java2typescript.mavenplugin/src/main/resources/tsc.js deleted file mode 100755 index acbc0c4..0000000 --- a/org.kevoree.modeling.java2typescript.mavenplugin/src/main/resources/tsc.js +++ /dev/null @@ -1,18289 +0,0 @@ -/*! ***************************************************************************** -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. -***************************************************************************** */ - -var ts; -(function (ts) { - (function (EmitReturnStatus) { - EmitReturnStatus[EmitReturnStatus["Succeeded"] = 0] = "Succeeded"; - EmitReturnStatus[EmitReturnStatus["AllOutputGenerationSkipped"] = 1] = "AllOutputGenerationSkipped"; - EmitReturnStatus[EmitReturnStatus["JSGeneratedWithSemanticErrors"] = 2] = "JSGeneratedWithSemanticErrors"; - EmitReturnStatus[EmitReturnStatus["DeclarationGenerationSkipped"] = 3] = "DeclarationGenerationSkipped"; - EmitReturnStatus[EmitReturnStatus["EmitErrorsEncountered"] = 4] = "EmitErrorsEncountered"; - EmitReturnStatus[EmitReturnStatus["CompilerOptionsErrors"] = 5] = "CompilerOptionsErrors"; - })(ts.EmitReturnStatus || (ts.EmitReturnStatus = {})); - var EmitReturnStatus = ts.EmitReturnStatus; - (function (DiagnosticCategory) { - DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; - DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; - DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; - })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); - var DiagnosticCategory = ts.DiagnosticCategory; -})(ts || (ts = {})); -var ts; -(function (ts) { - function forEach(array, callback) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - var result = callback(array[i]); - if (result) { - return result; - } - } - } - return undefined; - } - ts.forEach = forEach; - function contains(array, value) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return true; - } - } - } - return false; - } - ts.contains = contains; - function indexOf(array, value) { - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - } - return -1; - } - ts.indexOf = indexOf; - function countWhere(array, predicate) { - var count = 0; - if (array) { - for (var i = 0, len = array.length; i < len; i++) { - if (predicate(array[i])) { - count++; - } - } - } - return count; - } - ts.countWhere = countWhere; - function filter(array, f) { - if (array) { - var result = []; - for (var i = 0, len = array.length; i < len; i++) { - var item = array[i]; - if (f(item)) { - result.push(item); - } - } - } - return result; - } - ts.filter = filter; - function map(array, f) { - if (array) { - var result = []; - for (var i = 0, len = array.length; i < len; i++) { - result.push(f(array[i])); - } - } - return result; - } - ts.map = map; - function concatenate(array1, array2) { - if (!array2 || !array2.length) - return array1; - if (!array1 || !array1.length) - return array2; - return array1.concat(array2); - } - ts.concatenate = concatenate; - function deduplicate(array) { - if (array) { - var result = []; - for (var i = 0, len = array.length; i < len; i++) { - var item = array[i]; - if (!contains(result, item)) - result.push(item); - } - } - return result; - } - ts.deduplicate = deduplicate; - function sum(array, prop) { - var result = 0; - for (var i = 0; i < array.length; i++) { - result += array[i][prop]; - } - return result; - } - ts.sum = sum; - function lastOrUndefined(array) { - if (array.length === 0) { - return undefined; - } - return array[array.length - 1]; - } - ts.lastOrUndefined = lastOrUndefined; - function binarySearch(array, value) { - var low = 0; - var high = array.length - 1; - while (low <= high) { - var middle = low + ((high - low) >> 1); - var midValue = array[middle]; - if (midValue === value) { - return middle; - } - else if (midValue > value) { - high = middle - 1; - } - else { - low = middle + 1; - } - } - return ~low; - } - ts.binarySearch = binarySearch; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function hasProperty(map, key) { - return hasOwnProperty.call(map, key); - } - ts.hasProperty = hasProperty; - function getProperty(map, key) { - return hasOwnProperty.call(map, key) ? map[key] : undefined; - } - ts.getProperty = getProperty; - function isEmpty(map) { - for (var id in map) { - if (hasProperty(map, id)) { - return false; - } - } - return true; - } - ts.isEmpty = isEmpty; - function clone(object) { - var result = {}; - for (var id in object) { - result[id] = object[id]; - } - return result; - } - ts.clone = clone; - function forEachValue(map, callback) { - var result; - for (var id in map) { - if (result = callback(map[id])) - break; - } - return result; - } - ts.forEachValue = forEachValue; - function forEachKey(map, callback) { - var result; - for (var id in map) { - if (result = callback(id)) - break; - } - return result; - } - ts.forEachKey = forEachKey; - function lookUp(map, key) { - return hasProperty(map, key) ? map[key] : undefined; - } - ts.lookUp = lookUp; - function mapToArray(map) { - var result = []; - for (var id in map) { - result.push(map[id]); - } - return result; - } - ts.mapToArray = mapToArray; - function arrayToMap(array, makeKey) { - var result = {}; - forEach(array, function (value) { - result[makeKey(value)] = value; - }); - return result; - } - ts.arrayToMap = arrayToMap; - function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; - return text.replace(/{(\d+)}/g, function (match, index) { return args[+index + baseIndex]; }); - } - ts.localizedDiagnosticMessages = undefined; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message] ? ts.localizedDiagnosticMessages[message] : message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code, - isEarly: message.isEarly - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code, - isEarly: message.isEarly - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message.key); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - Debug.assert(!headChain.next); - headChain.next = tailChain; - return headChain; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function flattenDiagnosticChain(file, start, length, diagnosticChain, newLine) { - Debug.assert(start >= 0, "start must be non-negative, is " + start); - Debug.assert(length >= 0, "length must be non-negative, is " + length); - var code = diagnosticChain.code; - var category = diagnosticChain.category; - var messageText = ""; - var indent = 0; - while (diagnosticChain) { - if (indent) { - messageText += newLine; - for (var i = 0; i < indent; i++) { - messageText += " "; - } - } - messageText += diagnosticChain.messageText; - indent++; - diagnosticChain = diagnosticChain.next; - } - return { - file: file, - start: start, - length: length, - code: code, - category: category, - messageText: messageText - }; - } - ts.flattenDiagnosticChain = flattenDiagnosticChain; - function compareValues(a, b) { - if (a === b) - return 0 /* EqualTo */; - if (a === undefined) - return -1 /* LessThan */; - if (b === undefined) - return 1 /* GreaterThan */; - return a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; - } - ts.compareValues = compareValues; - function getDiagnosticFilename(diagnostic) { - return diagnostic.file ? diagnostic.file.filename : undefined; - } - function compareDiagnostics(d1, d2) { - return compareValues(getDiagnosticFilename(d1), getDiagnosticFilename(d2)) || compareValues(d1.start, d2.start) || compareValues(d1.length, d2.length) || compareValues(d1.code, d2.code) || compareValues(d1.messageText, d2.messageText) || 0; - } - ts.compareDiagnostics = compareDiagnostics; - function deduplicateSortedDiagnostics(diagnostics) { - if (diagnostics.length < 2) { - return diagnostics; - } - var newDiagnostics = [diagnostics[0]]; - var previousDiagnostic = diagnostics[0]; - for (var i = 1; i < diagnostics.length; i++) { - var currentDiagnostic = diagnostics[i]; - var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0 /* EqualTo */; - if (!isDupe) { - newDiagnostics.push(currentDiagnostic); - previousDiagnostic = currentDiagnostic; - } - } - return newDiagnostics; - } - ts.deduplicateSortedDiagnostics = deduplicateSortedDiagnostics; - function normalizeSlashes(path) { - return path.replace(/\\/g, "/"); - } - ts.normalizeSlashes = normalizeSlashes; - function getRootLength(path) { - if (path.charCodeAt(0) === 47 /* slash */) { - if (path.charCodeAt(1) !== 47 /* slash */) - return 1; - var p1 = path.indexOf("/", 2); - if (p1 < 0) - return 2; - var p2 = path.indexOf("/", p1 + 1); - if (p2 < 0) - return p1 + 1; - return p2 + 1; - } - if (path.charCodeAt(1) === 58 /* colon */) { - if (path.charCodeAt(2) === 47 /* slash */) - return 3; - return 2; - } - return 0; - } - ts.getRootLength = getRootLength; - ts.directorySeparator = "/"; - function getNormalizedParts(normalizedSlashedPath, rootLength) { - var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); - var normalized = []; - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; - if (part !== ".") { - if (part === ".." && normalized.length > 0 && normalized[normalized.length - 1] !== "..") { - normalized.pop(); - } - else { - normalized.push(part); - } - } - } - return normalized; - } - function normalizePath(path) { - var path = normalizeSlashes(path); - var rootLength = getRootLength(path); - var normalized = getNormalizedParts(path, rootLength); - return path.substr(0, rootLength) + normalized.join(ts.directorySeparator); - } - ts.normalizePath = normalizePath; - function getDirectoryPath(path) { - return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function isUrl(path) { - return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; - } - ts.isUrl = isUrl; - function isRootedDiskPath(path) { - return getRootLength(path) !== 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - function normalizedPathComponents(path, rootLength) { - var normalizedParts = getNormalizedParts(path, rootLength); - return [path.substr(0, rootLength)].concat(normalizedParts); - } - function getNormalizedPathComponents(path, currentDirectory) { - var path = normalizeSlashes(path); - var rootLength = getRootLength(path); - if (rootLength == 0) { - path = combinePaths(normalizeSlashes(currentDirectory), path); - rootLength = getRootLength(path); - } - return normalizedPathComponents(path, rootLength); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(filename, currentDirectory) { - return getNormalizedPathFromPathComponents(getNormalizedPathComponents(filename, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - function getNormalizedPathFromPathComponents(pathComponents) { - if (pathComponents && pathComponents.length) { - return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator); - } - } - ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents; - function getNormalizedPathComponentsOfUrl(url) { - var urlLength = url.length; - var rootLength = url.indexOf("://") + "://".length; - while (rootLength < urlLength) { - if (url.charCodeAt(rootLength) === 47 /* slash */) { - rootLength++; - } - else { - break; - } - } - if (rootLength === urlLength) { - return [url]; - } - var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); - if (indexOfNextSlash !== -1) { - rootLength = indexOfNextSlash + 1; - return normalizedPathComponents(url, rootLength); - } - else { - return [url + ts.directorySeparator]; - } - } - function getNormalizedPathOrUrlComponents(pathOrUrl, currentDirectory) { - if (isUrl(pathOrUrl)) { - return getNormalizedPathComponentsOfUrl(pathOrUrl); - } - else { - return getNormalizedPathComponents(pathOrUrl, currentDirectory); - } - } - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); - var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); - if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { - directoryComponents.length--; - } - for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { - break; - } - } - if (joinStartIndex) { - var relativePath = ""; - var relativePathComponents = pathComponents.slice(joinStartIndex, pathComponents.length); - for (; joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (directoryComponents[joinStartIndex] !== "") { - relativePath = relativePath + ".." + ts.directorySeparator; - } - } - return relativePath + relativePathComponents.join(ts.directorySeparator); - } - var absolutePath = getNormalizedPathFromPathComponents(pathComponents); - if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) { - absolutePath = "file:///" + absolutePath; - } - return absolutePath; - } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - function getBaseFilename(path) { - var i = path.lastIndexOf(ts.directorySeparator); - return i < 0 ? path : path.substring(i + 1); - } - ts.getBaseFilename = getBaseFilename; - function combinePaths(path1, path2) { - if (!(path1 && path1.length)) - return path2; - if (!(path2 && path2.length)) - return path1; - if (path2.charAt(0) === ts.directorySeparator) - return path2; - if (path1.charAt(path1.length - 1) === ts.directorySeparator) - return path1 + path2; - return path1 + ts.directorySeparator + path2; - } - ts.combinePaths = combinePaths; - function fileExtensionIs(path, extension) { - var pathLen = path.length; - var extLen = extension.length; - return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; - } - ts.fileExtensionIs = fileExtensionIs; - var supportedExtensions = [".d.ts", ".ts", ".js"]; - function removeFileExtension(path) { - for (var i = 0; i < supportedExtensions.length; i++) { - var ext = supportedExtensions[i]; - if (fileExtensionIs(path, ext)) { - return path.substr(0, path.length - ext.length); - } - } - return path; - } - ts.removeFileExtension = removeFileExtension; - var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\\\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\0": "\\0", - "\r": "\\r", - "\n": "\\n", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }; - function escapeString(s) { - return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) { - return escapedCharsMap[c] || c; - }) : s; - } - ts.escapeString = escapeString; - function Symbol(flags, name) { - this.flags = flags; - this.name = name; - this.declarations = undefined; - } - function Type(checker, flags) { - this.flags = flags; - } - function Signature(checker) { - } - ts.objectAllocator = { - getNodeConstructor: function (kind) { - function Node() { - } - Node.prototype = { - kind: kind, - pos: 0, - end: 0, - flags: 0, - parent: undefined - }; - return Node; - }, - getSymbolConstructor: function () { return Symbol; }, - getTypeConstructor: function () { return Type; }, - getSignatureConstructor: function () { return Signature; } - }; - var Debug; - (function (Debug) { - var currentAssertionLevel = 0 /* None */; - function shouldAssert(level) { - return currentAssertionLevel >= level; - } - Debug.shouldAssert = shouldAssert; - function assert(expression, message, verboseDebugInfo) { - if (!expression) { - var verboseDebugString = ""; - if (verboseDebugInfo) { - verboseDebugString = "\r\nVerbose Debug Information: " + verboseDebugInfo(); - } - throw new Error("Debug Failure. False expression: " + (message || "") + verboseDebugString); - } - } - Debug.assert = assert; - function fail(message) { - Debug.assert(false, message); - } - Debug.fail = fail; - })(Debug = ts.Debug || (ts.Debug = {})); -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - fileStream.Position = 0; - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - return { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return new ActiveXObject("WScript.Shell").CurrentDirectory; - }, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - } - function getNodeSystem() { - var _fs = require("fs"); - var _path = require("path"); - var _os = require('os'); - var platform = _os.platform(); - var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; - function readFile(fileName, encoding) { - if (!_fs.existsSync(fileName)) { - return undefined; - } - var buffer = _fs.readFileSync(fileName); - var len = buffer.length; - if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { - len &= ~1; - for (var i = 0; i < len; i += 2) { - var temp = buffer[i]; - buffer[i] = buffer[i + 1]; - buffer[i + 1] = temp; - } - return buffer.toString("utf16le", 2); - } - if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { - return buffer.toString("utf16le", 2); - } - if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { - return buffer.toString("utf8", 3); - } - return buffer.toString("utf8"); - } - function writeFile(fileName, data, writeByteOrderMark) { - if (writeByteOrderMark) { - data = '\uFEFF' + data; - } - _fs.writeFileSync(fileName, data, "utf8"); - } - return { - args: process.argv.slice(2), - newLine: _os.EOL, - useCaseSensitiveFileNames: useCaseSensitiveFileNames, - write: function (s) { - _fs.writeSync(1, s); - }, - readFile: readFile, - writeFile: writeFile, - watchFile: function (fileName, callback) { - _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); - return { - close: function () { - _fs.unwatchFile(fileName, fileChanged); - } - }; - function fileChanged(curr, prev) { - if (+curr.mtime <= +prev.mtime) { - return; - } - callback(fileName); - } - ; - }, - resolvePath: function (path) { - return _path.resolve(path); - }, - fileExists: function (path) { - return _fs.existsSync(path); - }, - directoryExists: function (path) { - return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); - }, - createDirectory: function (directoryName) { - if (!this.directoryExists(directoryName)) { - _fs.mkdirSync(directoryName); - } - }, - getExecutingFilePath: function () { - return __filename; - }, - getCurrentDirectory: function () { - return process.cwd(); - }, - getMemoryUsage: function () { - if (global.gc) { - global.gc(); - } - return process.memoryUsage().heapUsed; - }, - exit: function (exitCode) { - process.exit(exitCode); - } - }; - } - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return getWScriptSystem(); - } - else if (typeof module !== "undefined" && module.exports) { - return getNodeSystem(); - } - else { - return undefined; - } - })(); -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.Diagnostics = { - Unterminated_string_literal: { code: 1002, category: 1 /* Error */, key: "Unterminated string literal." }, - Identifier_expected: { code: 1003, category: 1 /* Error */, key: "Identifier expected." }, - _0_expected: { code: 1005, category: 1 /* Error */, key: "'{0}' expected." }, - A_file_cannot_have_a_reference_to_itself: { code: 1006, category: 1 /* Error */, key: "A file cannot have a reference to itself." }, - Trailing_comma_not_allowed: { code: 1009, category: 1 /* Error */, key: "Trailing comma not allowed." }, - Asterisk_Slash_expected: { code: 1010, category: 1 /* Error */, key: "'*/' expected." }, - Unexpected_token: { code: 1012, category: 1 /* Error */, key: "Unexpected token." }, - Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: 1 /* Error */, key: "Catch clause parameter cannot have a type annotation." }, - A_rest_parameter_must_be_last_in_a_parameter_list: { code: 1014, category: 1 /* Error */, key: "A rest parameter must be last in a parameter list." }, - Parameter_cannot_have_question_mark_and_initializer: { code: 1015, category: 1 /* Error */, key: "Parameter cannot have question mark and initializer." }, - A_required_parameter_cannot_follow_an_optional_parameter: { code: 1016, category: 1 /* Error */, key: "A required parameter cannot follow an optional parameter." }, - An_index_signature_cannot_have_a_rest_parameter: { code: 1017, category: 1 /* Error */, key: "An index signature cannot have a rest parameter." }, - An_index_signature_parameter_cannot_have_an_accessibility_modifier: { code: 1018, category: 1 /* Error */, key: "An index signature parameter cannot have an accessibility modifier." }, - An_index_signature_parameter_cannot_have_a_question_mark: { code: 1019, category: 1 /* Error */, key: "An index signature parameter cannot have a question mark." }, - An_index_signature_parameter_cannot_have_an_initializer: { code: 1020, category: 1 /* Error */, key: "An index signature parameter cannot have an initializer." }, - An_index_signature_must_have_a_type_annotation: { code: 1021, category: 1 /* Error */, key: "An index signature must have a type annotation." }, - An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: 1 /* Error */, key: "An index signature parameter must have a type annotation." }, - An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: 1 /* Error */, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: 1 /* Error */, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: 1 /* Error */, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: 1 /* Error */, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: 1 /* Error */, key: "A class declaration can only have one 'implements' clause." }, - Accessibility_modifier_already_seen: { code: 1028, category: 1 /* Error */, key: "Accessibility modifier already seen." }, - _0_modifier_must_precede_1_modifier: { code: 1029, category: 1 /* Error */, key: "'{0}' modifier must precede '{1}' modifier." }, - _0_modifier_already_seen: { code: 1030, category: 1 /* Error */, key: "'{0}' modifier already seen." }, - _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: 1 /* Error */, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: 1 /* Error */, key: "An interface declaration cannot have an 'implements' clause." }, - super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: 1 /* Error */, key: "'super' must be followed by an argument list or member access." }, - Only_ambient_modules_can_use_quoted_names: { code: 1035, category: 1 /* Error */, key: "Only ambient modules can use quoted names." }, - Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: 1 /* Error */, key: "Statements are not allowed in ambient contexts." }, - A_function_implementation_cannot_be_declared_in_an_ambient_context: { code: 1037, category: 1 /* Error */, key: "A function implementation cannot be declared in an ambient context." }, - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: 1 /* Error */, key: "A 'declare' modifier cannot be used in an already ambient context." }, - Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: 1 /* Error */, key: "Initializers are not allowed in ambient contexts." }, - _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: 1 /* Error */, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: 1 /* Error */, key: "A 'declare' modifier cannot be used with an interface declaration." }, - A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: 1 /* Error */, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, - A_rest_parameter_cannot_be_optional: { code: 1047, category: 1 /* Error */, key: "A rest parameter cannot be optional." }, - A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: 1 /* Error */, key: "A rest parameter cannot have an initializer." }, - A_set_accessor_must_have_exactly_one_parameter: { code: 1049, category: 1 /* Error */, key: "A 'set' accessor must have exactly one parameter." }, - A_set_accessor_cannot_have_an_optional_parameter: { code: 1051, category: 1 /* Error */, key: "A 'set' accessor cannot have an optional parameter." }, - A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: 1 /* Error */, key: "A 'set' accessor parameter cannot have an initializer." }, - A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: 1 /* Error */, key: "A 'set' accessor cannot have rest parameter." }, - A_get_accessor_cannot_have_parameters: { code: 1054, category: 1 /* Error */, key: "A 'get' accessor cannot have parameters." }, - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: 1 /* Error */, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, - Enum_member_must_have_initializer: { code: 1061, category: 1 /* Error */, key: "Enum member must have initializer." }, - An_export_assignment_cannot_be_used_in_an_internal_module: { code: 1063, category: 1 /* Error */, key: "An export assignment cannot be used in an internal module." }, - Ambient_enum_elements_can_only_have_integer_literal_initializers: { code: 1066, category: 1 /* Error */, key: "Ambient enum elements can only have integer literal initializers." }, - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: { code: 1068, category: 1 /* Error */, key: "Unexpected token. A constructor, method, accessor, or property was expected." }, - A_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: 1 /* Error */, key: "A 'declare' modifier cannot be used with an import declaration." }, - Invalid_reference_directive_syntax: { code: 1084, category: 1 /* Error */, key: "Invalid 'reference' directive syntax." }, - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: 1 /* Error */, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, - An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: 1 /* Error */, key: "An accessor cannot be declared in an ambient context." }, - _0_modifier_cannot_appear_on_a_constructor_declaration: { code: 1089, category: 1 /* Error */, key: "'{0}' modifier cannot appear on a constructor declaration." }, - _0_modifier_cannot_appear_on_a_parameter: { code: 1090, category: 1 /* Error */, key: "'{0}' modifier cannot appear on a parameter." }, - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: { code: 1091, category: 1 /* Error */, key: "Only a single variable declaration is allowed in a 'for...in' statement." }, - Type_parameters_cannot_appear_on_a_constructor_declaration: { code: 1092, category: 1 /* Error */, key: "Type parameters cannot appear on a constructor declaration." }, - Type_annotation_cannot_appear_on_a_constructor_declaration: { code: 1093, category: 1 /* Error */, key: "Type annotation cannot appear on a constructor declaration." }, - An_accessor_cannot_have_type_parameters: { code: 1094, category: 1 /* Error */, key: "An accessor cannot have type parameters." }, - A_set_accessor_cannot_have_a_return_type_annotation: { code: 1095, category: 1 /* Error */, key: "A 'set' accessor cannot have a return type annotation." }, - An_index_signature_must_have_exactly_one_parameter: { code: 1096, category: 1 /* Error */, key: "An index signature must have exactly one parameter." }, - _0_list_cannot_be_empty: { code: 1097, category: 1 /* Error */, key: "'{0}' list cannot be empty." }, - Type_parameter_list_cannot_be_empty: { code: 1098, category: 1 /* Error */, key: "Type parameter list cannot be empty." }, - Type_argument_list_cannot_be_empty: { code: 1099, category: 1 /* Error */, key: "Type argument list cannot be empty." }, - Invalid_use_of_0_in_strict_mode: { code: 1100, category: 1 /* Error */, key: "Invalid use of '{0}' in strict mode." }, - with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: 1 /* Error */, key: "'with' statements are not allowed in strict mode." }, - delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: 1 /* Error */, key: "'delete' cannot be called on an identifier in strict mode." }, - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: 1 /* Error */, key: "A 'continue' statement can only be used within an enclosing iteration statement." }, - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: 1 /* Error */, key: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, - Jump_target_cannot_cross_function_boundary: { code: 1107, category: 1 /* Error */, key: "Jump target cannot cross function boundary." }, - A_return_statement_can_only_be_used_within_a_function_body: { code: 1108, category: 1 /* Error */, key: "A 'return' statement can only be used within a function body." }, - Expression_expected: { code: 1109, category: 1 /* Error */, key: "Expression expected." }, - Type_expected: { code: 1110, category: 1 /* Error */, key: "Type expected." }, - A_constructor_implementation_cannot_be_declared_in_an_ambient_context: { code: 1111, category: 1 /* Error */, key: "A constructor implementation cannot be declared in an ambient context." }, - A_class_member_cannot_be_declared_optional: { code: 1112, category: 1 /* Error */, key: "A class member cannot be declared optional." }, - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: 1 /* Error */, key: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: 1 /* Error */, key: "Duplicate label '{0}'" }, - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: 1 /* Error */, key: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: 1 /* Error */, key: "A 'break' statement can only jump to a label of an enclosing statement." }, - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: 1 /* Error */, key: "An object literal cannot have multiple properties with the same name in strict mode." }, - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: 1 /* Error */, key: "An object literal cannot have multiple get/set accessors with the same name." }, - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: 1 /* Error */, key: "An object literal cannot have property and accessor with the same name." }, - An_export_assignment_cannot_have_modifiers: { code: 1120, category: 1 /* Error */, key: "An export assignment cannot have modifiers." }, - Octal_literals_are_not_allowed_in_strict_mode: { code: 1121, category: 1 /* Error */, key: "Octal literals are not allowed in strict mode." }, - A_tuple_type_element_list_cannot_be_empty: { code: 1122, category: 1 /* Error */, key: "A tuple type element list cannot be empty." }, - Variable_declaration_list_cannot_be_empty: { code: 1123, category: 1 /* Error */, key: "Variable declaration list cannot be empty." }, - Digit_expected: { code: 1124, category: 1 /* Error */, key: "Digit expected." }, - Hexadecimal_digit_expected: { code: 1125, category: 1 /* Error */, key: "Hexadecimal digit expected." }, - Unexpected_end_of_text: { code: 1126, category: 1 /* Error */, key: "Unexpected end of text." }, - Invalid_character: { code: 1127, category: 1 /* Error */, key: "Invalid character." }, - Declaration_or_statement_expected: { code: 1128, category: 1 /* Error */, key: "Declaration or statement expected." }, - Statement_expected: { code: 1129, category: 1 /* Error */, key: "Statement expected." }, - case_or_default_expected: { code: 1130, category: 1 /* Error */, key: "'case' or 'default' expected." }, - Property_or_signature_expected: { code: 1131, category: 1 /* Error */, key: "Property or signature expected." }, - Enum_member_expected: { code: 1132, category: 1 /* Error */, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: 1 /* Error */, key: "Type reference expected." }, - Variable_declaration_expected: { code: 1134, category: 1 /* Error */, key: "Variable declaration expected." }, - Argument_expression_expected: { code: 1135, category: 1 /* Error */, key: "Argument expression expected." }, - Property_assignment_expected: { code: 1136, category: 1 /* Error */, key: "Property assignment expected." }, - Expression_or_comma_expected: { code: 1137, category: 1 /* Error */, key: "Expression or comma expected." }, - Parameter_declaration_expected: { code: 1138, category: 1 /* Error */, key: "Parameter declaration expected." }, - Type_parameter_declaration_expected: { code: 1139, category: 1 /* Error */, key: "Type parameter declaration expected." }, - Type_argument_expected: { code: 1140, category: 1 /* Error */, key: "Type argument expected." }, - String_literal_expected: { code: 1141, category: 1 /* Error */, key: "String literal expected." }, - Line_break_not_permitted_here: { code: 1142, category: 1 /* Error */, key: "Line break not permitted here." }, - or_expected: { code: 1144, category: 1 /* Error */, key: "'{' or ';' expected." }, - Modifiers_not_permitted_on_index_signature_members: { code: 1145, category: 1 /* Error */, key: "Modifiers not permitted on index signature members." }, - Declaration_expected: { code: 1146, category: 1 /* Error */, key: "Declaration expected." }, - Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: 1 /* Error */, key: "Import declarations in an internal module cannot reference an external module." }, - Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: 1 /* Error */, key: "Cannot compile external modules unless the '--module' flag is provided." }, - Filename_0_differs_from_already_included_filename_1_only_in_casing: { code: 1149, category: 1 /* Error */, key: "Filename '{0}' differs from already included filename '{1}' only in casing" }, - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: 1 /* Error */, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: 1 /* Error */, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: 1 /* Error */, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: 1 /* Error */, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_must_be_initialized: { code: 1155, category: 1 /* Error */, key: "'const' declarations must be initialized" }, - const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1 /* Error */, key: "'const' declarations can only be declared inside a block." }, - let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1 /* Error */, key: "'let' declarations can only be declared inside a block." }, - Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: 1 /* Error */, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, - Unterminated_template_literal: { code: 1160, category: 1 /* Error */, key: "Unterminated template literal." }, - Unterminated_regular_expression_literal: { code: 1161, category: 1 /* Error */, key: "Unterminated regular expression literal." }, - An_object_member_cannot_be_declared_optional: { code: 1162, category: 1 /* Error */, key: "An object member cannot be declared optional." }, - yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1 /* Error */, key: "'yield' expression must be contained_within a generator declaration." }, - Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: 1 /* Error */, key: "Computed property names are not allowed in enums." }, - Computed_property_names_are_not_allowed_in_an_ambient_context: { code: 1165, category: 1 /* Error */, key: "Computed property names are not allowed in an ambient context." }, - Computed_property_names_are_not_allowed_in_class_property_declarations: { code: 1166, category: 1 /* Error */, key: "Computed property names are not allowed in class property declarations." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: 1 /* Error */, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, - Computed_property_names_are_not_allowed_in_method_overloads: { code: 1168, category: 1 /* Error */, key: "Computed property names are not allowed in method overloads." }, - Computed_property_names_are_not_allowed_in_interfaces: { code: 1169, category: 1 /* Error */, key: "Computed property names are not allowed in interfaces." }, - Computed_property_names_are_not_allowed_in_type_literals: { code: 1170, category: 1 /* Error */, key: "Computed property names are not allowed in type literals." }, - A_comma_expression_is_not_allowed_in_a_computed_property_name: { code: 1171, category: 1 /* Error */, key: "A comma expression is not allowed in a computed property name." }, - extends_clause_already_seen: { code: 1172, category: 1 /* Error */, key: "'extends' clause already seen." }, - extends_clause_must_precede_implements_clause: { code: 1173, category: 1 /* Error */, key: "'extends' clause must precede 'implements' clause." }, - Classes_can_only_extend_a_single_class: { code: 1174, category: 1 /* Error */, key: "Classes can only extend a single class." }, - implements_clause_already_seen: { code: 1175, category: 1 /* Error */, key: "'implements' clause already seen." }, - Interface_declaration_cannot_have_implements_clause: { code: 1176, category: 1 /* Error */, key: "Interface declaration cannot have 'implements' clause." }, - Binary_digit_expected: { code: 1177, category: 1 /* Error */, key: "Binary digit expected." }, - Octal_digit_expected: { code: 1178, category: 1 /* Error */, key: "Octal digit expected." }, - Unexpected_token_expected: { code: 1179, category: 1 /* Error */, key: "Unexpected token. '{' expected." }, - Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." }, - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, - Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." }, - Circular_definition_of_import_alias_0: { code: 2303, category: 1 /* Error */, key: "Circular definition of import alias '{0}'." }, - Cannot_find_name_0: { code: 2304, category: 1 /* Error */, key: "Cannot find name '{0}'." }, - Module_0_has_no_exported_member_1: { code: 2305, category: 1 /* Error */, key: "Module '{0}' has no exported member '{1}'." }, - File_0_is_not_an_external_module: { code: 2306, category: 1 /* Error */, key: "File '{0}' is not an external module." }, - Cannot_find_external_module_0: { code: 2307, category: 1 /* Error */, key: "Cannot find external module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: 1 /* Error */, key: "A module cannot have more than one export assignment." }, - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: 1 /* Error */, key: "An export assignment cannot be used in a module with other exported elements." }, - Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: 1 /* Error */, key: "Type '{0}' recursively references itself as a base type." }, - A_class_may_only_extend_another_class: { code: 2311, category: 1 /* Error */, key: "A class may only extend another class." }, - An_interface_may_only_extend_a_class_or_another_interface: { code: 2312, category: 1 /* Error */, key: "An interface may only extend a class or another interface." }, - Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list: { code: 2313, category: 1 /* Error */, key: "Constraint of a type parameter cannot reference any type parameter from the same type parameter list." }, - Generic_type_0_requires_1_type_argument_s: { code: 2314, category: 1 /* Error */, key: "Generic type '{0}' requires {1} type argument(s)." }, - Type_0_is_not_generic: { code: 2315, category: 1 /* Error */, key: "Type '{0}' is not generic." }, - Global_type_0_must_be_a_class_or_interface_type: { code: 2316, category: 1 /* Error */, key: "Global type '{0}' must be a class or interface type." }, - Global_type_0_must_have_1_type_parameter_s: { code: 2317, category: 1 /* Error */, key: "Global type '{0}' must have {1} type parameter(s)." }, - Cannot_find_global_type_0: { code: 2318, category: 1 /* Error */, key: "Cannot find global type '{0}'." }, - Named_properties_0_of_types_1_and_2_are_not_identical: { code: 2319, category: 1 /* Error */, key: "Named properties '{0}' of types '{1}' and '{2}' are not identical." }, - Interface_0_cannot_simultaneously_extend_types_1_and_2: { code: 2320, category: 1 /* Error */, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'." }, - Excessive_stack_depth_comparing_types_0_and_1: { code: 2321, category: 1 /* Error */, key: "Excessive stack depth comparing types '{0}' and '{1}'." }, - Type_0_is_not_assignable_to_type_1: { code: 2322, category: 1 /* Error */, key: "Type '{0}' is not assignable to type '{1}'." }, - Property_0_is_missing_in_type_1: { code: 2324, category: 1 /* Error */, key: "Property '{0}' is missing in type '{1}'." }, - Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: 1 /* Error */, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, - Types_of_property_0_are_incompatible: { code: 2326, category: 1 /* Error */, key: "Types of property '{0}' are incompatible." }, - Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: 1 /* Error */, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, - Types_of_parameters_0_and_1_are_incompatible: { code: 2328, category: 1 /* Error */, key: "Types of parameters '{0}' and '{1}' are incompatible." }, - Index_signature_is_missing_in_type_0: { code: 2329, category: 1 /* Error */, key: "Index signature is missing in type '{0}'." }, - Index_signatures_are_incompatible: { code: 2330, category: 1 /* Error */, key: "Index signatures are incompatible." }, - this_cannot_be_referenced_in_a_module_body: { code: 2331, category: 1 /* Error */, key: "'this' cannot be referenced in a module body." }, - this_cannot_be_referenced_in_current_location: { code: 2332, category: 1 /* Error */, key: "'this' cannot be referenced in current location." }, - this_cannot_be_referenced_in_constructor_arguments: { code: 2333, category: 1 /* Error */, key: "'this' cannot be referenced in constructor arguments." }, - this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: 1 /* Error */, key: "'this' cannot be referenced in a static property initializer." }, - super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: 1 /* Error */, key: "'super' can only be referenced in a derived class." }, - super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: 1 /* Error */, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: 1 /* Error */, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: 1 /* Error */, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, - Property_0_does_not_exist_on_type_1: { code: 2339, category: 1 /* Error */, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: 1 /* Error */, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, - Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: 1 /* Error */, key: "Property '{0}' is private and only accessible within class '{1}'." }, - An_index_expression_argument_must_be_of_type_string_number_or_any: { code: 2342, category: 1 /* Error */, key: "An index expression argument must be of type 'string', 'number', or 'any'." }, - Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: 1 /* Error */, key: "Type '{0}' does not satisfy the constraint '{1}'." }, - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: 1 /* Error */, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." }, - Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: 1 /* Error */, key: "Supplied parameters do not match any signature of call target." }, - Untyped_function_calls_may_not_accept_type_arguments: { code: 2347, category: 1 /* Error */, key: "Untyped function calls may not accept type arguments." }, - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: { code: 2348, category: 1 /* Error */, key: "Value of type '{0}' is not callable. Did you mean to include 'new'?" }, - Cannot_invoke_an_expression_whose_type_lacks_a_call_signature: { code: 2349, category: 1 /* Error */, key: "Cannot invoke an expression whose type lacks a call signature." }, - Only_a_void_function_can_be_called_with_the_new_keyword: { code: 2350, category: 1 /* Error */, key: "Only a void function can be called with the 'new' keyword." }, - Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: 1 /* Error */, key: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, - Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: 1 /* Error */, key: "Neither type '{0}' nor type '{1}' is assignable to the other." }, - No_best_common_type_exists_among_return_expressions: { code: 2354, category: 1 /* Error */, key: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: 1 /* Error */, key: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, - An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: 1 /* Error */, key: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: 1 /* Error */, key: "The operand of an increment or decrement operator must be a variable, property or indexer." }, - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: 1 /* Error */, key: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: 1 /* Error */, key: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, - The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number: { code: 2360, category: 1 /* Error */, key: "The left-hand side of an 'in' expression must be of types 'any', 'string' or 'number'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: 1 /* Error */, key: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: 1 /* Error */, key: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: 1 /* Error */, key: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, - Invalid_left_hand_side_of_assignment_expression: { code: 2364, category: 1 /* Error */, key: "Invalid left-hand side of assignment expression." }, - Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: 1 /* Error */, key: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: 1 /* Error */, key: "Type parameter name cannot be '{0}'" }, - A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: 1 /* Error */, key: "A parameter property is only allowed in a constructor implementation." }, - A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: 1 /* Error */, key: "A rest parameter must be of an array type." }, - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: 1 /* Error */, key: "A parameter initializer is only allowed in a function or constructor implementation." }, - Parameter_0_cannot_be_referenced_in_its_initializer: { code: 2372, category: 1 /* Error */, key: "Parameter '{0}' cannot be referenced in its initializer." }, - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2373, category: 1 /* Error */, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." }, - Duplicate_string_index_signature: { code: 2374, category: 1 /* Error */, key: "Duplicate string index signature." }, - Duplicate_number_index_signature: { code: 2375, category: 1 /* Error */, key: "Duplicate number index signature." }, - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: 1 /* Error */, key: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, - Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: 1 /* Error */, key: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: 1 /* Error */, key: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, - Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: 1 /* Error */, key: "Getter and setter accessors do not agree in visibility." }, - get_and_set_accessor_must_have_the_same_type: { code: 2380, category: 1 /* Error */, key: "'get' and 'set' accessor must have the same type." }, - A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: 1 /* Error */, key: "A signature with an implementation cannot use a string literal type." }, - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: 1 /* Error */, key: "Specialized overload signature is not assignable to any non-specialized signature." }, - Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: 1 /* Error */, key: "Overload signatures must all be exported or not exported." }, - Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: 1 /* Error */, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: 1 /* Error */, key: "Overload signatures must all be public, private or protected." }, - Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: 1 /* Error */, key: "Overload signatures must all be optional or required." }, - Function_overload_must_be_static: { code: 2387, category: 1 /* Error */, key: "Function overload must be static." }, - Function_overload_must_not_be_static: { code: 2388, category: 1 /* Error */, key: "Function overload must not be static." }, - Function_implementation_name_must_be_0: { code: 2389, category: 1 /* Error */, key: "Function implementation name must be '{0}'." }, - Constructor_implementation_is_missing: { code: 2390, category: 1 /* Error */, key: "Constructor implementation is missing." }, - Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: 2391, category: 1 /* Error */, key: "Function implementation is missing or not immediately following the declaration." }, - Multiple_constructor_implementations_are_not_allowed: { code: 2392, category: 1 /* Error */, key: "Multiple constructor implementations are not allowed." }, - Duplicate_function_implementation: { code: 2393, category: 1 /* Error */, key: "Duplicate function implementation." }, - Overload_signature_is_not_compatible_with_function_implementation: { code: 2394, category: 1 /* Error */, key: "Overload signature is not compatible with function implementation." }, - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2395, category: 1 /* Error */, key: "Individual declarations in merged declaration {0} must be all exported or all local." }, - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: { code: 2396, category: 1 /* Error */, key: "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters." }, - Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter: { code: 2397, category: 1 /* Error */, key: "Duplicate identifier '_i'. Compiler uses '_i' to initialize rest parameter." }, - Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter: { code: 2398, category: 1 /* Error */, key: "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter." }, - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: { code: 2399, category: 1 /* Error */, key: "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference." }, - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: { code: 2400, category: 1 /* Error */, key: "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference." }, - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: { code: 2401, category: 1 /* Error */, key: "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference." }, - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: { code: 2402, category: 1 /* Error */, key: "Expression resolves to '_super' that compiler uses to capture base class reference." }, - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2403, category: 1 /* Error */, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." }, - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: { code: 2404, category: 1 /* Error */, key: "The left-hand side of a 'for...in' statement cannot use a type annotation." }, - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: { code: 2405, category: 1 /* Error */, key: "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'." }, - Invalid_left_hand_side_in_for_in_statement: { code: 2406, category: 1 /* Error */, key: "Invalid left-hand side in 'for...in' statement." }, - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: 1 /* Error */, key: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, - Setters_cannot_return_a_value: { code: 2408, category: 1 /* Error */, key: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: 1 /* Error */, key: "Return type of constructor signature must be assignable to the instance type of the class" }, - All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2410, category: 1 /* Error */, key: "All symbols within a 'with' block will be resolved to 'any'." }, - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: 1 /* Error */, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: 1 /* Error */, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: 1 /* Error */, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - Class_name_cannot_be_0: { code: 2414, category: 1 /* Error */, key: "Class name cannot be '{0}'" }, - Class_0_incorrectly_extends_base_class_1: { code: 2415, category: 1 /* Error */, key: "Class '{0}' incorrectly extends base class '{1}'." }, - Class_static_side_0_incorrectly_extends_base_class_static_side_1: { code: 2417, category: 1 /* Error */, key: "Class static side '{0}' incorrectly extends base class static side '{1}'." }, - Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0: { code: 2419, category: 1 /* Error */, key: "Type name '{0}' in extends clause does not reference constructor function for '{0}'." }, - Class_0_incorrectly_implements_interface_1: { code: 2420, category: 1 /* Error */, key: "Class '{0}' incorrectly implements interface '{1}'." }, - A_class_may_only_implement_another_class_or_interface: { code: 2422, category: 1 /* Error */, key: "A class may only implement another class or interface." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: { code: 2423, category: 1 /* Error */, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor." }, - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: 1 /* Error */, key: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2425, category: 1 /* Error */, key: "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function." }, - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: { code: 2426, category: 1 /* Error */, key: "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function." }, - Interface_name_cannot_be_0: { code: 2427, category: 1 /* Error */, key: "Interface name cannot be '{0}'" }, - All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2428, category: 1 /* Error */, key: "All declarations of an interface must have identical type parameters." }, - Interface_0_incorrectly_extends_interface_1: { code: 2430, category: 1 /* Error */, key: "Interface '{0}' incorrectly extends interface '{1}'." }, - Enum_name_cannot_be_0: { code: 2431, category: 1 /* Error */, key: "Enum name cannot be '{0}'" }, - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: { code: 2432, category: 1 /* Error */, key: "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element." }, - A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: 1 /* Error */, key: "A module declaration cannot be in a different file from a class or function with which it is merged" }, - A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: 1 /* Error */, key: "A module declaration cannot be located prior to a class or function with which it is merged" }, - Ambient_external_modules_cannot_be_nested_in_other_modules: { code: 2435, category: 1 /* Error */, key: "Ambient external modules cannot be nested in other modules." }, - Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: 1 /* Error */, key: "Ambient external module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: 1 /* Error */, key: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: 1 /* Error */, key: "Import name cannot be '{0}'" }, - Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: 1 /* Error */, key: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: 1 /* Error */, key: "Import declaration conflicts with local declaration of '{0}'" }, - Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: 1 /* Error */, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, - Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: 1 /* Error */, key: "Types have separate declarations of a private property '{0}'." }, - Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: 1 /* Error */, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, - Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: 1 /* Error */, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, - Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: 1 /* Error */, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: 1 /* Error */, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, - The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: 1 /* Error */, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, - Block_scoped_variable_0_used_before_its_declaration: { code: 2448, category: 1 /* Error */, key: "Block-scoped variable '{0}' used before its declaration.", isEarly: true }, - The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant: { code: 2449, category: 1 /* Error */, key: "The operand of an increment or decrement operator cannot be a constant.", isEarly: true }, - Left_hand_side_of_assignment_expression_cannot_be_a_constant: { code: 2450, category: 1 /* Error */, key: "Left-hand side of assignment expression cannot be a constant.", isEarly: true }, - Cannot_redeclare_block_scoped_variable_0: { code: 2451, category: 1 /* Error */, key: "Cannot redeclare block-scoped variable '{0}'.", isEarly: true }, - An_enum_member_cannot_have_a_numeric_name: { code: 2452, category: 1 /* Error */, key: "An enum member cannot have a numeric name." }, - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: 1 /* Error */, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: 1 /* Error */, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, - Type_alias_0_circularly_references_itself: { code: 2456, category: 1 /* Error */, key: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: 1 /* Error */, key: "Type alias name cannot be '{0}'" }, - An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: 1 /* Error */, key: "An AMD module cannot have multiple name assignments." }, - Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." }, - Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, - Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: 1 /* Error */, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: 1 /* Error */, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: 1 /* Error */, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: 1 /* Error */, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: 1 /* Error */, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: 1 /* Error */, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: 1 /* Error */, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." }, - Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: 1 /* Error */, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: 1 /* Error */, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." }, - Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: 1 /* Error */, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." }, - Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: 1 /* Error */, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, - Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: 1 /* Error */, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." }, - Exported_variable_0_has_or_is_using_private_name_1: { code: 4025, category: 1 /* Error */, key: "Exported variable '{0}' has or is using private name '{1}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4026, category: 1 /* Error */, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4027, category: 1 /* Error */, key: "Public static property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_static_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4028, category: 1 /* Error */, key: "Public static property '{0}' of exported class has or is using private name '{1}'." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4029, category: 1 /* Error */, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4030, category: 1 /* Error */, key: "Public property '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, - Public_property_0_of_exported_class_has_or_is_using_private_name_1: { code: 4031, category: 1 /* Error */, key: "Public property '{0}' of exported class has or is using private name '{1}'." }, - Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4032, category: 1 /* Error */, key: "Property '{0}' of exported interface has or is using name '{1}' from private module '{2}'." }, - Property_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4033, category: 1 /* Error */, key: "Property '{0}' of exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4034, category: 1 /* Error */, key: "Parameter '{0}' of public static property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4035, category: 1 /* Error */, key: "Parameter '{0}' of public static property setter from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4036, category: 1 /* Error */, key: "Parameter '{0}' of public property setter from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1: { code: 4037, category: 1 /* Error */, key: "Parameter '{0}' of public property setter from exported class has or is using private name '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4038, category: 1 /* Error */, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4039, category: 1 /* Error */, key: "Return type of public static property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4040, category: 1 /* Error */, key: "Return type of public static property getter from exported class has or is using private name '{0}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4041, category: 1 /* Error */, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4042, category: 1 /* Error */, key: "Return type of public property getter from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0: { code: 4043, category: 1 /* Error */, key: "Return type of public property getter from exported class has or is using private name '{0}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4044, category: 1 /* Error */, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4045, category: 1 /* Error */, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4046, category: 1 /* Error */, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4047, category: 1 /* Error */, key: "Return type of call signature from exported interface has or is using private name '{0}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4048, category: 1 /* Error */, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 4049, category: 1 /* Error */, key: "Return type of index signature from exported interface has or is using private name '{0}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4050, category: 1 /* Error */, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4051, category: 1 /* Error */, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 4052, category: 1 /* Error */, key: "Return type of public static method from exported class has or is using private name '{0}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4053, category: 1 /* Error */, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 4054, category: 1 /* Error */, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." }, - Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 4055, category: 1 /* Error */, key: "Return type of public method from exported class has or is using private name '{0}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 4056, category: 1 /* Error */, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." }, - Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 4057, category: 1 /* Error */, key: "Return type of method from exported interface has or is using private name '{0}'." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 4058, category: 1 /* Error */, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, - Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 4059, category: 1 /* Error */, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." }, - Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 4060, category: 1 /* Error */, key: "Return type of exported function has or is using private name '{0}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4061, category: 1 /* Error */, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4062, category: 1 /* Error */, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1: { code: 4063, category: 1 /* Error */, key: "Parameter '{0}' of constructor from exported class has or is using private name '{1}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4064, category: 1 /* Error */, key: "Parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4065, category: 1 /* Error */, key: "Parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4066, category: 1 /* Error */, key: "Parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4067, category: 1 /* Error */, key: "Parameter '{0}' of call signature from exported interface has or is using private name '{1}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4068, category: 1 /* Error */, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4069, category: 1 /* Error */, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4070, category: 1 /* Error */, key: "Parameter '{0}' of public static method from exported class has or is using private name '{1}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4071, category: 1 /* Error */, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4072, category: 1 /* Error */, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4073, category: 1 /* Error */, key: "Parameter '{0}' of public method from exported class has or is using private name '{1}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4074, category: 1 /* Error */, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4075, category: 1 /* Error */, key: "Parameter '{0}' of method from exported interface has or is using private name '{1}'." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: 1 /* Error */, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, - Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: 1 /* Error */, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." }, - Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: 1 /* Error */, key: "Parameter '{0}' of exported function has or is using private name '{1}'." }, - Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using private name '{1}'." }, - Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: 1 /* Error */, key: "Enum declarations must all be const or non-const." }, - In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: 1 /* Error */, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true }, - const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 4084, category: 1 /* Error */, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, - Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: 1 /* Error */, key: "Index expression arguments in 'const' enums must be of type 'string'." }, - const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 4086, category: 1 /* Error */, key: "'const' enum member initializer was evaluated to a non-finite value." }, - const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 4087, category: 1 /* Error */, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, - The_current_host_does_not_support_the_0_option: { code: 5001, category: 1 /* Error */, key: "The current host does not support the '{0}' option." }, - Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: 1 /* Error */, key: "Cannot find the common subdirectory path for the input files." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: 1 /* Error */, key: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: 1 /* Error */, key: "Unsupported file encoding." }, - Unknown_compiler_option_0: { code: 5023, category: 1 /* Error */, key: "Unknown compiler option '{0}'." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: 1 /* Error */, key: "Could not write file '{0}': {1}" }, - Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: 1 /* Error */, key: "Option mapRoot cannot be specified without specifying sourcemap option." }, - Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: 1 /* Error */, key: "Option sourceRoot cannot be specified without specifying sourcemap option." }, - Concatenate_and_emit_output_to_single_file: { code: 6001, category: 2 /* Message */, key: "Concatenate and emit output to single file." }, - Generates_corresponding_d_ts_file: { code: 6002, category: 2 /* Message */, key: "Generates corresponding '.d.ts' file." }, - Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: 2 /* Message */, key: "Specifies the location where debugger should locate map files instead of generated locations." }, - Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: 2 /* Message */, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, - Watch_input_files: { code: 6005, category: 2 /* Message */, key: "Watch input files." }, - Redirect_output_structure_to_the_directory: { code: 6006, category: 2 /* Message */, key: "Redirect output structure to the directory." }, - Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: 2 /* Message */, key: "Do not erase const enum declarations in generated code." }, - Do_not_emit_outputs_if_any_type_checking_errors_were_reported: { code: 6008, category: 2 /* Message */, key: "Do not emit outputs if any type checking errors were reported." }, - Do_not_emit_comments_to_output: { code: 6009, category: 2 /* Message */, key: "Do not emit comments to output." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: 2 /* Message */, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, - Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: 2 /* Message */, key: "Specify module code generation: 'commonjs' or 'amd'" }, - Print_this_message: { code: 6017, category: 2 /* Message */, key: "Print this message." }, - Print_the_compiler_s_version: { code: 6019, category: 2 /* Message */, key: "Print the compiler's version." }, - Syntax_Colon_0: { code: 6023, category: 2 /* Message */, key: "Syntax: {0}" }, - options: { code: 6024, category: 2 /* Message */, key: "options" }, - file: { code: 6025, category: 2 /* Message */, key: "file" }, - Examples_Colon_0: { code: 6026, category: 2 /* Message */, key: "Examples: {0}" }, - Options_Colon: { code: 6027, category: 2 /* Message */, key: "Options:" }, - Version_0: { code: 6029, category: 2 /* Message */, key: "Version {0}" }, - Insert_command_line_options_and_files_from_a_file: { code: 6030, category: 2 /* Message */, key: "Insert command line options and files from a file." }, - File_change_detected_Compiling: { code: 6032, category: 2 /* Message */, key: "File change detected. Compiling..." }, - KIND: { code: 6034, category: 2 /* Message */, key: "KIND" }, - FILE: { code: 6035, category: 2 /* Message */, key: "FILE" }, - VERSION: { code: 6036, category: 2 /* Message */, key: "VERSION" }, - LOCATION: { code: 6037, category: 2 /* Message */, key: "LOCATION" }, - DIRECTORY: { code: 6038, category: 2 /* Message */, key: "DIRECTORY" }, - Compilation_complete_Watching_for_file_changes: { code: 6042, category: 2 /* Message */, key: "Compilation complete. Watching for file changes." }, - Generates_corresponding_map_file: { code: 6043, category: 2 /* Message */, key: "Generates corresponding '.map' file." }, - Compiler_option_0_expects_an_argument: { code: 6044, category: 1 /* Error */, key: "Compiler option '{0}' expects an argument." }, - Unterminated_quoted_string_in_response_file_0: { code: 6045, category: 1 /* Error */, key: "Unterminated quoted string in response file '{0}'." }, - Argument_for_module_option_must_be_commonjs_or_amd: { code: 6046, category: 1 /* Error */, key: "Argument for '--module' option must be 'commonjs' or 'amd'." }, - Argument_for_target_option_must_be_es3_es5_or_es6: { code: 6047, category: 1 /* Error */, key: "Argument for '--target' option must be 'es3', 'es5', or 'es6'." }, - Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: { code: 6048, category: 1 /* Error */, key: "Locale must be of the form or -. For example '{0}' or '{1}'." }, - Unsupported_locale_0: { code: 6049, category: 1 /* Error */, key: "Unsupported locale '{0}'." }, - Unable_to_open_file_0: { code: 6050, category: 1 /* Error */, key: "Unable to open file '{0}'." }, - Corrupted_locale_file_0: { code: 6051, category: 1 /* Error */, key: "Corrupted locale file {0}." }, - Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: 2 /* Message */, key: "Warn on expressions and declarations with an implied 'any' type." }, - File_0_not_found: { code: 6053, category: 1 /* Error */, key: "File '{0}' not found." }, - File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: 1 /* Error */, key: "File '{0}' must have extension '.ts' or '.d.ts'." }, - Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: 2 /* Message */, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, - Variable_0_implicitly_has_an_1_type: { code: 7005, category: 1 /* Error */, key: "Variable '{0}' implicitly has an '{1}' type." }, - Parameter_0_implicitly_has_an_1_type: { code: 7006, category: 1 /* Error */, key: "Parameter '{0}' implicitly has an '{1}' type." }, - Member_0_implicitly_has_an_1_type: { code: 7008, category: 1 /* Error */, key: "Member '{0}' implicitly has an '{1}' type." }, - new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type: { code: 7009, category: 1 /* Error */, key: "'new' expression, whose target lacks a construct signature, implicitly has an 'any' type." }, - _0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type: { code: 7010, category: 1 /* Error */, key: "'{0}', which lacks return-type annotation, implicitly has an '{1}' return type." }, - Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type: { code: 7011, category: 1 /* Error */, key: "Function expression, which lacks return-type annotation, implicitly has an '{0}' return type." }, - Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7013, category: 1 /* Error */, key: "Construct signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation: { code: 7016, category: 1 /* Error */, key: "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation." }, - Index_signature_of_object_type_implicitly_has_an_any_type: { code: 7017, category: 1 /* Error */, key: "Index signature of object type implicitly has an 'any' type." }, - Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: 1 /* Error */, key: "Object literal's property '{0}' implicitly has an '{1}' type." }, - Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: 1 /* Error */, key: "Rest parameter '{0}' implicitly has an 'any[]' type." }, - Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: 1 /* Error */, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." }, - _0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 7021, category: 1 /* Error */, key: "'{0}' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation." }, - _0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: 1 /* Error */, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." }, - _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: 1 /* Error */, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: 1 /* Error */, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, - You_cannot_rename_this_element: { code: 8000, category: 1 /* Error */, key: "You cannot rename this element." }, - yield_expressions_are_not_currently_supported: { code: 9000, category: 1 /* Error */, key: "'yield' expressions are not currently supported." }, - Generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "Generators are not currently supported." }, - Computed_property_names_are_not_currently_supported: { code: 9002, category: 1 /* Error */, key: "Computed property names are not currently supported." } - }; -})(ts || (ts = {})); -var ts; -(function (ts) { - var textToToken = { - "any": 109 /* AnyKeyword */, - "boolean": 110 /* BooleanKeyword */, - "break": 64 /* BreakKeyword */, - "case": 65 /* CaseKeyword */, - "catch": 66 /* CatchKeyword */, - "class": 67 /* ClassKeyword */, - "continue": 69 /* ContinueKeyword */, - "const": 68 /* ConstKeyword */, - "constructor": 111 /* ConstructorKeyword */, - "debugger": 70 /* DebuggerKeyword */, - "declare": 112 /* DeclareKeyword */, - "default": 71 /* DefaultKeyword */, - "delete": 72 /* DeleteKeyword */, - "do": 73 /* DoKeyword */, - "else": 74 /* ElseKeyword */, - "enum": 75 /* EnumKeyword */, - "export": 76 /* ExportKeyword */, - "extends": 77 /* ExtendsKeyword */, - "false": 78 /* FalseKeyword */, - "finally": 79 /* FinallyKeyword */, - "for": 80 /* ForKeyword */, - "function": 81 /* FunctionKeyword */, - "get": 113 /* GetKeyword */, - "if": 82 /* IfKeyword */, - "implements": 100 /* ImplementsKeyword */, - "import": 83 /* ImportKeyword */, - "in": 84 /* InKeyword */, - "instanceof": 85 /* InstanceOfKeyword */, - "interface": 101 /* InterfaceKeyword */, - "let": 102 /* LetKeyword */, - "module": 114 /* ModuleKeyword */, - "new": 86 /* NewKeyword */, - "null": 87 /* NullKeyword */, - "number": 116 /* NumberKeyword */, - "package": 103 /* PackageKeyword */, - "private": 104 /* PrivateKeyword */, - "protected": 105 /* ProtectedKeyword */, - "public": 106 /* PublicKeyword */, - "require": 115 /* RequireKeyword */, - "return": 88 /* ReturnKeyword */, - "set": 117 /* SetKeyword */, - "static": 107 /* StaticKeyword */, - "string": 118 /* StringKeyword */, - "super": 89 /* SuperKeyword */, - "switch": 90 /* SwitchKeyword */, - "this": 91 /* ThisKeyword */, - "throw": 92 /* ThrowKeyword */, - "true": 93 /* TrueKeyword */, - "try": 94 /* TryKeyword */, - "type": 119 /* TypeKeyword */, - "typeof": 95 /* TypeOfKeyword */, - "var": 96 /* VarKeyword */, - "void": 97 /* VoidKeyword */, - "while": 98 /* WhileKeyword */, - "with": 99 /* WithKeyword */, - "yield": 108 /* YieldKeyword */, - "{": 13 /* OpenBraceToken */, - "}": 14 /* CloseBraceToken */, - "(": 15 /* OpenParenToken */, - ")": 16 /* CloseParenToken */, - "[": 17 /* OpenBracketToken */, - "]": 18 /* CloseBracketToken */, - ".": 19 /* DotToken */, - "...": 20 /* DotDotDotToken */, - ";": 21 /* SemicolonToken */, - ",": 22 /* CommaToken */, - "<": 23 /* LessThanToken */, - ">": 24 /* GreaterThanToken */, - "<=": 25 /* LessThanEqualsToken */, - ">=": 26 /* GreaterThanEqualsToken */, - "==": 27 /* EqualsEqualsToken */, - "!=": 28 /* ExclamationEqualsToken */, - "===": 29 /* EqualsEqualsEqualsToken */, - "!==": 30 /* ExclamationEqualsEqualsToken */, - "=>": 31 /* EqualsGreaterThanToken */, - "+": 32 /* PlusToken */, - "-": 33 /* MinusToken */, - "*": 34 /* AsteriskToken */, - "/": 35 /* SlashToken */, - "%": 36 /* PercentToken */, - "++": 37 /* PlusPlusToken */, - "--": 38 /* MinusMinusToken */, - "<<": 39 /* LessThanLessThanToken */, - ">>": 40 /* GreaterThanGreaterThanToken */, - ">>>": 41 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 42 /* AmpersandToken */, - "|": 43 /* BarToken */, - "^": 44 /* CaretToken */, - "!": 45 /* ExclamationToken */, - "~": 46 /* TildeToken */, - "&&": 47 /* AmpersandAmpersandToken */, - "||": 48 /* BarBarToken */, - "?": 49 /* QuestionToken */, - ":": 50 /* ColonToken */, - "=": 51 /* EqualsToken */, - "+=": 52 /* PlusEqualsToken */, - "-=": 53 /* MinusEqualsToken */, - "*=": 54 /* AsteriskEqualsToken */, - "/=": 55 /* SlashEqualsToken */, - "%=": 56 /* PercentEqualsToken */, - "<<=": 57 /* LessThanLessThanEqualsToken */, - ">>=": 58 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 60 /* AmpersandEqualsToken */, - "|=": 61 /* BarEqualsToken */, - "^=": 62 /* CaretEqualsToken */ - }; - var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; - function lookupInUnicodeMap(code, map) { - if (code < map[0]) { - return false; - } - var lo = 0; - var hi = map.length; - var mid; - while (lo + 1 < hi) { - mid = lo + (hi - lo) / 2; - mid -= mid % 2; - if (map[mid] <= code && code <= map[mid + 1]) { - return true; - } - if (code < map[mid]) { - hi = mid; - } - else { - lo = mid + 2; - } - } - return false; - } - function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion === 0 /* ES3 */ ? lookupInUnicodeMap(code, unicodeES3IdentifierStart) : lookupInUnicodeMap(code, unicodeES5IdentifierStart); - } - function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion === 0 /* ES3 */ ? lookupInUnicodeMap(code, unicodeES3IdentifierPart) : lookupInUnicodeMap(code, unicodeES5IdentifierPart); - } - function makeReverseMap(source) { - var result = []; - for (var name in source) { - if (source.hasOwnProperty(name)) { - result[source[name]] = name; - } - } - return result; - } - var tokenStrings = makeReverseMap(textToToken); - function tokenToString(t) { - return tokenStrings[t]; - } - ts.tokenToString = tokenToString; - function computeLineStarts(text) { - var result = new Array(); - var pos = 0; - var lineStart = 0; - while (pos < text.length) { - var ch = text.charCodeAt(pos++); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { - pos++; - } - case 10 /* lineFeed */: - result.push(lineStart); - lineStart = pos; - break; - default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { - result.push(lineStart); - lineStart = pos; - } - break; - } - } - result.push(lineStart); - return result; - } - ts.computeLineStarts = computeLineStarts; - function getPositionFromLineAndCharacter(lineStarts, line, character) { - ts.Debug.assert(line > 0); - return lineStarts[line - 1] + character - 1; - } - ts.getPositionFromLineAndCharacter = getPositionFromLineAndCharacter; - function getLineAndCharacterOfPosition(lineStarts, position) { - var lineNumber = ts.binarySearch(lineStarts, position); - if (lineNumber < 0) { - lineNumber = (~lineNumber) - 1; - } - return { - line: lineNumber + 1, - character: position - lineStarts[lineNumber] + 1 - }; - } - ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - function positionToLineAndCharacter(text, pos) { - var lineStarts = computeLineStarts(text); - return getLineAndCharacterOfPosition(lineStarts, pos); - } - ts.positionToLineAndCharacter = positionToLineAndCharacter; - var hasOwnProperty = Object.prototype.hasOwnProperty; - function isWhiteSpace(ch) { - return ch === 32 /* space */ || ch === 9 /* tab */ || ch === 11 /* verticalTab */ || ch === 12 /* formFeed */ || ch === 160 /* nonBreakingSpace */ || ch === 5760 /* ogham */ || ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || ch === 8239 /* narrowNoBreakSpace */ || ch === 8287 /* mathematicalSpace */ || ch === 12288 /* ideographicSpace */ || ch === 65279 /* byteOrderMark */; - } - ts.isWhiteSpace = isWhiteSpace; - function isLineBreak(ch) { - return ch === 10 /* lineFeed */ || ch === 13 /* carriageReturn */ || ch === 8232 /* lineSeparator */ || ch === 8233 /* paragraphSeparator */ || ch === 133 /* nextLine */; - } - ts.isLineBreak = isLineBreak; - function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; - } - function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; - } - ts.isOctalDigit = isOctalDigit; - function skipTrivia(text, pos, stopAfterLineBreak) { - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) - pos++; - case 10 /* lineFeed */: - pos++; - if (stopAfterLineBreak) - return pos; - continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - pos++; - continue; - case 47 /* slash */: - if (text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - continue; - } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - pos += 2; - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - break; - } - pos++; - } - continue; - } - break; - default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { - pos++; - continue; - } - break; - } - return pos; - } - } - ts.skipTrivia = skipTrivia; - function getCommentRanges(text, pos, trailing) { - var result; - var collecting = trailing || pos === 0; - while (true) { - var ch = text.charCodeAt(pos); - switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) - pos++; - case 10 /* lineFeed */: - pos++; - if (trailing) { - return result; - } - collecting = true; - if (result && result.length) { - result[result.length - 1].hasTrailingNewLine = true; - } - continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - pos++; - continue; - case 47 /* slash */: - var nextChar = text.charCodeAt(pos + 1); - var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var startPos = pos; - pos += 2; - if (nextChar === 47 /* slash */) { - while (pos < text.length) { - if (isLineBreak(text.charCodeAt(pos))) { - hasTrailingNewLine = true; - break; - } - pos++; - } - } - else { - while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - break; - } - pos++; - } - } - if (collecting) { - if (!result) - result = []; - result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine }); - } - continue; - } - break; - default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch) || isLineBreak(ch))) { - if (result && result.length && isLineBreak(ch)) { - result[result.length - 1].hasTrailingNewLine = true; - } - pos++; - continue; - } - break; - } - return result; - } - } - function getLeadingCommentRanges(text, pos) { - return getCommentRanges(text, pos, false); - } - ts.getLeadingCommentRanges = getLeadingCommentRanges; - function getTrailingCommentRanges(text, pos) { - return getCommentRanges(text, pos, true); - } - ts.getTrailingCommentRanges = getTrailingCommentRanges; - function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); - } - ts.isIdentifierStart = isIdentifierStart; - function isIdentifierPart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); - } - ts.isIdentifierPart = isIdentifierPart; - function createScanner(languageVersion, skipTrivia, text, onError) { - var pos; - var len; - var startPos; - var tokenPos; - var token; - var tokenValue; - var precedingLineBreak; - var tokenIsUnterminated; - function error(message) { - if (onError) { - onError(message); - } - } - function isIdentifierStart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); - } - function isIdentifierPart(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); - } - function scanNumber() { - var start = pos; - while (isDigit(text.charCodeAt(pos))) - pos++; - if (text.charCodeAt(pos) === 46 /* dot */) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - } - var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { - pos++; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) - pos++; - if (isDigit(text.charCodeAt(pos))) { - pos++; - while (isDigit(text.charCodeAt(pos))) - pos++; - end = pos; - } - else { - error(ts.Diagnostics.Digit_expected); - } - } - return +(text.substring(start, end)); - } - function scanOctalDigits() { - var start = pos; - while (isOctalDigit(text.charCodeAt(pos))) { - pos++; - } - return +(text.substring(start, pos)); - } - function scanHexDigits(count, mustMatchCount) { - var digits = 0; - var value = 0; - while (digits < count || !mustMatchCount) { - var ch = text.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { - value = value * 16 + ch - 48 /* _0 */; - } - else if (ch >= 65 /* A */ && ch <= 70 /* F */) { - value = value * 16 + ch - 65 /* A */ + 10; - } - else if (ch >= 97 /* a */ && ch <= 102 /* f */) { - value = value * 16 + ch - 97 /* a */ + 10; - } - else { - break; - } - pos++; - digits++; - } - if (digits < count) { - value = -1; - } - return value; - } - function scanString() { - var quote = text.charCodeAt(pos++); - var result = ""; - var start = pos; - while (true) { - if (pos >= len) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - var ch = text.charCodeAt(pos); - if (ch === quote) { - result += text.substring(start, pos); - pos++; - break; - } - if (ch === 92 /* backslash */) { - result += text.substring(start, pos); - result += scanEscapeSequence(); - start = pos; - continue; - } - if (isLineBreak(ch)) { - result += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_string_literal); - break; - } - pos++; - } - return result; - } - function scanTemplateAndSetTokenValue() { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; - pos++; - var start = pos; - var contents = ""; - var resultingToken; - while (true) { - if (pos >= len) { - contents += text.substring(start, pos); - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; - break; - } - var currChar = text.charCodeAt(pos); - if (currChar === 96 /* backtick */) { - contents += text.substring(start, pos); - pos++; - resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; - break; - } - if (currChar === 36 /* $ */ && pos + 1 < len && text.charCodeAt(pos + 1) === 123 /* openBrace */) { - contents += text.substring(start, pos); - pos += 2; - resultingToken = startedWithBacktick ? 10 /* TemplateHead */ : 11 /* TemplateMiddle */; - break; - } - if (currChar === 92 /* backslash */) { - contents += text.substring(start, pos); - contents += scanEscapeSequence(); - start = pos; - continue; - } - if (currChar === 13 /* carriageReturn */) { - contents += text.substring(start, pos); - if (pos + 1 < len && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { - pos++; - } - pos++; - contents += "\n"; - start = pos; - continue; - } - pos++; - } - ts.Debug.assert(resultingToken !== undefined); - tokenValue = contents; - return resultingToken; - } - function scanEscapeSequence() { - pos++; - if (pos >= len) { - error(ts.Diagnostics.Unexpected_end_of_text); - return ""; - } - var ch = text.charCodeAt(pos++); - switch (ch) { - case 48 /* _0 */: - return "\0"; - case 98 /* b */: - return "\b"; - case 116 /* t */: - return "\t"; - case 110 /* n */: - return "\n"; - case 118 /* v */: - return "\v"; - case 102 /* f */: - return "\f"; - case 114 /* r */: - return "\r"; - case 39 /* singleQuote */: - return "\'"; - case 34 /* doubleQuote */: - return "\""; - case 120 /* x */: - case 117 /* u */: - var ch = scanHexDigits(ch === 120 /* x */ ? 2 : 4, true); - if (ch >= 0) { - return String.fromCharCode(ch); - } - else { - error(ts.Diagnostics.Hexadecimal_digit_expected); - return ""; - } - case 13 /* carriageReturn */: - if (pos < len && text.charCodeAt(pos) === 10 /* lineFeed */) { - pos++; - } - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: - return ""; - default: - return String.fromCharCode(ch); - } - } - function peekUnicodeEscape() { - if (pos + 5 < len && text.charCodeAt(pos + 1) === 117 /* u */) { - var start = pos; - pos += 2; - var value = scanHexDigits(4, true); - pos = start; - return value; - } - return -1; - } - function scanIdentifierParts() { - var result = ""; - var start = pos; - while (pos < len) { - var ch = text.charCodeAt(pos); - if (isIdentifierPart(ch)) { - pos++; - } - else if (ch === 92 /* backslash */) { - ch = peekUnicodeEscape(); - if (!(ch >= 0 && isIdentifierPart(ch))) { - break; - } - result += text.substring(start, pos); - result += String.fromCharCode(ch); - pos += 6; - start = pos; - } - else { - break; - } - } - result += text.substring(start, pos); - return result; - } - function getIdentifierToken() { - var len = tokenValue.length; - if (len >= 2 && len <= 11) { - var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */ && hasOwnProperty.call(textToToken, tokenValue)) { - return token = textToToken[tokenValue]; - } - } - return token = 63 /* Identifier */; - } - function scanBinaryOrOctalDigits(base) { - ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); - var value = 0; - var numberOfDigits = 0; - while (true) { - var ch = text.charCodeAt(pos); - var valueOfCh = ch - 48 /* _0 */; - if (!isDigit(ch) || valueOfCh >= base) { - break; - } - value = value * base + valueOfCh; - pos++; - numberOfDigits++; - } - if (numberOfDigits === 0) { - return -1; - } - return value; - } - function scan() { - startPos = pos; - precedingLineBreak = false; - tokenIsUnterminated = false; - while (true) { - tokenPos = pos; - if (pos >= len) { - return token = 1 /* EndOfFileToken */; - } - var ch = text.charCodeAt(pos); - switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - precedingLineBreak = true; - if (skipTrivia) { - pos++; - continue; - } - else { - if (ch === 13 /* carriageReturn */ && pos + 1 < len && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { - pos += 2; - } - else { - pos++; - } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - if (skipTrivia) { - pos++; - continue; - } - else { - while (pos < len && isWhiteSpace(text.charCodeAt(pos))) { - pos++; - } - return token = 5 /* WhitespaceTrivia */; - } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 30 /* ExclamationEqualsEqualsToken */; - } - return pos += 2, token = 28 /* ExclamationEqualsToken */; - } - return pos++, token = 45 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: - tokenValue = scanString(); - return token = 7 /* StringLiteral */; - case 96 /* backtick */: - return token = scanTemplateAndSetTokenValue(); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* PercentEqualsToken */; - } - return pos++, token = 36 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 47 /* AmpersandAmpersandToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* AmpersandEqualsToken */; - } - return pos++, token = 42 /* AmpersandToken */; - case 40 /* openParen */: - return pos++, token = 15 /* OpenParenToken */; - case 41 /* closeParen */: - return pos++, token = 16 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 54 /* AsteriskEqualsToken */; - } - return pos++, token = 34 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 37 /* PlusPlusToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 52 /* PlusEqualsToken */; - } - return pos++, token = 32 /* PlusToken */; - case 44 /* comma */: - return pos++, token = 22 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 38 /* MinusMinusToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 53 /* MinusEqualsToken */; - } - return pos++, token = 33 /* MinusToken */; - case 46 /* dot */: - if (isDigit(text.charCodeAt(pos + 1))) { - tokenValue = "" + scanNumber(); - return token = 6 /* NumericLiteral */; - } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 20 /* DotDotDotToken */; - } - return pos++, token = 19 /* DotToken */; - case 47 /* slash */: - if (text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - while (pos < len) { - if (isLineBreak(text.charCodeAt(pos))) { - break; - } - pos++; - } - if (skipTrivia) { - continue; - } - else { - return token = 2 /* SingleLineCommentTrivia */; - } - } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - pos += 2; - var commentClosed = false; - while (pos < len) { - var ch = text.charCodeAt(pos); - if (ch === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { - pos += 2; - commentClosed = true; - break; - } - if (isLineBreak(ch)) { - precedingLineBreak = true; - } - pos++; - } - if (!commentClosed) { - error(ts.Diagnostics.Asterisk_Slash_expected); - } - if (skipTrivia) { - continue; - } - else { - tokenIsUnterminated = !commentClosed; - return token = 3 /* MultiLineCommentTrivia */; - } - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* SlashEqualsToken */; - } - return pos++, token = 35 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < len && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { - pos += 2; - var value = scanHexDigits(1, false); - if (value < 0) { - error(ts.Diagnostics.Hexadecimal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return token = 6 /* NumericLiteral */; - } - else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { - pos += 2; - var value = scanBinaryOrOctalDigits(2); - if (value < 0) { - error(ts.Diagnostics.Binary_digit_expected); - value = 0; - } - tokenValue = "" + value; - return 6 /* NumericLiteral */; - } - else if (pos + 2 < len && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { - pos += 2; - var value = scanBinaryOrOctalDigits(8); - if (value < 0) { - error(ts.Diagnostics.Octal_digit_expected); - value = 0; - } - tokenValue = "" + value; - return 6 /* NumericLiteral */; - } - if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) { - tokenValue = "" + scanOctalDigits(); - return token = 6 /* NumericLiteral */; - } - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: - tokenValue = "" + scanNumber(); - return token = 6 /* NumericLiteral */; - case 58 /* colon */: - return pos++, token = 50 /* ColonToken */; - case 59 /* semicolon */: - return pos++, token = 21 /* SemicolonToken */; - case 60 /* lessThan */: - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 57 /* LessThanLessThanEqualsToken */; - } - return pos += 2, token = 39 /* LessThanLessThanToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 25 /* LessThanEqualsToken */; - } - return pos++, token = 23 /* LessThanToken */; - case 61 /* equals */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 29 /* EqualsEqualsEqualsToken */; - } - return pos += 2, token = 27 /* EqualsEqualsToken */; - } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 31 /* EqualsGreaterThanToken */; - } - return pos++, token = 51 /* EqualsToken */; - case 62 /* greaterThan */: - return pos++, token = 24 /* GreaterThanToken */; - case 63 /* question */: - return pos++, token = 49 /* QuestionToken */; - case 91 /* openBracket */: - return pos++, token = 17 /* OpenBracketToken */; - case 93 /* closeBracket */: - return pos++, token = 18 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* CaretEqualsToken */; - } - return pos++, token = 44 /* CaretToken */; - case 123 /* openBrace */: - return pos++, token = 13 /* OpenBraceToken */; - case 124 /* bar */: - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 48 /* BarBarToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* BarEqualsToken */; - } - return pos++, token = 43 /* BarToken */; - case 125 /* closeBrace */: - return pos++, token = 14 /* CloseBraceToken */; - case 126 /* tilde */: - return pos++, token = 46 /* TildeToken */; - case 92 /* backslash */: - var ch = peekUnicodeEscape(); - if (ch >= 0 && isIdentifierStart(ch)) { - pos += 6; - tokenValue = String.fromCharCode(ch) + scanIdentifierParts(); - return token = getIdentifierToken(); - } - error(ts.Diagnostics.Invalid_character); - return pos++, token = 0 /* Unknown */; - default: - if (isIdentifierStart(ch)) { - pos++; - while (pos < len && isIdentifierPart(ch = text.charCodeAt(pos))) - pos++; - tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { - tokenValue += scanIdentifierParts(); - } - return token = getIdentifierToken(); - } - else if (isWhiteSpace(ch)) { - pos++; - continue; - } - else if (isLineBreak(ch)) { - precedingLineBreak = true; - pos++; - continue; - } - error(ts.Diagnostics.Invalid_character); - return pos++, token = 0 /* Unknown */; - } - } - } - function reScanGreaterToken() { - if (token === 24 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */; - } - return pos += 2, token = 41 /* GreaterThanGreaterThanGreaterThanToken */; - } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* GreaterThanGreaterThanEqualsToken */; - } - return pos++, token = 40 /* GreaterThanGreaterThanToken */; - } - if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 26 /* GreaterThanEqualsToken */; - } - } - return token; - } - function reScanSlashToken() { - if (token === 35 /* SlashToken */ || token === 55 /* SlashEqualsToken */) { - var p = tokenPos + 1; - var inEscape = false; - var inCharacterClass = false; - while (true) { - if (p >= len) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - var ch = text.charCodeAt(p); - if (isLineBreak(ch)) { - tokenIsUnterminated = true; - error(ts.Diagnostics.Unterminated_regular_expression_literal); - break; - } - if (inEscape) { - inEscape = false; - } - else if (ch === 47 /* slash */ && !inCharacterClass) { - p++; - break; - } - else if (ch === 91 /* openBracket */) { - inCharacterClass = true; - } - else if (ch === 92 /* backslash */) { - inEscape = true; - } - else if (ch === 93 /* closeBracket */) { - inCharacterClass = false; - } - p++; - } - while (p < len && isIdentifierPart(text.charCodeAt(p))) { - p++; - } - pos = p; - tokenValue = text.substring(tokenPos, pos); - token = 8 /* RegularExpressionLiteral */; - } - return token; - } - function reScanTemplateToken() { - ts.Debug.assert(token === 14 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); - pos = tokenPos; - return token = scanTemplateAndSetTokenValue(); - } - function speculationHelper(callback, isLookahead) { - var savePos = pos; - var saveStartPos = startPos; - var saveTokenPos = tokenPos; - var saveToken = token; - var saveTokenValue = tokenValue; - var savePrecedingLineBreak = precedingLineBreak; - var result = callback(); - if (!result || isLookahead) { - pos = savePos; - startPos = saveStartPos; - tokenPos = saveTokenPos; - token = saveToken; - tokenValue = saveTokenValue; - precedingLineBreak = savePrecedingLineBreak; - } - return result; - } - function lookAhead(callback) { - return speculationHelper(callback, true); - } - function tryScan(callback) { - return speculationHelper(callback, false); - } - function setText(newText) { - text = newText || ""; - len = text.length; - setTextPos(0); - } - function setTextPos(textPos) { - pos = textPos; - startPos = textPos; - tokenPos = textPos; - token = 0 /* Unknown */; - precedingLineBreak = false; - } - setText(text); - return { - getStartPos: function () { return startPos; }, - getTextPos: function () { return pos; }, - getToken: function () { return token; }, - getTokenPos: function () { return tokenPos; }, - getTokenText: function () { return text.substring(tokenPos, pos); }, - getTokenValue: function () { return tokenValue; }, - hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 63 /* Identifier */ || token > 99 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 64 /* FirstReservedWord */ && token <= 99 /* LastReservedWord */; }, - isUnterminated: function () { return tokenIsUnterminated; }, - reScanGreaterToken: reScanGreaterToken, - reScanSlashToken: reScanSlashToken, - reScanTemplateToken: reScanTemplateToken, - scan: scan, - setText: setText, - setTextPos: setTextPos, - tryScan: tryScan, - lookAhead: lookAhead - }; - } - ts.createScanner = createScanner; -})(ts || (ts = {})); -var ts; -(function (ts) { - function getDeclarationOfKind(symbol, kind) { - var declarations = symbol.declarations; - for (var i = 0; i < declarations.length; i++) { - var declaration = declarations[i]; - if (declaration.kind === kind) { - return declaration; - } - } - return undefined; - } - ts.getDeclarationOfKind = getDeclarationOfKind; - var stringWriters = []; - function getSingleLineStringWriter() { - if (stringWriters.length == 0) { - var str = ""; - var writeText = function (text) { return str += text; }; - return { - string: function () { return str; }, - writeKeyword: writeText, - writeOperator: writeText, - writePunctuation: writeText, - writeSpace: writeText, - writeStringLiteral: writeText, - writeParameter: writeText, - writeSymbol: writeText, - writeLine: function () { return str += " "; }, - increaseIndent: function () { - }, - decreaseIndent: function () { - }, - clear: function () { return str = ""; }, - trackSymbol: function () { - } - }; - } - return stringWriters.pop(); - } - ts.getSingleLineStringWriter = getSingleLineStringWriter; - function releaseStringWriter(writer) { - writer.clear(); - stringWriters.push(writer); - } - ts.releaseStringWriter = releaseStringWriter; - function getFullWidth(node) { - return node.end - node.pos; - } - ts.getFullWidth = getFullWidth; - function hasFlag(val, flag) { - return (val & flag) !== 0; - } - ts.hasFlag = hasFlag; - function containsParseError(node) { - if (!hasFlag(node.parserContextFlags, 32 /* HasPropagatedChildContainsErrorFlag */)) { - var val = hasFlag(node.parserContextFlags, 16 /* ContainsError */) || ts.forEachChild(node, containsParseError); - if (val) { - node.parserContextFlags |= 16 /* ContainsError */; - } - node.parserContextFlags |= 32 /* HasPropagatedChildContainsErrorFlag */; - } - return hasFlag(node.parserContextFlags, 16 /* ContainsError */); - } - ts.containsParseError = containsParseError; - function getSourceFileOfNode(node) { - while (node && node.kind !== 201 /* SourceFile */) { - node = node.parent; - } - return node; - } - ts.getSourceFileOfNode = getSourceFileOfNode; - function nodePosToString(node) { - var file = getSourceFileOfNode(node); - var loc = file.getLineAndCharacterFromPosition(node.pos); - return file.filename + "(" + loc.line + "," + loc.character + ")"; - } - ts.nodePosToString = nodePosToString; - function getStartPosOfNode(node) { - return node.pos; - } - ts.getStartPosOfNode = getStartPosOfNode; - function isMissingNode(node) { - return node.pos === node.end && node.kind !== 1 /* EndOfFileToken */; - } - ts.isMissingNode = isMissingNode; - function getTokenPosOfNode(node, sourceFile) { - if (isMissingNode(node)) { - return node.pos; - } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); - } - ts.getTokenPosOfNode = getTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node) { - if (isMissingNode(node)) { - return ""; - } - var text = sourceFile.text; - return text.substring(ts.skipTrivia(text, node.pos), node.end); - } - ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; - function getTextOfNodeFromSourceText(sourceText, node) { - if (isMissingNode(node)) { - return ""; - } - return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); - } - ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node) { - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node); - } - ts.getTextOfNode = getTextOfNode; - function escapeIdentifier(identifier) { - return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; - } - ts.escapeIdentifier = escapeIdentifier; - function unescapeIdentifier(identifier) { - return identifier.length >= 3 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ && identifier.charCodeAt(2) === 95 /* _ */ ? identifier.substr(1) : identifier; - } - ts.unescapeIdentifier = unescapeIdentifier; - function declarationNameToString(name) { - return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); - } - ts.declarationNameToString = declarationNameToString; - function createDiagnosticForNode(node, message, arg0, arg1, arg2) { - node = getErrorSpanForNode(node); - var file = getSourceFileOfNode(node); - var start = getTokenPosOfNode(node, file); - var length = node.end - start; - return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); - } - ts.createDiagnosticForNode = createDiagnosticForNode; - function createDiagnosticForNodeFromMessageChain(node, messageChain, newLine) { - node = getErrorSpanForNode(node); - var file = getSourceFileOfNode(node); - var start = ts.skipTrivia(file.text, node.pos); - var length = node.end - start; - return ts.flattenDiagnosticChain(file, start, length, messageChain, newLine); - } - ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; - function getErrorSpanForNode(node) { - var errorSpan; - switch (node.kind) { - case 183 /* VariableDeclaration */: - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - case 189 /* ModuleDeclaration */: - case 188 /* EnumDeclaration */: - case 200 /* EnumMember */: - errorSpan = node.name; - break; - } - return errorSpan && errorSpan.pos < errorSpan.end ? errorSpan : node; - } - ts.getErrorSpanForNode = getErrorSpanForNode; - function isExternalModule(file) { - return file.externalModuleIndicator !== undefined; - } - ts.isExternalModule = isExternalModule; - function isDeclarationFile(file) { - return (file.flags & 1024 /* DeclarationFile */) !== 0; - } - ts.isDeclarationFile = isDeclarationFile; - function isConstEnumDeclaration(node) { - return node.kind === 188 /* EnumDeclaration */ && isConst(node); - } - ts.isConstEnumDeclaration = isConstEnumDeclaration; - function isConst(node) { - return !!(node.flags & 4096 /* Const */); - } - ts.isConst = isConst; - function isLet(node) { - return !!(node.flags & 2048 /* Let */); - } - ts.isLet = isLet; - function isPrologueDirective(node) { - return node.kind === 166 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; - } - ts.isPrologueDirective = isPrologueDirective; - function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - if (node.kind === 123 /* Parameter */ || node.kind === 122 /* TypeParameter */) { - return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); - } - else { - return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); - } - } - ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; - function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), isJsDocComment); - function isJsDocComment(comment) { - return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; - } - } - ts.getJsDocComments = getJsDocComments; - ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; - function forEachReturnStatement(body, visitor) { - return traverse(body); - function traverse(node) { - switch (node.kind) { - case 174 /* ReturnStatement */: - return visitor(node); - case 163 /* Block */: - case 167 /* IfStatement */: - case 168 /* DoStatement */: - case 169 /* WhileStatement */: - case 170 /* ForStatement */: - case 171 /* ForInStatement */: - case 175 /* WithStatement */: - case 176 /* SwitchStatement */: - case 194 /* CaseClause */: - case 195 /* DefaultClause */: - case 177 /* LabeledStatement */: - case 179 /* TryStatement */: - case 180 /* TryBlock */: - case 197 /* CatchClause */: - case 181 /* FinallyBlock */: - return ts.forEachChild(node, traverse); - } - } - } - ts.forEachReturnStatement = forEachReturnStatement; - function isAnyFunction(node) { - if (node) { - switch (node.kind) { - case 150 /* FunctionExpression */: - case 184 /* FunctionDeclaration */: - case 151 /* ArrowFunction */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - return true; - } - } - return false; - } - ts.isAnyFunction = isAnyFunction; - function isFunctionBlock(node) { - return node !== undefined && node.kind === 163 /* Block */ && isAnyFunction(node.parent); - } - ts.isFunctionBlock = isFunctionBlock; - function isObjectLiteralMethod(node) { - return node !== undefined && node.kind === 125 /* Method */ && node.parent.kind === 142 /* ObjectLiteralExpression */; - } - ts.isObjectLiteralMethod = isObjectLiteralMethod; - function getContainingFunction(node) { - while (true) { - node = node.parent; - if (!node || isAnyFunction(node)) { - return node; - } - } - } - ts.getContainingFunction = getContainingFunction; - function getThisContainer(node, includeArrowFunctions) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 151 /* ArrowFunction */: - if (!includeArrowFunctions) { - continue; - } - case 184 /* FunctionDeclaration */: - case 150 /* FunctionExpression */: - case 189 /* ModuleDeclaration */: - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 188 /* EnumDeclaration */: - case 201 /* SourceFile */: - return node; - } - } - } - ts.getThisContainer = getThisContainer; - function getSuperContainer(node) { - while (true) { - node = node.parent; - if (!node) { - return undefined; - } - switch (node.kind) { - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - return node; - } - } - } - ts.getSuperContainer = getSuperContainer; - function getInvokedExpression(node) { - if (node.kind === 147 /* TaggedTemplateExpression */) { - return node.tag; - } - return node.expression; - } - ts.getInvokedExpression = getInvokedExpression; - function isExpression(node) { - switch (node.kind) { - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - case 87 /* NullKeyword */: - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: - case 8 /* RegularExpressionLiteral */: - case 141 /* ArrayLiteralExpression */: - case 142 /* ObjectLiteralExpression */: - case 143 /* PropertyAccessExpression */: - case 144 /* ElementAccessExpression */: - case 145 /* CallExpression */: - case 146 /* NewExpression */: - case 147 /* TaggedTemplateExpression */: - case 148 /* TypeAssertionExpression */: - case 149 /* ParenthesizedExpression */: - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - case 154 /* VoidExpression */: - case 152 /* DeleteExpression */: - case 153 /* TypeOfExpression */: - case 155 /* PrefixUnaryExpression */: - case 156 /* PostfixUnaryExpression */: - case 157 /* BinaryExpression */: - case 158 /* ConditionalExpression */: - case 159 /* TemplateExpression */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 161 /* OmittedExpression */: - return true; - case 120 /* QualifiedName */: - while (node.parent.kind === 120 /* QualifiedName */) { - node = node.parent; - } - return node.parent.kind === 135 /* TypeQuery */; - case 63 /* Identifier */: - if (node.parent.kind === 135 /* TypeQuery */) { - return true; - } - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - var parent = node.parent; - switch (parent.kind) { - case 183 /* VariableDeclaration */: - case 123 /* Parameter */: - case 124 /* Property */: - case 200 /* EnumMember */: - case 198 /* PropertyAssignment */: - return parent.initializer === node; - case 166 /* ExpressionStatement */: - case 167 /* IfStatement */: - case 168 /* DoStatement */: - case 169 /* WhileStatement */: - case 174 /* ReturnStatement */: - case 175 /* WithStatement */: - case 176 /* SwitchStatement */: - case 194 /* CaseClause */: - case 178 /* ThrowStatement */: - case 176 /* SwitchStatement */: - return parent.expression === node; - case 170 /* ForStatement */: - return parent.initializer === node || parent.condition === node || parent.iterator === node; - case 171 /* ForInStatement */: - return parent.variable === node || parent.expression === node; - case 148 /* TypeAssertionExpression */: - return node === parent.expression; - case 162 /* TemplateSpan */: - return node === parent.expression; - default: - if (isExpression(parent)) { - return true; - } - } - } - return false; - } - ts.isExpression = isExpression; - function isExternalModuleImportDeclaration(node) { - return node.kind === 191 /* ImportDeclaration */ && node.moduleReference.kind === 193 /* ExternalModuleReference */; - } - ts.isExternalModuleImportDeclaration = isExternalModuleImportDeclaration; - function getExternalModuleImportDeclarationExpression(node) { - ts.Debug.assert(isExternalModuleImportDeclaration(node)); - return node.moduleReference.expression; - } - ts.getExternalModuleImportDeclarationExpression = getExternalModuleImportDeclarationExpression; - function isInternalModuleImportDeclaration(node) { - return node.kind === 191 /* ImportDeclaration */ && node.moduleReference.kind !== 193 /* ExternalModuleReference */; - } - ts.isInternalModuleImportDeclaration = isInternalModuleImportDeclaration; - function hasDotDotDotToken(node) { - return node && node.kind === 123 /* Parameter */ && node.dotDotDotToken !== undefined; - } - ts.hasDotDotDotToken = hasDotDotDotToken; - function hasQuestionToken(node) { - if (node) { - switch (node.kind) { - case 123 /* Parameter */: - return node.questionToken !== undefined; - case 125 /* Method */: - return node.questionToken !== undefined; - case 199 /* ShorthandPropertyAssignment */: - case 198 /* PropertyAssignment */: - case 124 /* Property */: - return node.questionToken !== undefined; - } - } - return false; - } - ts.hasQuestionToken = hasQuestionToken; - function hasRestParameters(s) { - return s.parameters.length > 0 && s.parameters[s.parameters.length - 1].dotDotDotToken !== undefined; - } - ts.hasRestParameters = hasRestParameters; - function isLiteralKind(kind) { - return 6 /* FirstLiteralToken */ <= kind && kind <= 9 /* LastLiteralToken */; - } - ts.isLiteralKind = isLiteralKind; - function isTextualLiteralKind(kind) { - return kind === 7 /* StringLiteral */ || kind === 9 /* NoSubstitutionTemplateLiteral */; - } - ts.isTextualLiteralKind = isTextualLiteralKind; - function isTemplateLiteralKind(kind) { - return 9 /* FirstTemplateToken */ <= kind && kind <= 12 /* LastTemplateToken */; - } - ts.isTemplateLiteralKind = isTemplateLiteralKind; - function isInAmbientContext(node) { - while (node) { - if (node.flags & (2 /* Ambient */ | 1024 /* DeclarationFile */)) - return true; - node = node.parent; - } - return false; - } - ts.isInAmbientContext = isInAmbientContext; - function isDeclaration(node) { - switch (node.kind) { - case 122 /* TypeParameter */: - case 123 /* Parameter */: - case 183 /* VariableDeclaration */: - case 124 /* Property */: - case 198 /* PropertyAssignment */: - case 199 /* ShorthandPropertyAssignment */: - case 200 /* EnumMember */: - case 125 /* Method */: - case 184 /* FunctionDeclaration */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - case 187 /* TypeAliasDeclaration */: - case 188 /* EnumDeclaration */: - case 189 /* ModuleDeclaration */: - case 191 /* ImportDeclaration */: - return true; - } - return false; - } - ts.isDeclaration = isDeclaration; - function isStatement(n) { - switch (n.kind) { - case 173 /* BreakStatement */: - case 172 /* ContinueStatement */: - case 182 /* DebuggerStatement */: - case 168 /* DoStatement */: - case 166 /* ExpressionStatement */: - case 165 /* EmptyStatement */: - case 171 /* ForInStatement */: - case 170 /* ForStatement */: - case 167 /* IfStatement */: - case 177 /* LabeledStatement */: - case 174 /* ReturnStatement */: - case 176 /* SwitchStatement */: - case 92 /* ThrowKeyword */: - case 179 /* TryStatement */: - case 164 /* VariableStatement */: - case 169 /* WhileStatement */: - case 175 /* WithStatement */: - case 192 /* ExportAssignment */: - return true; - default: - return false; - } - } - ts.isStatement = isStatement; - function isDeclarationOrFunctionExpressionOrCatchVariableName(name) { - if (name.kind !== 63 /* Identifier */ && name.kind !== 7 /* StringLiteral */ && name.kind !== 6 /* NumericLiteral */) { - return false; - } - var parent = name.parent; - if (isDeclaration(parent) || parent.kind === 150 /* FunctionExpression */) { - return parent.name === name; - } - if (parent.kind === 197 /* CatchClause */) { - return parent.name === name; - } - return false; - } - ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName; - function getClassBaseTypeNode(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 77 /* ExtendsKeyword */); - return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; - } - ts.getClassBaseTypeNode = getClassBaseTypeNode; - function getClassImplementedTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 100 /* ImplementsKeyword */); - return heritageClause ? heritageClause.types : undefined; - } - ts.getClassImplementedTypeNodes = getClassImplementedTypeNodes; - function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 77 /* ExtendsKeyword */); - return heritageClause ? heritageClause.types : undefined; - } - ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var i = 0, n = clauses.length; i < n; i++) { - if (clauses[i].token === kind) { - return clauses[i]; - } - } - } - return undefined; - } - ts.getHeritageClause = getHeritageClause; - function tryResolveScriptReference(program, sourceFile, reference) { - if (!program.getCompilerOptions().noResolve) { - var referenceFileName = ts.isRootedDiskPath(reference.filename) ? reference.filename : ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, program.getCompilerHost().getCurrentDirectory()); - return program.getSourceFile(referenceFileName); - } - } - ts.tryResolveScriptReference = tryResolveScriptReference; - function getAncestor(node, kind) { - switch (kind) { - case 185 /* ClassDeclaration */: - while (node) { - switch (node.kind) { - case 185 /* ClassDeclaration */: - return node; - case 188 /* EnumDeclaration */: - case 186 /* InterfaceDeclaration */: - case 187 /* TypeAliasDeclaration */: - case 189 /* ModuleDeclaration */: - case 191 /* ImportDeclaration */: - return undefined; - default: - node = node.parent; - continue; - } - } - break; - default: - while (node) { - if (node.kind === kind) { - return node; - } - node = node.parent; - } - break; - } - return undefined; - } - ts.getAncestor = getAncestor; - function getFileReferenceFromReferencePath(comment, commentRange) { - var simpleReferenceRegEx = /^\/\/\/\s*/gim; - if (simpleReferenceRegEx.exec(comment)) { - if (isNoDefaultLibRegEx.exec(comment)) { - return { - isNoDefaultLib: true - }; - } - else { - var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); - if (matchResult) { - var start = commentRange.pos; - var end = commentRange.end; - return { - fileReference: { - pos: start, - end: end, - filename: matchResult[3] - }, - isNoDefaultLib: false - }; - } - else { - return { - diagnosticMessage: ts.Diagnostics.Invalid_reference_directive_syntax, - isNoDefaultLib: false - }; - } - } - } - return undefined; - } - ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; - function isKeyword(token) { - return 64 /* FirstKeyword */ <= token && token <= 119 /* LastKeyword */; - } - ts.isKeyword = isKeyword; - function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 5 /* LastTriviaToken */; - } - ts.isTrivia = isTrivia; - function isModifier(token) { - switch (token) { - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: - case 107 /* StaticKeyword */: - case 76 /* ExportKeyword */: - case 112 /* DeclareKeyword */: - case 68 /* ConstKeyword */: - return true; - } - return false; - } - ts.isModifier = isModifier; -})(ts || (ts = {})); -var ts; -(function (ts) { - var nodeConstructors = new Array(204 /* Count */); - function getNodeConstructor(kind) { - return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); - } - ts.getNodeConstructor = getNodeConstructor; - function createRootNode(kind, pos, end, flags) { - var node = new (getNodeConstructor(kind))(); - node.pos = pos; - node.end = end; - node.flags = flags; - return node; - } - function forEachChild(node, cbNode, cbNodes) { - function child(node) { - if (node) { - return cbNode(node); - } - } - function children(nodes) { - if (nodes) { - if (cbNodes) { - return cbNodes(nodes); - } - for (var i = 0, len = nodes.length; i < len; i++) { - var result = cbNode(nodes[i]); - if (result) { - return result; - } - } - return undefined; - } - } - if (!node) { - return; - } - switch (node.kind) { - case 120 /* QualifiedName */: - return child(node.left) || child(node.right); - case 122 /* TypeParameter */: - return child(node.name) || child(node.constraint); - case 123 /* Parameter */: - return children(node.modifiers) || child(node.dotDotDotToken) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); - case 124 /* Property */: - case 198 /* PropertyAssignment */: - case 199 /* ShorthandPropertyAssignment */: - return children(node.modifiers) || child(node.name) || child(node.questionToken) || child(node.type) || child(node.initializer); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - return children(node.modifiers) || children(node.typeParameters) || children(node.parameters) || child(node.type); - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 150 /* FunctionExpression */: - case 184 /* FunctionDeclaration */: - case 151 /* ArrowFunction */: - return children(node.modifiers) || child(node.name) || child(node.questionToken) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); - case 132 /* TypeReference */: - return child(node.typeName) || children(node.typeArguments); - case 135 /* TypeQuery */: - return child(node.exprName); - case 136 /* TypeLiteral */: - return children(node.members); - case 137 /* ArrayType */: - return child(node.elementType); - case 138 /* TupleType */: - return children(node.elementTypes); - case 139 /* UnionType */: - return children(node.types); - case 140 /* ParenthesizedType */: - return child(node.type); - case 141 /* ArrayLiteralExpression */: - return children(node.elements); - case 142 /* ObjectLiteralExpression */: - return children(node.properties); - case 143 /* PropertyAccessExpression */: - return child(node.expression) || child(node.name); - case 144 /* ElementAccessExpression */: - return child(node.expression) || child(node.argumentExpression); - case 145 /* CallExpression */: - case 146 /* NewExpression */: - return child(node.expression) || children(node.typeArguments) || children(node.arguments); - case 147 /* TaggedTemplateExpression */: - return child(node.tag) || child(node.template); - case 148 /* TypeAssertionExpression */: - return child(node.type) || child(node.expression); - case 149 /* ParenthesizedExpression */: - return child(node.expression); - case 152 /* DeleteExpression */: - return child(node.expression); - case 153 /* TypeOfExpression */: - return child(node.expression); - case 154 /* VoidExpression */: - return child(node.expression); - case 155 /* PrefixUnaryExpression */: - return child(node.operand); - case 156 /* PostfixUnaryExpression */: - return child(node.operand); - case 157 /* BinaryExpression */: - return child(node.left) || child(node.right); - case 158 /* ConditionalExpression */: - return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); - case 163 /* Block */: - case 180 /* TryBlock */: - case 181 /* FinallyBlock */: - case 190 /* ModuleBlock */: - return children(node.statements); - case 201 /* SourceFile */: - return children(node.statements) || child(node.endOfFileToken); - case 164 /* VariableStatement */: - return children(node.modifiers) || children(node.declarations); - case 166 /* ExpressionStatement */: - return child(node.expression); - case 167 /* IfStatement */: - return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); - case 168 /* DoStatement */: - return child(node.statement) || child(node.expression); - case 169 /* WhileStatement */: - return child(node.expression) || child(node.statement); - case 170 /* ForStatement */: - return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); - case 171 /* ForInStatement */: - return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement); - case 172 /* ContinueStatement */: - case 173 /* BreakStatement */: - return child(node.label); - case 174 /* ReturnStatement */: - return child(node.expression); - case 175 /* WithStatement */: - return child(node.expression) || child(node.statement); - case 176 /* SwitchStatement */: - return child(node.expression) || children(node.clauses); - case 194 /* CaseClause */: - return child(node.expression) || children(node.statements); - case 195 /* DefaultClause */: - return children(node.statements); - case 177 /* LabeledStatement */: - return child(node.label) || child(node.statement); - case 178 /* ThrowStatement */: - return child(node.expression); - case 179 /* TryStatement */: - return child(node.tryBlock) || child(node.catchClause) || child(node.finallyBlock); - case 197 /* CatchClause */: - return child(node.name) || child(node.type) || child(node.block); - case 183 /* VariableDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.type) || child(node.initializer); - case 185 /* ClassDeclaration */: - return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); - case 186 /* InterfaceDeclaration */: - return children(node.modifiers) || child(node.name) || children(node.typeParameters) || children(node.heritageClauses) || children(node.members); - case 187 /* TypeAliasDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.type); - case 188 /* EnumDeclaration */: - return children(node.modifiers) || child(node.name) || children(node.members); - case 200 /* EnumMember */: - return child(node.name) || child(node.initializer); - case 189 /* ModuleDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.body); - case 191 /* ImportDeclaration */: - return children(node.modifiers) || child(node.name) || child(node.moduleReference); - case 192 /* ExportAssignment */: - return children(node.modifiers) || child(node.exportName); - case 159 /* TemplateExpression */: - return child(node.head) || children(node.templateSpans); - case 162 /* TemplateSpan */: - return child(node.expression) || child(node.literal); - case 121 /* ComputedPropertyName */: - return child(node.expression); - case 196 /* HeritageClause */: - return children(node.types); - case 193 /* ExternalModuleReference */: - return child(node.expression); - } - } - ts.forEachChild = forEachChild; - function createCompilerHost(options) { - var currentDirectory; - var existingDirectories = {}; - function getCanonicalFileName(fileName) { - return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); - } - var unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(filename, languageVersion, onError) { - try { - var text = ts.sys.readFile(filename, options.charset); - } - catch (e) { - if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText : e.message); - } - text = ""; - } - return text !== undefined ? createSourceFile(filename, text, languageVersion, "0") : undefined; - } - function writeFile(fileName, data, writeByteOrderMark, onError) { - function directoryExists(directoryPath) { - if (ts.hasProperty(existingDirectories, directoryPath)) { - return true; - } - if (ts.sys.directoryExists(directoryPath)) { - existingDirectories[directoryPath] = true; - return true; - } - return false; - } - function ensureDirectoriesExist(directoryPath) { - if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) { - var parentDirectory = ts.getDirectoryPath(directoryPath); - ensureDirectoriesExist(parentDirectory); - ts.sys.createDirectory(directoryPath); - } - } - try { - ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(fileName))); - ts.sys.writeFile(fileName, data, writeByteOrderMark); - } - catch (e) { - if (onError) { - onError(e.message); - } - } - } - return { - getSourceFile: getSourceFile, - getDefaultLibFilename: function (options) { return ts.combinePaths(ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath())), options.target === 2 /* ES6 */ ? "lib.es6.d.ts" : "lib.d.ts"); }, - writeFile: writeFile, - getCurrentDirectory: function () { return currentDirectory || (currentDirectory = ts.sys.getCurrentDirectory()); }, - useCaseSensitiveFileNames: function () { return ts.sys.useCaseSensitiveFileNames; }, - getCanonicalFileName: getCanonicalFileName, - getNewLine: function () { return ts.sys.newLine; } - }; - } - ts.createCompilerHost = createCompilerHost; - function parsingContextErrors(context) { - switch (context) { - case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; - case 8 /* TypeReferences */: return ts.Diagnostics.Type_reference_expected; - case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; - case 11 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 12 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 13 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 14 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 15 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 16 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 17 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - } - } - ; - function modifierToFlag(token) { - switch (token) { - case 107 /* StaticKeyword */: return 128 /* Static */; - case 106 /* PublicKeyword */: return 16 /* Public */; - case 105 /* ProtectedKeyword */: return 64 /* Protected */; - case 104 /* PrivateKeyword */: return 32 /* Private */; - case 76 /* ExportKeyword */: return 1 /* Export */; - case 112 /* DeclareKeyword */: return 2 /* Ambient */; - case 68 /* ConstKeyword */: return 4096 /* Const */; - } - return 0; - } - function isEvalOrArgumentsIdentifier(node) { - return node.kind === 63 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); - } - function isUseStrictPrologueDirective(sourceFile, node) { - ts.Debug.assert(ts.isPrologueDirective(node)); - var nodeText = ts.getSourceTextOfNodeFromSourceFile(sourceFile, node.expression); - return nodeText === '"use strict"' || nodeText === "'use strict'"; - } - function createSourceFile(filename, sourceText, languageVersion, version, isOpen) { - if (isOpen === void 0) { isOpen = false; } - var token; - var parsingContext; - var identifiers = {}; - var identifierCount = 0; - var nodeCount = 0; - var lineStarts; - var contextFlags = 0; - var parseErrorBeforeNextFinishedNode = false; - function setContextFlag(val, flag) { - if (val) { - contextFlags |= flag; - } - else { - contextFlags &= ~flag; - } - } - function setStrictModeContext(val) { - setContextFlag(val, 1 /* StrictMode */); - } - function setDisallowInContext(val) { - setContextFlag(val, 2 /* DisallowIn */); - } - function setYieldContext(val) { - setContextFlag(val, 4 /* Yield */); - } - function setGeneratorParameterContext(val) { - setContextFlag(val, 8 /* GeneratorParameter */); - } - function allowInAnd(func) { - if (contextFlags & 2 /* DisallowIn */) { - setDisallowInContext(false); - var result = func(); - setDisallowInContext(true); - return result; - } - return func(); - } - function disallowInAnd(func) { - if (contextFlags & 2 /* DisallowIn */) { - return func(); - } - setDisallowInContext(true); - var result = func(); - setDisallowInContext(false); - return result; - } - function doInYieldContext(func) { - if (contextFlags & 4 /* Yield */) { - return func(); - } - setYieldContext(true); - var result = func(); - setYieldContext(false); - return result; - } - function doOutsideOfYieldContext(func) { - if (contextFlags & 4 /* Yield */) { - setYieldContext(false); - var result = func(); - setYieldContext(true); - return result; - } - return func(); - } - function inYieldContext() { - return (contextFlags & 4 /* Yield */) !== 0; - } - function inStrictModeContext() { - return (contextFlags & 1 /* StrictMode */) !== 0; - } - function inGeneratorParameterContext() { - return (contextFlags & 8 /* GeneratorParameter */) !== 0; - } - function inDisallowInContext() { - return (contextFlags & 2 /* DisallowIn */) !== 0; - } - function getLineStarts() { - return lineStarts || (lineStarts = ts.computeLineStarts(sourceText)); - } - function getLineAndCharacterFromSourcePosition(position) { - return ts.getLineAndCharacterOfPosition(getLineStarts(), position); - } - function getPositionFromSourceLineAndCharacter(line, character) { - return ts.getPositionFromLineAndCharacter(getLineStarts(), line, character); - } - function parseErrorAtCurrentToken(message, arg0) { - var start = scanner.getTokenPos(); - var length = scanner.getTextPos() - start; - parseErrorAtPosition(start, length, message, arg0); - } - function parseErrorAtPosition(start, length, message, arg0) { - var lastError = ts.lastOrUndefined(sourceFile.parseDiagnostics); - if (!lastError || start !== lastError.start) { - sourceFile.parseDiagnostics.push(ts.createFileDiagnostic(sourceFile, start, length, message, arg0)); - } - parseErrorBeforeNextFinishedNode = true; - } - function scanError(message) { - var pos = scanner.getTextPos(); - parseErrorAtPosition(pos, 0, message); - } - function getNodePos() { - return scanner.getStartPos(); - } - function getNodeEnd() { - return scanner.getStartPos(); - } - function nextToken() { - return token = scanner.scan(); - } - function getTokenPos(pos) { - return ts.skipTrivia(sourceText, pos); - } - function reScanGreaterToken() { - return token = scanner.reScanGreaterToken(); - } - function reScanSlashToken() { - return token = scanner.reScanSlashToken(); - } - function reScanTemplateToken() { - return token = scanner.reScanTemplateToken(); - } - function speculationHelper(callback, isLookAhead) { - var saveToken = token; - var saveParseDiagnosticsLength = sourceFile.parseDiagnostics.length; - var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var saveContextFlags = contextFlags; - var result = isLookAhead ? scanner.lookAhead(callback) : scanner.tryScan(callback); - ts.Debug.assert(saveContextFlags === contextFlags); - if (!result || isLookAhead) { - token = saveToken; - sourceFile.parseDiagnostics.length = saveParseDiagnosticsLength; - parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; - } - return result; - } - function lookAhead(callback) { - return speculationHelper(callback, true); - } - function tryParse(callback) { - return speculationHelper(callback, false); - } - function isIdentifier() { - if (token === 63 /* Identifier */) { - return true; - } - if (token === 108 /* YieldKeyword */ && inYieldContext()) { - return false; - } - return inStrictModeContext() ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */; - } - function parseExpected(kind, diagnosticMessage, arg0) { - if (token === kind) { - nextToken(); - return true; - } - if (diagnosticMessage) { - parseErrorAtCurrentToken(diagnosticMessage, arg0); - } - else { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind)); - } - return false; - } - function parseOptional(t) { - if (token === t) { - nextToken(); - return true; - } - return false; - } - function parseOptionalToken(t) { - if (token === t) { - var node = createNode(t); - nextToken(); - return finishNode(node); - } - return undefined; - } - function canParseSemicolon() { - if (token === 21 /* SemicolonToken */) { - return true; - } - return token === 14 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); - } - function parseSemicolon(diagnosticMessage) { - if (canParseSemicolon()) { - if (token === 21 /* SemicolonToken */) { - nextToken(); - } - return true; - } - else { - return parseExpected(21 /* SemicolonToken */, diagnosticMessage); - } - } - function createNode(kind, pos) { - nodeCount++; - var node = new (nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)))(); - if (!(pos >= 0)) { - pos = scanner.getStartPos(); - } - node.pos = pos; - node.end = pos; - return node; - } - function finishNode(node) { - node.end = scanner.getStartPos(); - if (contextFlags) { - node.parserContextFlags = contextFlags; - } - if (parseErrorBeforeNextFinishedNode) { - parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 16 /* ContainsError */; - } - return node; - } - function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) { - if (reportAtCurrentPosition) { - parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0); - } - else { - parseErrorAtCurrentToken(diagnosticMessage, arg0); - } - var result = createNode(kind, scanner.getStartPos()); - result.text = ""; - return finishNode(result); - } - function internIdentifier(text) { - text = ts.escapeIdentifier(text); - return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); - } - function createIdentifier(isIdentifier, diagnosticMessage) { - identifierCount++; - if (isIdentifier) { - var node = createNode(63 /* Identifier */); - node.text = internIdentifier(scanner.getTokenValue()); - nextToken(); - return finishNode(node); - } - return createMissingNode(63 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); - } - function parseIdentifier(diagnosticMessage) { - return createIdentifier(isIdentifier(), diagnosticMessage); - } - function parseIdentifierName() { - return createIdentifier(isIdentifierOrKeyword()); - } - function isLiteralPropertyName() { - return isIdentifierOrKeyword() || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; - } - function parsePropertyName() { - if (token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { - return parseLiteralNode(true); - } - if (token === 17 /* OpenBracketToken */) { - return parseComputedPropertyName(); - } - return parseIdentifierName(); - } - function parseComputedPropertyName() { - var node = createNode(121 /* ComputedPropertyName */); - parseExpected(17 /* OpenBracketToken */); - var yieldContext = inYieldContext(); - if (inGeneratorParameterContext()) { - setYieldContext(false); - } - node.expression = allowInAnd(parseExpression); - if (inGeneratorParameterContext()) { - setYieldContext(yieldContext); - } - parseExpected(18 /* CloseBracketToken */); - return finishNode(node); - } - function parseContextualModifier(t) { - return token === t && tryParse(nextTokenCanFollowModifier); - } - function nextTokenCanFollowModifier() { - nextToken(); - return canFollowModifier(); - } - function parseAnyContextualModifier() { - return ts.isModifier(token) && tryParse(nextTokenCanFollowContextualModifier); - } - function nextTokenCanFollowContextualModifier() { - if (token === 68 /* ConstKeyword */) { - return nextToken() === 75 /* EnumKeyword */; - } - nextToken(); - return canFollowModifier(); - } - function canFollowModifier() { - return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isLiteralPropertyName(); - } - function isListElement(kind, inErrorRecovery) { - switch (kind) { - case 0 /* SourceElements */: - case 1 /* ModuleElements */: - return isSourceElement(inErrorRecovery); - case 2 /* BlockStatements */: - case 4 /* SwitchClauseStatements */: - return isStatement(inErrorRecovery); - case 3 /* SwitchClauses */: - return token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; - case 5 /* TypeMembers */: - return isStartOfTypeMember(); - case 6 /* ClassMembers */: - return lookAhead(isClassMemberStart); - case 7 /* EnumMembers */: - return token === 17 /* OpenBracketToken */ || isLiteralPropertyName(); - case 11 /* ObjectLiteralMembers */: - return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isLiteralPropertyName(); - case 8 /* TypeReferences */: - return isIdentifier() && !isNotHeritageClauseTypeName(); - case 9 /* VariableDeclarations */: - case 14 /* TypeParameters */: - return isIdentifier(); - case 10 /* ArgumentExpressions */: - return token === 22 /* CommaToken */ || isStartOfExpression(); - case 12 /* ArrayLiteralMembers */: - return token === 22 /* CommaToken */ || isStartOfExpression(); - case 13 /* Parameters */: - return isStartOfParameter(); - case 15 /* TypeArguments */: - case 16 /* TupleElementTypes */: - return token === 22 /* CommaToken */ || isStartOfType(); - case 17 /* HeritageClauses */: - return isHeritageClause(); - } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); - } - function nextTokenIsIdentifier() { - nextToken(); - return isIdentifier(); - } - function isNotHeritageClauseTypeName() { - if (token === 100 /* ImplementsKeyword */ || token === 77 /* ExtendsKeyword */) { - return lookAhead(nextTokenIsIdentifier); - } - return false; - } - function isListTerminator(kind) { - if (token === 1 /* EndOfFileToken */) { - return true; - } - switch (kind) { - case 1 /* ModuleElements */: - case 2 /* BlockStatements */: - case 3 /* SwitchClauses */: - case 5 /* TypeMembers */: - case 6 /* ClassMembers */: - case 7 /* EnumMembers */: - case 11 /* ObjectLiteralMembers */: - return token === 14 /* CloseBraceToken */; - case 4 /* SwitchClauseStatements */: - return token === 14 /* CloseBraceToken */ || token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; - case 8 /* TypeReferences */: - return token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; - case 9 /* VariableDeclarations */: - return isVariableDeclaratorListTerminator(); - case 14 /* TypeParameters */: - return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */ || token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; - case 10 /* ArgumentExpressions */: - return token === 16 /* CloseParenToken */ || token === 21 /* SemicolonToken */; - case 12 /* ArrayLiteralMembers */: - case 16 /* TupleElementTypes */: - return token === 18 /* CloseBracketToken */; - case 13 /* Parameters */: - return token === 16 /* CloseParenToken */ || token === 18 /* CloseBracketToken */ || token === 13 /* OpenBraceToken */; - case 15 /* TypeArguments */: - return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */; - case 17 /* HeritageClauses */: - return token === 13 /* OpenBraceToken */ || token === 14 /* CloseBraceToken */; - } - } - function isVariableDeclaratorListTerminator() { - if (canParseSemicolon()) { - return true; - } - if (token === 84 /* InKeyword */) { - return true; - } - if (token === 31 /* EqualsGreaterThanToken */) { - return true; - } - return false; - } - function isInSomeParsingContext() { - for (var kind = 0; kind < 18 /* Count */; kind++) { - if (parsingContext & (1 << kind)) { - if (isListElement(kind, true) || isListTerminator(kind)) { - return true; - } - } - } - return false; - } - function parseList(kind, checkForStrictMode, parseElement) { - var saveParsingContext = parsingContext; - parsingContext |= 1 << kind; - var result = []; - result.pos = getNodePos(); - var savedStrictModeContext = inStrictModeContext(); - while (!isListTerminator(kind)) { - if (isListElement(kind, false)) { - var element = parseElement(); - result.push(element); - if (checkForStrictMode && !inStrictModeContext()) { - if (ts.isPrologueDirective(element)) { - if (isUseStrictPrologueDirective(sourceFile, element)) { - setStrictModeContext(true); - checkForStrictMode = false; - } - } - else { - checkForStrictMode = false; - } - } - continue; - } - if (abortParsingListOrMoveToNextToken(kind)) { - break; - } - } - setStrictModeContext(savedStrictModeContext); - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function abortParsingListOrMoveToNextToken(kind) { - parseErrorAtCurrentToken(parsingContextErrors(kind)); - if (isInSomeParsingContext()) { - return true; - } - nextToken(); - return false; - } - function parseDelimitedList(kind, parseElement) { - var saveParsingContext = parsingContext; - parsingContext |= 1 << kind; - var result = []; - result.pos = getNodePos(); - var commaStart = -1; - while (true) { - if (isListElement(kind, false)) { - result.push(parseElement()); - commaStart = scanner.getTokenPos(); - if (parseOptional(22 /* CommaToken */)) { - continue; - } - commaStart = -1; - if (isListTerminator(kind)) { - break; - } - parseExpected(22 /* CommaToken */); - continue; - } - if (isListTerminator(kind)) { - break; - } - if (abortParsingListOrMoveToNextToken(kind)) { - break; - } - } - if (commaStart >= 0) { - result.hasTrailingComma = true; - } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; - return result; - } - function createMissingList() { - var pos = getNodePos(); - var result = []; - result.pos = pos; - result.end = pos; - return result; - } - function parseBracketedList(kind, parseElement, open, close) { - if (parseExpected(open)) { - var result = parseDelimitedList(kind, parseElement); - parseExpected(close); - return result; - } - return createMissingList(); - } - function parseEntityName(allowReservedWords, diagnosticMessage) { - var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(19 /* DotToken */)) { - var node = createNode(120 /* QualifiedName */, entity.pos); - node.left = entity; - node.right = parseRightSideOfDot(allowReservedWords); - entity = finishNode(node); - } - return entity; - } - function parseRightSideOfDot(allowIdentifierNames) { - if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord()) { - var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); - if (matchesPattern) { - return createMissingNode(63 /* Identifier */, true, ts.Diagnostics.Identifier_expected); - } - } - return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); - } - function parseTokenNode() { - var node = createNode(token); - nextToken(); - return finishNode(node); - } - function parseTemplateExpression() { - var template = createNode(159 /* TemplateExpression */); - template.head = parseLiteralNode(); - ts.Debug.assert(template.head.kind === 10 /* TemplateHead */, "Template head has wrong token kind"); - var templateSpans = []; - templateSpans.pos = getNodePos(); - do { - templateSpans.push(parseTemplateSpan()); - } while (templateSpans[templateSpans.length - 1].literal.kind === 11 /* TemplateMiddle */); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; - return finishNode(template); - } - function parseTemplateSpan() { - var span = createNode(162 /* TemplateSpan */); - span.expression = allowInAnd(parseExpression); - var literal; - if (token === 14 /* CloseBraceToken */) { - reScanTemplateToken(); - literal = parseLiteralNode(); - } - else { - literal = createMissingNode(12 /* TemplateTail */, false, ts.Diagnostics._0_expected, ts.tokenToString(14 /* CloseBraceToken */)); - } - span.literal = literal; - return finishNode(span); - } - function parseLiteralNode(internName) { - var node = createNode(token); - var text = scanner.getTokenValue(); - node.text = internName ? internIdentifier(text) : text; - if (scanner.isUnterminated()) { - node.isUnterminated = true; - } - var tokenPos = scanner.getTokenPos(); - nextToken(); - finishNode(node); - if (node.kind === 6 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 8192 /* OctalLiteral */; - } - return node; - } - function parseTypeReference() { - var node = createNode(132 /* TypeReference */); - node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && token === 23 /* LessThanToken */) { - node.typeArguments = parseBracketedList(15 /* TypeArguments */, parseType, 23 /* LessThanToken */, 24 /* GreaterThanToken */); - } - return finishNode(node); - } - function parseTypeQuery() { - var node = createNode(135 /* TypeQuery */); - parseExpected(95 /* TypeOfKeyword */); - node.exprName = parseEntityName(true); - return finishNode(node); - } - function parseTypeParameter() { - var node = createNode(122 /* TypeParameter */); - node.name = parseIdentifier(); - if (parseOptional(77 /* ExtendsKeyword */)) { - if (isStartOfType() || !isStartOfExpression()) { - node.constraint = parseType(); - } - else { - node.expression = parseUnaryExpressionOrHigher(); - } - } - return finishNode(node); - } - function parseTypeParameters() { - if (token === 23 /* LessThanToken */) { - return parseBracketedList(14 /* TypeParameters */, parseTypeParameter, 23 /* LessThanToken */, 24 /* GreaterThanToken */); - } - } - function parseParameterType() { - if (parseOptional(50 /* ColonToken */)) { - return token === 7 /* StringLiteral */ ? parseLiteralNode(true) : parseType(); - } - return undefined; - } - function isStartOfParameter() { - return token === 20 /* DotDotDotToken */ || isIdentifier() || ts.isModifier(token); - } - function setModifiers(node, modifiers) { - if (modifiers) { - node.flags |= modifiers.flags; - node.modifiers = modifiers; - } - } - function parseParameter() { - var node = createNode(123 /* Parameter */); - setModifiers(node, parseModifiers()); - node.dotDotDotToken = parseOptionalToken(20 /* DotDotDotToken */); - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifier) : parseIdentifier(); - if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { - nextToken(); - } - node.questionToken = parseOptionalToken(49 /* QuestionToken */); - node.type = parseParameterType(); - node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); - return finishNode(node); - } - function parseParameterInitializer() { - return parseInitializer(true); - } - function fillSignature(returnToken, yieldAndGeneratorParameterContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 31 /* EqualsGreaterThanToken */; - signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); - if (returnTokenRequired) { - parseExpected(returnToken); - signature.type = parseType(); - } - else if (parseOptional(returnToken)) { - signature.type = parseType(); - } - } - function parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList) { - if (parseExpected(15 /* OpenParenToken */)) { - var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(yieldAndGeneratorParameterContext); - setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(13 /* Parameters */, parseParameter); - setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - if (!parseExpected(16 /* CloseParenToken */) && requireCompleteParameterList) { - return undefined; - } - return result; - } - return requireCompleteParameterList ? undefined : createMissingList(); - } - function parseTypeMemberSemicolon() { - if (parseSemicolon()) { - return; - } - parseOptional(22 /* CommaToken */); - } - function parseSignatureMember(kind) { - var node = createNode(kind); - if (kind === 130 /* ConstructSignature */) { - parseExpected(86 /* NewKeyword */); - } - fillSignature(50 /* ColonToken */, false, false, node); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function isIndexSignature() { - if (token !== 17 /* OpenBracketToken */) { - return false; - } - return lookAhead(isUnambiguouslyIndexSignature); - } - function isUnambiguouslyIndexSignature() { - nextToken(); - if (token === 20 /* DotDotDotToken */ || token === 18 /* CloseBracketToken */) { - return true; - } - if (ts.isModifier(token)) { - nextToken(); - if (isIdentifier()) { - return true; - } - } - else if (!isIdentifier()) { - return false; - } - else { - nextToken(); - } - if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */) { - return true; - } - if (token !== 49 /* QuestionToken */) { - return false; - } - nextToken(); - return token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 18 /* CloseBracketToken */; - } - function parseIndexSignatureDeclaration(fullStart, modifiers) { - var node = createNode(131 /* IndexSignature */, fullStart); - setModifiers(node, modifiers); - node.parameters = parseBracketedList(13 /* Parameters */, parseParameter, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); - node.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(node); - } - function parsePropertyOrMethodSignature() { - var fullStart = scanner.getStartPos(); - var name = parsePropertyName(); - var questionToken = parseOptionalToken(49 /* QuestionToken */); - if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - var method = createNode(125 /* Method */, fullStart); - method.name = name; - method.questionToken = questionToken; - fillSignature(50 /* ColonToken */, false, false, method); - parseTypeMemberSemicolon(); - return finishNode(method); - } - else { - var property = createNode(124 /* Property */, fullStart); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - parseTypeMemberSemicolon(); - return finishNode(property); - } - } - function isStartOfTypeMember() { - switch (token) { - case 15 /* OpenParenToken */: - case 23 /* LessThanToken */: - case 17 /* OpenBracketToken */: - return true; - default: - return isLiteralPropertyName() && lookAhead(isTypeMemberWithLiteralPropertyName); - } - } - function isTypeMemberWithLiteralPropertyName() { - nextToken(); - return token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */ || token === 49 /* QuestionToken */ || token === 50 /* ColonToken */ || canParseSemicolon(); - } - function parseTypeMember() { - switch (token) { - case 15 /* OpenParenToken */: - case 23 /* LessThanToken */: - return parseSignatureMember(129 /* CallSignature */); - case 17 /* OpenBracketToken */: - return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined) : parsePropertyOrMethodSignature(); - case 86 /* NewKeyword */: - if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(130 /* ConstructSignature */); - } - case 7 /* StringLiteral */: - case 6 /* NumericLiteral */: - return parsePropertyOrMethodSignature(); - default: - if (isIdentifierOrKeyword()) { - return parsePropertyOrMethodSignature(); - } - } - } - function isStartOfConstructSignature() { - nextToken(); - return token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; - } - function parseTypeLiteral() { - var node = createNode(136 /* TypeLiteral */); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseObjectTypeMembers() { - var members; - if (parseExpected(13 /* OpenBraceToken */)) { - members = parseList(5 /* TypeMembers */, false, parseTypeMember); - parseExpected(14 /* CloseBraceToken */); - } - else { - members = createMissingList(); - } - return members; - } - function parseTupleType() { - var node = createNode(138 /* TupleType */); - node.elementTypes = parseBracketedList(16 /* TupleElementTypes */, parseType, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); - return finishNode(node); - } - function parseParenthesizedType() { - var node = createNode(140 /* ParenthesizedType */); - parseExpected(15 /* OpenParenToken */); - node.type = parseType(); - parseExpected(16 /* CloseParenToken */); - return finishNode(node); - } - function parseFunctionOrConstructorType(kind) { - var node = createNode(kind); - if (kind === 134 /* ConstructorType */) { - parseExpected(86 /* NewKeyword */); - } - fillSignature(31 /* EqualsGreaterThanToken */, false, false, node); - return finishNode(node); - } - function parseKeywordAndNoDot() { - var node = parseTokenNode(); - return token === 19 /* DotToken */ ? undefined : node; - } - function parseNonArrayType() { - switch (token) { - case 109 /* AnyKeyword */: - case 118 /* StringKeyword */: - case 116 /* NumberKeyword */: - case 110 /* BooleanKeyword */: - var node = tryParse(parseKeywordAndNoDot); - return node || parseTypeReference(); - case 97 /* VoidKeyword */: - return parseTokenNode(); - case 95 /* TypeOfKeyword */: - return parseTypeQuery(); - case 13 /* OpenBraceToken */: - return parseTypeLiteral(); - case 17 /* OpenBracketToken */: - return parseTupleType(); - case 15 /* OpenParenToken */: - return parseParenthesizedType(); - default: - return parseTypeReference(); - } - } - function isStartOfType() { - switch (token) { - case 109 /* AnyKeyword */: - case 118 /* StringKeyword */: - case 116 /* NumberKeyword */: - case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: - case 95 /* TypeOfKeyword */: - case 13 /* OpenBraceToken */: - case 17 /* OpenBracketToken */: - case 23 /* LessThanToken */: - case 86 /* NewKeyword */: - return true; - case 15 /* OpenParenToken */: - return lookAhead(isStartOfParenthesizedOrFunctionType); - default: - return isIdentifier(); - } - } - function isStartOfParenthesizedOrFunctionType() { - nextToken(); - return token === 16 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); - } - function parseArrayTypeOrHigher() { - var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(17 /* OpenBracketToken */)) { - parseExpected(18 /* CloseBracketToken */); - var node = createNode(137 /* ArrayType */, type.pos); - node.elementType = type; - type = finishNode(node); - } - return type; - } - function parseUnionTypeOrHigher() { - var type = parseArrayTypeOrHigher(); - if (token === 43 /* BarToken */) { - var types = [type]; - types.pos = type.pos; - while (parseOptional(43 /* BarToken */)) { - types.push(parseArrayTypeOrHigher()); - } - types.end = getNodeEnd(); - var node = createNode(139 /* UnionType */, type.pos); - node.types = types; - type = finishNode(node); - } - return type; - } - function isStartOfFunctionType() { - if (token === 23 /* LessThanToken */) { - return true; - } - return token === 15 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); - } - function isUnambiguouslyStartOfFunctionType() { - nextToken(); - if (token === 16 /* CloseParenToken */ || token === 20 /* DotDotDotToken */) { - return true; - } - if (isIdentifier() || ts.isModifier(token)) { - nextToken(); - if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 49 /* QuestionToken */ || token === 51 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { - return true; - } - if (token === 16 /* CloseParenToken */) { - nextToken(); - if (token === 31 /* EqualsGreaterThanToken */) { - return true; - } - } - } - return false; - } - function parseType() { - var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(false); - setGeneratorParameterContext(false); - var result = parseTypeWorker(); - setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - return result; - } - function parseTypeWorker() { - if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(133 /* FunctionType */); - } - if (token === 86 /* NewKeyword */) { - return parseFunctionOrConstructorType(134 /* ConstructorType */); - } - return parseUnionTypeOrHigher(); - } - function parseTypeAnnotation() { - return parseOptional(50 /* ColonToken */) ? parseType() : undefined; - } - function isStartOfExpression() { - switch (token) { - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - case 87 /* NullKeyword */: - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 10 /* TemplateHead */: - case 15 /* OpenParenToken */: - case 17 /* OpenBracketToken */: - case 13 /* OpenBraceToken */: - case 81 /* FunctionKeyword */: - case 86 /* NewKeyword */: - case 35 /* SlashToken */: - case 55 /* SlashEqualsToken */: - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: - case 45 /* ExclamationToken */: - case 72 /* DeleteKeyword */: - case 95 /* TypeOfKeyword */: - case 97 /* VoidKeyword */: - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: - case 23 /* LessThanToken */: - case 63 /* Identifier */: - case 108 /* YieldKeyword */: - return true; - default: - if (isBinaryOperator()) { - return true; - } - return isIdentifier(); - } - } - function isStartOfExpressionStatement() { - return token !== 13 /* OpenBraceToken */ && token !== 81 /* FunctionKeyword */ && isStartOfExpression(); - } - function parseExpression() { - var expr = parseAssignmentExpressionOrHigher(); - while (parseOptional(22 /* CommaToken */)) { - expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpressionOrHigher()); - } - return expr; - } - function parseInitializer(inParameter) { - if (token !== 51 /* EqualsToken */) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 13 /* OpenBraceToken */) || !isStartOfExpression()) { - return undefined; - } - } - parseExpected(51 /* EqualsToken */); - return parseAssignmentExpressionOrHigher(); - } - function parseAssignmentExpressionOrHigher() { - if (isYieldExpression()) { - return parseYieldExpression(); - } - var arrowExpression = tryParseParenthesizedArrowFunctionExpression(); - if (arrowExpression) { - return arrowExpression; - } - var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 63 /* Identifier */ && token === 31 /* EqualsGreaterThanToken */) { - return parseSimpleArrowFunctionExpression(expr); - } - if (isLeftHandSideExpression(expr) && isAssignmentOperator(reScanGreaterToken())) { - var operator = token; - nextToken(); - return makeBinaryExpression(expr, operator, parseAssignmentExpressionOrHigher()); - } - return parseConditionalExpressionRest(expr); - } - function isYieldExpression() { - if (token === 108 /* YieldKeyword */) { - if (inYieldContext()) { - return true; - } - if (inStrictModeContext()) { - return true; - } - return lookAhead(nextTokenIsIdentifierOnSameLine); - } - return false; - } - function nextTokenIsIdentifierOnSameLine() { - nextToken(); - return !scanner.hasPrecedingLineBreak() && isIdentifier(); - } - function parseYieldExpression() { - var node = createNode(160 /* YieldExpression */); - nextToken(); - if (!scanner.hasPrecedingLineBreak() && (token === 34 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - node.expression = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - else { - return finishNode(node); - } - } - function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 31 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(151 /* ArrowFunction */, identifier.pos); - var parameter = createNode(123 /* Parameter */, identifier.pos); - parameter.name = identifier; - finishNode(parameter); - node.parameters = [parameter]; - node.parameters.pos = parameter.pos; - node.parameters.end = parameter.end; - parseExpected(31 /* EqualsGreaterThanToken */); - node.body = parseArrowFunctionExpressionBody(); - return finishNode(node); - } - function tryParseParenthesizedArrowFunctionExpression() { - var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { - return undefined; - } - var arrowFunction = triState === 1 /* True */ ? parseParenthesizedArrowFunctionExpressionHead(true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); - if (!arrowFunction) { - return undefined; - } - if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) { - arrowFunction.body = parseArrowFunctionExpressionBody(); - } - else { - arrowFunction.body = parseIdentifier(); - } - return finishNode(arrowFunction); - } - function isParenthesizedArrowFunctionExpression() { - if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - return lookAhead(isParenthesizedArrowFunctionExpressionWorker); - } - if (token === 31 /* EqualsGreaterThanToken */) { - return 1 /* True */; - } - return 0 /* False */; - } - function isParenthesizedArrowFunctionExpressionWorker() { - var first = token; - var second = nextToken(); - if (first === 15 /* OpenParenToken */) { - if (second === 16 /* CloseParenToken */) { - var third = nextToken(); - switch (third) { - case 31 /* EqualsGreaterThanToken */: - case 50 /* ColonToken */: - case 13 /* OpenBraceToken */: - return 1 /* True */; - default: - return 0 /* False */; - } - } - if (second === 20 /* DotDotDotToken */) { - return 1 /* True */; - } - if (!isIdentifier()) { - return 0 /* False */; - } - if (nextToken() === 50 /* ColonToken */) { - return 1 /* True */; - } - return 2 /* Unknown */; - } - else { - ts.Debug.assert(first === 23 /* LessThanToken */); - if (!isIdentifier()) { - return 0 /* False */; - } - return 2 /* Unknown */; - } - } - function parsePossibleParenthesizedArrowFunctionExpressionHead() { - return parseParenthesizedArrowFunctionExpressionHead(false); - } - function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(151 /* ArrowFunction */); - fillSignature(50 /* ColonToken */, false, !allowAmbiguity, node); - if (!node.parameters) { - return undefined; - } - if (!allowAmbiguity && token !== 31 /* EqualsGreaterThanToken */ && token !== 13 /* OpenBraceToken */) { - return undefined; - } - return node; - } - function parseArrowFunctionExpressionBody() { - if (token === 13 /* OpenBraceToken */) { - return parseFunctionBlock(false, false); - } - if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) { - return parseFunctionBlock(false, true); - } - return parseAssignmentExpressionOrHigher(); - } - function parseConditionalExpressionRest(leftOperand) { - if (!parseOptional(49 /* QuestionToken */)) { - return leftOperand; - } - var node = createNode(158 /* ConditionalExpression */, leftOperand.pos); - node.condition = leftOperand; - node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(50 /* ColonToken */); - node.whenFalse = parseAssignmentExpressionOrHigher(); - return finishNode(node); - } - function parseBinaryExpressionOrHigher(precedence) { - var leftOperand = parseUnaryExpressionOrHigher(); - return parseBinaryExpressionRest(precedence, leftOperand); - } - function parseBinaryExpressionRest(precedence, leftOperand) { - while (true) { - reScanGreaterToken(); - var newPrecedence = getBinaryOperatorPrecedence(); - if (newPrecedence <= precedence) { - break; - } - if (token === 84 /* InKeyword */ && inDisallowInContext()) { - break; - } - var operator = token; - nextToken(); - leftOperand = makeBinaryExpression(leftOperand, operator, parseBinaryExpressionOrHigher(newPrecedence)); - } - return leftOperand; - } - function isBinaryOperator() { - if (inDisallowInContext() && token === 84 /* InKeyword */) { - return false; - } - return getBinaryOperatorPrecedence() > 0; - } - function getBinaryOperatorPrecedence() { - switch (token) { - case 48 /* BarBarToken */: - return 1; - case 47 /* AmpersandAmpersandToken */: - return 2; - case 43 /* BarToken */: - return 3; - case 44 /* CaretToken */: - return 4; - case 42 /* AmpersandToken */: - return 5; - case 27 /* EqualsEqualsToken */: - case 28 /* ExclamationEqualsToken */: - case 29 /* EqualsEqualsEqualsToken */: - case 30 /* ExclamationEqualsEqualsToken */: - return 6; - case 23 /* LessThanToken */: - case 24 /* GreaterThanToken */: - case 25 /* LessThanEqualsToken */: - case 26 /* GreaterThanEqualsToken */: - case 85 /* InstanceOfKeyword */: - case 84 /* InKeyword */: - return 7; - case 39 /* LessThanLessThanToken */: - case 40 /* GreaterThanGreaterThanToken */: - case 41 /* GreaterThanGreaterThanGreaterThanToken */: - return 8; - case 32 /* PlusToken */: - case 33 /* MinusToken */: - return 9; - case 34 /* AsteriskToken */: - case 35 /* SlashToken */: - case 36 /* PercentToken */: - return 10; - } - return -1; - } - function makeBinaryExpression(left, operator, right) { - var node = createNode(157 /* BinaryExpression */, left.pos); - node.left = left; - node.operator = operator; - node.right = right; - return finishNode(node); - } - function parsePrefixUnaryExpression() { - var node = createNode(155 /* PrefixUnaryExpression */); - node.operator = token; - nextToken(); - node.operand = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseDeleteExpression() { - var node = createNode(152 /* DeleteExpression */); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseTypeOfExpression() { - var node = createNode(153 /* TypeOfExpression */); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseVoidExpression() { - var node = createNode(154 /* VoidExpression */); - nextToken(); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseUnaryExpressionOrHigher() { - switch (token) { - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: - case 45 /* ExclamationToken */: - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: - return parsePrefixUnaryExpression(); - case 72 /* DeleteKeyword */: - return parseDeleteExpression(); - case 95 /* TypeOfKeyword */: - return parseTypeOfExpression(); - case 97 /* VoidKeyword */: - return parseVoidExpression(); - case 23 /* LessThanToken */: - return parseTypeAssertion(); - default: - return parsePostfixExpressionOrHigher(); - } - } - function parsePostfixExpressionOrHigher() { - var expression = parseLeftHandSideExpressionOrHigher(); - ts.Debug.assert(isLeftHandSideExpression(expression)); - if ((token === 37 /* PlusPlusToken */ || token === 38 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(156 /* PostfixUnaryExpression */, expression.pos); - node.operand = expression; - node.operator = token; - nextToken(); - return finishNode(node); - } - return expression; - } - function parseLeftHandSideExpressionOrHigher() { - var expression = token === 89 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); - return parseCallExpressionRest(expression); - } - function parseMemberExpressionOrHigher() { - var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); - } - function parseSuperExpression() { - var expression = parseTokenNode(); - if (token === 15 /* OpenParenToken */ || token === 19 /* DotToken */) { - return expression; - } - var node = createNode(143 /* PropertyAccessExpression */, expression.pos); - node.expression = expression; - parseExpected(19 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); - node.name = parseRightSideOfDot(true); - return finishNode(node); - } - function parseTypeAssertion() { - var node = createNode(148 /* TypeAssertionExpression */); - parseExpected(23 /* LessThanToken */); - node.type = parseType(); - parseExpected(24 /* GreaterThanToken */); - node.expression = parseUnaryExpressionOrHigher(); - return finishNode(node); - } - function parseMemberExpressionRest(expression) { - while (true) { - var dotOrBracketStart = scanner.getTokenPos(); - if (parseOptional(19 /* DotToken */)) { - var propertyAccess = createNode(143 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(true); - expression = finishNode(propertyAccess); - continue; - } - if (parseOptional(17 /* OpenBracketToken */)) { - var indexedAccess = createNode(144 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token !== 18 /* CloseBracketToken */) { - indexedAccess.argumentExpression = allowInAnd(parseExpression); - if (indexedAccess.argumentExpression.kind === 7 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 6 /* NumericLiteral */) { - var literal = indexedAccess.argumentExpression; - literal.text = internIdentifier(literal.text); - } - } - parseExpected(18 /* CloseBracketToken */); - expression = finishNode(indexedAccess); - continue; - } - if (token === 9 /* NoSubstitutionTemplateLiteral */ || token === 10 /* TemplateHead */) { - var tagExpression = createNode(147 /* TaggedTemplateExpression */, expression.pos); - tagExpression.tag = expression; - tagExpression.template = token === 9 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); - expression = finishNode(tagExpression); - continue; - } - return expression; - } - } - function parseCallExpressionRest(expression) { - while (true) { - expression = parseMemberExpressionRest(expression); - if (token === 23 /* LessThanToken */) { - var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - var callExpr = createNode(145 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - else if (token === 15 /* OpenParenToken */) { - var callExpr = createNode(145 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; - } - return expression; - } - } - function parseArgumentList() { - parseExpected(15 /* OpenParenToken */); - var result = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(16 /* CloseParenToken */); - return result; - } - function parseTypeArgumentsInExpression() { - if (!parseOptional(23 /* LessThanToken */)) { - return undefined; - } - var typeArguments = parseDelimitedList(15 /* TypeArguments */, parseType); - if (!parseExpected(24 /* GreaterThanToken */)) { - return undefined; - } - return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined; - } - function canFollowTypeArgumentsInExpression() { - switch (token) { - case 15 /* OpenParenToken */: - case 19 /* DotToken */: - case 16 /* CloseParenToken */: - case 18 /* CloseBracketToken */: - case 50 /* ColonToken */: - case 21 /* SemicolonToken */: - case 22 /* CommaToken */: - case 49 /* QuestionToken */: - case 27 /* EqualsEqualsToken */: - case 29 /* EqualsEqualsEqualsToken */: - case 28 /* ExclamationEqualsToken */: - case 30 /* ExclamationEqualsEqualsToken */: - case 47 /* AmpersandAmpersandToken */: - case 48 /* BarBarToken */: - case 44 /* CaretToken */: - case 42 /* AmpersandToken */: - case 43 /* BarToken */: - case 14 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - return true; - default: - return false; - } - } - function parsePrimaryExpression() { - switch (token) { - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - return parseLiteralNode(); - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - case 87 /* NullKeyword */: - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: - return parseTokenNode(); - case 15 /* OpenParenToken */: - return parseParenthesizedExpression(); - case 17 /* OpenBracketToken */: - return parseArrayLiteralExpression(); - case 13 /* OpenBraceToken */: - return parseObjectLiteralExpression(); - case 81 /* FunctionKeyword */: - return parseFunctionExpression(); - case 86 /* NewKeyword */: - return parseNewExpression(); - case 35 /* SlashToken */: - case 55 /* SlashEqualsToken */: - if (reScanSlashToken() === 8 /* RegularExpressionLiteral */) { - return parseLiteralNode(); - } - break; - case 10 /* TemplateHead */: - return parseTemplateExpression(); - } - return parseIdentifier(ts.Diagnostics.Expression_expected); - } - function parseParenthesizedExpression() { - var node = createNode(149 /* ParenthesizedExpression */); - parseExpected(15 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - return finishNode(node); - } - function parseAssignmentExpressionOrOmittedExpression() { - return token === 22 /* CommaToken */ ? createNode(161 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); - } - function parseArrayLiteralElement() { - return parseAssignmentExpressionOrOmittedExpression(); - } - function parseArgumentExpression() { - return allowInAnd(parseAssignmentExpressionOrOmittedExpression); - } - function parseArrayLiteralExpression() { - var node = createNode(141 /* ArrayLiteralExpression */); - parseExpected(17 /* OpenBracketToken */); - if (scanner.hasPrecedingLineBreak()) - node.flags |= 256 /* MultiLine */; - node.elements = parseDelimitedList(12 /* ArrayLiteralMembers */, parseArrayLiteralElement); - parseExpected(18 /* CloseBracketToken */); - return finishNode(node); - } - function parseObjectLiteralElement() { - var fullStart = scanner.getStartPos(); - var initialToken = token; - if (parseContextualModifier(113 /* GetKeyword */) || parseContextualModifier(117 /* SetKeyword */)) { - var kind = initialToken === 113 /* GetKeyword */ ? 127 /* GetAccessor */ : 128 /* SetAccessor */; - return parseAccessorDeclaration(kind, fullStart, undefined); - } - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - var tokenIsIdentifier = isIdentifier(); - var nameToken = token; - var propertyName = parsePropertyName(); - if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - return parseMethodDeclaration(fullStart, undefined, asteriskToken, propertyName, undefined, true); - } - var questionToken = parseOptionalToken(49 /* QuestionToken */); - if ((token === 22 /* CommaToken */ || token === 14 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(199 /* ShorthandPropertyAssignment */, fullStart); - shorthandDeclaration.name = propertyName; - shorthandDeclaration.questionToken = questionToken; - return finishNode(shorthandDeclaration); - } - else { - var propertyAssignment = createNode(198 /* PropertyAssignment */, fullStart); - propertyAssignment.name = propertyName; - propertyAssignment.questionToken = questionToken; - parseExpected(50 /* ColonToken */); - propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); - return finishNode(propertyAssignment); - } - } - function parseObjectLiteralExpression() { - var node = createNode(142 /* ObjectLiteralExpression */); - parseExpected(13 /* OpenBraceToken */); - if (scanner.hasPrecedingLineBreak()) { - node.flags |= 256 /* MultiLine */; - } - node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralElement); - parseExpected(14 /* CloseBraceToken */); - return finishNode(node); - } - function parseFunctionExpression() { - var node = createNode(150 /* FunctionExpression */); - parseExpected(81 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(50 /* ColonToken */, !!node.asteriskToken, false, node); - node.body = parseFunctionBlock(!!node.asteriskToken, false); - return finishNode(node); - } - function parseOptionalIdentifier() { - return isIdentifier() ? parseIdentifier() : undefined; - } - function parseNewExpression() { - var node = createNode(146 /* NewExpression */); - parseExpected(86 /* NewKeyword */); - node.expression = parseMemberExpressionOrHigher(); - node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token === 15 /* OpenParenToken */) { - node.arguments = parseArgumentList(); - } - return finishNode(node); - } - function parseBlock(kind, ignoreMissingOpenBrace, checkForStrictMode) { - var node = createNode(kind); - if (parseExpected(13 /* OpenBraceToken */) || ignoreMissingOpenBrace) { - node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement); - parseExpected(14 /* CloseBraceToken */); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseFunctionBlock(allowYield, ignoreMissingOpenBrace) { - var savedYieldContext = inYieldContext(); - setYieldContext(allowYield); - var block = parseBlock(163 /* Block */, ignoreMissingOpenBrace, true); - setYieldContext(savedYieldContext); - return block; - } - function parseEmptyStatement() { - var node = createNode(165 /* EmptyStatement */); - parseExpected(21 /* SemicolonToken */); - return finishNode(node); - } - function parseIfStatement() { - var node = createNode(167 /* IfStatement */); - parseExpected(82 /* IfKeyword */); - parseExpected(15 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(74 /* ElseKeyword */) ? parseStatement() : undefined; - return finishNode(node); - } - function parseDoStatement() { - var node = createNode(168 /* DoStatement */); - parseExpected(73 /* DoKeyword */); - node.statement = parseStatement(); - parseExpected(98 /* WhileKeyword */); - parseExpected(15 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - parseOptional(21 /* SemicolonToken */); - return finishNode(node); - } - function parseWhileStatement() { - var node = createNode(169 /* WhileStatement */); - parseExpected(98 /* WhileKeyword */); - parseExpected(15 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - node.statement = parseStatement(); - return finishNode(node); - } - function parseForOrForInStatement() { - var pos = getNodePos(); - parseExpected(80 /* ForKeyword */); - parseExpected(15 /* OpenParenToken */); - if (token !== 21 /* SemicolonToken */) { - if (parseOptional(96 /* VarKeyword */)) { - var declarations = disallowInAnd(parseVariableDeclarationList); - } - else if (parseOptional(102 /* LetKeyword */)) { - var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 2048 /* Let */); - } - else if (parseOptional(68 /* ConstKeyword */)) { - var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 4096 /* Const */); - } - else { - var varOrInit = disallowInAnd(parseExpression); - } - } - var forOrForInStatement; - if (parseOptional(84 /* InKeyword */)) { - var forInStatement = createNode(171 /* ForInStatement */, pos); - if (declarations) { - forInStatement.declarations = declarations; - } - else { - forInStatement.variable = varOrInit; - } - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - forOrForInStatement = forInStatement; - } - else { - var forStatement = createNode(170 /* ForStatement */, pos); - if (declarations) { - forStatement.declarations = declarations; - } - if (varOrInit) { - forStatement.initializer = varOrInit; - } - parseExpected(21 /* SemicolonToken */); - if (token !== 21 /* SemicolonToken */ && token !== 16 /* CloseParenToken */) { - forStatement.condition = allowInAnd(parseExpression); - } - parseExpected(21 /* SemicolonToken */); - if (token !== 16 /* CloseParenToken */) { - forStatement.iterator = allowInAnd(parseExpression); - } - parseExpected(16 /* CloseParenToken */); - forOrForInStatement = forStatement; - } - forOrForInStatement.statement = parseStatement(); - return finishNode(forOrForInStatement); - } - function parseBreakOrContinueStatement(kind) { - var node = createNode(kind); - parseExpected(kind === 173 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */); - if (!canParseSemicolon()) { - node.label = parseIdentifier(); - } - parseSemicolon(); - return finishNode(node); - } - function parseReturnStatement() { - var node = createNode(174 /* ReturnStatement */); - parseExpected(88 /* ReturnKeyword */); - if (!canParseSemicolon()) { - node.expression = allowInAnd(parseExpression); - } - parseSemicolon(); - return finishNode(node); - } - function parseWithStatement() { - var node = createNode(175 /* WithStatement */); - parseExpected(99 /* WithKeyword */); - parseExpected(15 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - node.statement = parseStatement(); - return finishNode(node); - } - function parseCaseClause() { - var node = createNode(194 /* CaseClause */); - parseExpected(65 /* CaseKeyword */); - node.expression = allowInAnd(parseExpression); - parseExpected(50 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); - return finishNode(node); - } - function parseDefaultClause() { - var node = createNode(195 /* DefaultClause */); - parseExpected(71 /* DefaultKeyword */); - parseExpected(50 /* ColonToken */); - node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement); - return finishNode(node); - } - function parseCaseOrDefaultClause() { - return token === 65 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); - } - function parseSwitchStatement() { - var node = createNode(176 /* SwitchStatement */); - parseExpected(90 /* SwitchKeyword */); - parseExpected(15 /* OpenParenToken */); - node.expression = allowInAnd(parseExpression); - parseExpected(16 /* CloseParenToken */); - parseExpected(13 /* OpenBraceToken */); - node.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); - parseExpected(14 /* CloseBraceToken */); - return finishNode(node); - } - function parseThrowStatement() { - var node = createNode(178 /* ThrowStatement */); - parseExpected(92 /* ThrowKeyword */); - node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); - parseSemicolon(); - return finishNode(node); - } - function parseTryStatement() { - var node = createNode(179 /* TryStatement */); - node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */); - node.catchClause = token === 66 /* CatchKeyword */ ? parseCatchClause() : undefined; - node.finallyBlock = !node.catchClause || token === 79 /* FinallyKeyword */ ? parseTokenAndBlock(79 /* FinallyKeyword */) : undefined; - return finishNode(node); - } - function parseTokenAndBlock(token) { - var pos = getNodePos(); - parseExpected(token); - var result = parseBlock(token === 94 /* TryKeyword */ ? 180 /* TryBlock */ : 181 /* FinallyBlock */, false, false); - result.pos = pos; - return result; - } - function parseCatchClause() { - var result = createNode(197 /* CatchClause */); - parseExpected(66 /* CatchKeyword */); - parseExpected(15 /* OpenParenToken */); - result.name = parseIdentifier(); - result.type = parseTypeAnnotation(); - parseExpected(16 /* CloseParenToken */); - result.block = parseBlock(163 /* Block */, false, false); - return finishNode(result); - } - function parseDebuggerStatement() { - var node = createNode(182 /* DebuggerStatement */); - parseExpected(70 /* DebuggerKeyword */); - parseSemicolon(); - return finishNode(node); - } - function isLabel() { - return isIdentifier() && lookAhead(nextTokenIsColonToken); - } - function nextTokenIsColonToken() { - return nextToken() === 50 /* ColonToken */; - } - function parseLabeledStatement() { - var node = createNode(177 /* LabeledStatement */); - node.label = parseIdentifier(); - parseExpected(50 /* ColonToken */); - node.statement = parseStatement(); - return finishNode(node); - } - function parseExpressionStatement() { - var node = createNode(166 /* ExpressionStatement */); - node.expression = allowInAnd(parseExpression); - parseSemicolon(); - return finishNode(node); - } - function isStatement(inErrorRecovery) { - switch (token) { - case 21 /* SemicolonToken */: - return !inErrorRecovery; - case 13 /* OpenBraceToken */: - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - case 81 /* FunctionKeyword */: - case 82 /* IfKeyword */: - case 73 /* DoKeyword */: - case 98 /* WhileKeyword */: - case 80 /* ForKeyword */: - case 69 /* ContinueKeyword */: - case 64 /* BreakKeyword */: - case 88 /* ReturnKeyword */: - case 99 /* WithKeyword */: - case 90 /* SwitchKeyword */: - case 92 /* ThrowKeyword */: - case 94 /* TryKeyword */: - case 70 /* DebuggerKeyword */: - case 66 /* CatchKeyword */: - case 79 /* FinallyKeyword */: - return true; - case 68 /* ConstKeyword */: - var isConstEnum = lookAhead(nextTokenIsEnumKeyword); - return !isConstEnum; - case 101 /* InterfaceKeyword */: - case 67 /* ClassKeyword */: - case 114 /* ModuleKeyword */: - case 75 /* EnumKeyword */: - case 119 /* TypeKeyword */: - if (isDeclarationStart()) { - return false; - } - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: - case 107 /* StaticKeyword */: - if (lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine)) { - return false; - } - default: - return isStartOfExpression(); - } - } - function nextTokenIsEnumKeyword() { - nextToken(); - return token === 75 /* EnumKeyword */; - } - function nextTokenIsIdentifierOrKeywordOnSameLine() { - nextToken(); - return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); - } - function parseStatement() { - switch (token) { - case 13 /* OpenBraceToken */: - return parseBlock(163 /* Block */, false, false); - case 96 /* VarKeyword */: - case 68 /* ConstKeyword */: - return parseVariableStatement(scanner.getStartPos(), undefined); - case 81 /* FunctionKeyword */: - return parseFunctionDeclaration(scanner.getStartPos(), undefined); - case 21 /* SemicolonToken */: - return parseEmptyStatement(); - case 82 /* IfKeyword */: - return parseIfStatement(); - case 73 /* DoKeyword */: - return parseDoStatement(); - case 98 /* WhileKeyword */: - return parseWhileStatement(); - case 80 /* ForKeyword */: - return parseForOrForInStatement(); - case 69 /* ContinueKeyword */: - return parseBreakOrContinueStatement(172 /* ContinueStatement */); - case 64 /* BreakKeyword */: - return parseBreakOrContinueStatement(173 /* BreakStatement */); - case 88 /* ReturnKeyword */: - return parseReturnStatement(); - case 99 /* WithKeyword */: - return parseWithStatement(); - case 90 /* SwitchKeyword */: - return parseSwitchStatement(); - case 92 /* ThrowKeyword */: - return parseThrowStatement(); - case 94 /* TryKeyword */: - case 66 /* CatchKeyword */: - case 79 /* FinallyKeyword */: - return parseTryStatement(); - case 70 /* DebuggerKeyword */: - return parseDebuggerStatement(); - case 102 /* LetKeyword */: - if (isLetDeclaration()) { - return parseVariableStatement(scanner.getStartPos(), undefined); - } - default: - return isLabel() ? parseLabeledStatement() : parseExpressionStatement(); - } - } - function parseFunctionBlockOrSemicolon(isGenerator) { - if (token === 13 /* OpenBraceToken */) { - return parseFunctionBlock(isGenerator, false); - } - parseSemicolon(ts.Diagnostics.or_expected); - return undefined; - } - function parseVariableDeclaration() { - var node = createNode(183 /* VariableDeclaration */); - node.name = parseIdentifier(); - node.type = parseTypeAnnotation(); - node.initializer = parseInitializer(false); - return finishNode(node); - } - function setFlag(array, flag) { - for (var i = 0, n = array.length; i < n; i++) { - array[i].flags |= flag; - } - return array; - } - function parseVariableDeclarationList() { - return parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration); - } - function parseVariableStatement(fullStart, modifiers) { - var node = createNode(164 /* VariableStatement */, fullStart); - setModifiers(node, modifiers); - if (token === 102 /* LetKeyword */) { - node.flags |= 2048 /* Let */; - } - else if (token === 68 /* ConstKeyword */) { - node.flags |= 4096 /* Const */; - } - else { - ts.Debug.assert(token === 96 /* VarKeyword */); - } - nextToken(); - node.declarations = allowInAnd(parseVariableDeclarationList); - setFlag(node.declarations, node.flags); - parseSemicolon(); - return finishNode(node); - } - function parseFunctionDeclaration(fullStart, modifiers) { - var node = createNode(184 /* FunctionDeclaration */, fullStart); - setModifiers(node, modifiers); - parseExpected(81 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - node.name = parseIdentifier(); - fillSignature(50 /* ColonToken */, !!node.asteriskToken, false, node); - node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken); - return finishNode(node); - } - function parseConstructorDeclaration(pos, modifiers) { - var node = createNode(126 /* Constructor */, pos); - setModifiers(node, modifiers); - parseExpected(111 /* ConstructorKeyword */); - fillSignature(50 /* ColonToken */, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false); - return finishNode(node); - } - function parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, requireBlock) { - var method = createNode(125 /* Method */, fullStart); - setModifiers(method, modifiers); - method.asteriskToken = asteriskToken; - method.name = name; - method.questionToken = questionToken; - fillSignature(50 /* ColonToken */, !!asteriskToken, false, method); - method.body = requireBlock ? parseFunctionBlock(!!asteriskToken, false) : parseFunctionBlockOrSemicolon(!!asteriskToken); - return finishNode(method); - } - function parsePropertyOrMethodDeclaration(fullStart, modifiers) { - var asteriskToken = parseOptionalToken(34 /* AsteriskToken */); - var name = parsePropertyName(); - var questionToken = parseOptionalToken(49 /* QuestionToken */); - if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { - return parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, false); - } - else { - var property = createNode(124 /* Property */, fullStart); - setModifiers(property, modifiers); - property.name = name; - property.questionToken = questionToken; - property.type = parseTypeAnnotation(); - property.initializer = allowInAnd(parseNonParameterInitializer); - parseSemicolon(); - return finishNode(property); - } - } - function parseNonParameterInitializer() { - return parseInitializer(false); - } - function parseAccessorDeclaration(kind, fullStart, modifiers) { - var node = createNode(kind, fullStart); - setModifiers(node, modifiers); - node.name = parsePropertyName(); - fillSignature(50 /* ColonToken */, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false); - return finishNode(node); - } - function isClassMemberStart() { - var idToken; - while (ts.isModifier(token)) { - idToken = token; - nextToken(); - } - if (token === 34 /* AsteriskToken */) { - return true; - } - if (isLiteralPropertyName()) { - idToken = token; - nextToken(); - } - if (token === 17 /* OpenBracketToken */) { - return true; - } - if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 117 /* SetKeyword */ || idToken === 113 /* GetKeyword */) { - return true; - } - switch (token) { - case 15 /* OpenParenToken */: - case 23 /* LessThanToken */: - case 50 /* ColonToken */: - case 51 /* EqualsToken */: - case 49 /* QuestionToken */: - return true; - default: - return canParseSemicolon(); - } - } - return false; - } - function parseModifiers() { - var flags = 0; - var modifiers; - while (true) { - var modifierStart = scanner.getStartPos(); - var modifierKind = token; - if (!parseAnyContextualModifier()) { - break; - } - if (!modifiers) { - modifiers = []; - modifiers.pos = modifierStart; - } - flags |= modifierToFlag(modifierKind); - modifiers.push(finishNode(createNode(modifierKind, modifierStart))); - } - if (modifiers) { - modifiers.flags = flags; - modifiers.end = scanner.getStartPos(); - } - return modifiers; - } - function parseClassElement() { - var fullStart = getNodePos(); - var modifiers = parseModifiers(); - if (parseContextualModifier(113 /* GetKeyword */)) { - return parseAccessorDeclaration(127 /* GetAccessor */, fullStart, modifiers); - } - if (parseContextualModifier(117 /* SetKeyword */)) { - return parseAccessorDeclaration(128 /* SetAccessor */, fullStart, modifiers); - } - if (token === 111 /* ConstructorKeyword */) { - return parseConstructorDeclaration(fullStart, modifiers); - } - if (isIndexSignature()) { - return parseIndexSignatureDeclaration(fullStart, modifiers); - } - if (isIdentifierOrKeyword() || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */ || token === 34 /* AsteriskToken */ || token === 17 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(fullStart, modifiers); - } - ts.Debug.fail("Should not have attempted to parse class member declaration."); - } - function parseClassDeclaration(fullStart, modifiers) { - var node = createNode(185 /* ClassDeclaration */, fullStart); - setModifiers(node, modifiers); - parseExpected(67 /* ClassKeyword */); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(true); - if (parseExpected(13 /* OpenBraceToken */)) { - node.members = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassMembers) : parseClassMembers(); - parseExpected(14 /* CloseBraceToken */); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseHeritageClauses(isClassHeritageClause) { - if (isHeritageClause()) { - return isClassHeritageClause && inGeneratorParameterContext() ? doOutsideOfYieldContext(parseHeritageClausesWorker) : parseHeritageClausesWorker(); - } - return undefined; - } - function parseHeritageClausesWorker() { - return parseList(17 /* HeritageClauses */, false, parseHeritageClause); - } - function parseHeritageClause() { - if (token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */) { - var node = createNode(196 /* HeritageClause */); - node.token = token; - nextToken(); - node.types = parseDelimitedList(8 /* TypeReferences */, parseTypeReference); - return finishNode(node); - } - return undefined; - } - function isHeritageClause() { - return token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; - } - function parseClassMembers() { - return parseList(6 /* ClassMembers */, false, parseClassElement); - } - function parseInterfaceDeclaration(fullStart, modifiers) { - var node = createNode(186 /* InterfaceDeclaration */, fullStart); - setModifiers(node, modifiers); - parseExpected(101 /* InterfaceKeyword */); - node.name = parseIdentifier(); - node.typeParameters = parseTypeParameters(); - node.heritageClauses = parseHeritageClauses(false); - node.members = parseObjectTypeMembers(); - return finishNode(node); - } - function parseTypeAliasDeclaration(fullStart, modifiers) { - var node = createNode(187 /* TypeAliasDeclaration */, fullStart); - setModifiers(node, modifiers); - parseExpected(119 /* TypeKeyword */); - node.name = parseIdentifier(); - parseExpected(51 /* EqualsToken */); - node.type = parseType(); - parseSemicolon(); - return finishNode(node); - } - function parseEnumMember() { - var node = createNode(200 /* EnumMember */, scanner.getStartPos()); - node.name = parsePropertyName(); - node.initializer = allowInAnd(parseNonParameterInitializer); - return finishNode(node); - } - function parseEnumDeclaration(fullStart, modifiers) { - var node = createNode(188 /* EnumDeclaration */, fullStart); - setModifiers(node, modifiers); - parseExpected(75 /* EnumKeyword */); - node.name = parseIdentifier(); - if (parseExpected(13 /* OpenBraceToken */)) { - node.members = parseDelimitedList(7 /* EnumMembers */, parseEnumMember); - parseExpected(14 /* CloseBraceToken */); - } - else { - node.members = createMissingList(); - } - return finishNode(node); - } - function parseModuleBlock() { - var node = createNode(190 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(13 /* OpenBraceToken */)) { - node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); - parseExpected(14 /* CloseBraceToken */); - } - else { - node.statements = createMissingList(); - } - return finishNode(node); - } - function parseInternalModuleTail(fullStart, modifiers, flags) { - var node = createNode(189 /* ModuleDeclaration */, fullStart); - setModifiers(node, modifiers); - node.flags |= flags; - node.name = parseIdentifier(); - node.body = parseOptional(19 /* DotToken */) ? parseInternalModuleTail(getNodePos(), undefined, 1 /* Export */) : parseModuleBlock(); - return finishNode(node); - } - function parseAmbientExternalModuleDeclaration(fullStart, modifiers) { - var node = createNode(189 /* ModuleDeclaration */, fullStart); - setModifiers(node, modifiers); - node.name = parseLiteralNode(true); - node.body = parseModuleBlock(); - return finishNode(node); - } - function parseModuleDeclaration(fullStart, modifiers) { - parseExpected(114 /* ModuleKeyword */); - return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, modifiers) : parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0); - } - function isExternalModuleReference() { - return token === 115 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); - } - function nextTokenIsOpenParen() { - return nextToken() === 15 /* OpenParenToken */; - } - function parseImportDeclaration(fullStart, modifiers) { - var node = createNode(191 /* ImportDeclaration */, fullStart); - setModifiers(node, modifiers); - parseExpected(83 /* ImportKeyword */); - node.name = parseIdentifier(); - parseExpected(51 /* EqualsToken */); - node.moduleReference = parseModuleReference(); - parseSemicolon(); - return finishNode(node); - } - function parseModuleReference() { - return isExternalModuleReference() ? parseExternalModuleReference() : parseEntityName(false); - } - function parseExternalModuleReference() { - var node = createNode(193 /* ExternalModuleReference */); - parseExpected(115 /* RequireKeyword */); - parseExpected(15 /* OpenParenToken */); - node.expression = parseExpression(); - if (node.expression.kind === 7 /* StringLiteral */) { - internIdentifier(node.expression.text); - } - parseExpected(16 /* CloseParenToken */); - return finishNode(node); - } - function parseExportAssignmentTail(fullStart, modifiers) { - var node = createNode(192 /* ExportAssignment */, fullStart); - setModifiers(node, modifiers); - node.exportName = parseIdentifier(); - parseSemicolon(); - return finishNode(node); - } - function isLetDeclaration() { - return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOnSameLine); - } - function isDeclarationStart() { - switch (token) { - case 96 /* VarKeyword */: - case 68 /* ConstKeyword */: - case 81 /* FunctionKeyword */: - return true; - case 102 /* LetKeyword */: - return isLetDeclaration(); - case 67 /* ClassKeyword */: - case 101 /* InterfaceKeyword */: - case 75 /* EnumKeyword */: - case 83 /* ImportKeyword */: - case 119 /* TypeKeyword */: - return lookAhead(nextTokenIsIdentifierOrKeyword); - case 114 /* ModuleKeyword */: - return lookAhead(nextTokenIsIdentifierOrKeywordOrStringLiteral); - case 76 /* ExportKeyword */: - return lookAhead(nextTokenIsEqualsTokenOrDeclarationStart); - case 112 /* DeclareKeyword */: - case 106 /* PublicKeyword */: - case 104 /* PrivateKeyword */: - case 105 /* ProtectedKeyword */: - case 107 /* StaticKeyword */: - return lookAhead(nextTokenIsDeclarationStart); - } - } - function isIdentifierOrKeyword() { - return token >= 63 /* Identifier */; - } - function nextTokenIsIdentifierOrKeyword() { - nextToken(); - return isIdentifierOrKeyword(); - } - function nextTokenIsIdentifierOrKeywordOrStringLiteral() { - nextToken(); - return isIdentifierOrKeyword() || token === 7 /* StringLiteral */; - } - function nextTokenIsEqualsTokenOrDeclarationStart() { - nextToken(); - return token === 51 /* EqualsToken */ || isDeclarationStart(); - } - function nextTokenIsDeclarationStart() { - nextToken(); - return isDeclarationStart(); - } - function parseDeclaration() { - var fullStart = getNodePos(); - var modifiers = parseModifiers(); - if (token === 76 /* ExportKeyword */) { - nextToken(); - if (parseOptional(51 /* EqualsToken */)) { - return parseExportAssignmentTail(fullStart, modifiers); - } - } - switch (token) { - case 96 /* VarKeyword */: - case 102 /* LetKeyword */: - case 68 /* ConstKeyword */: - return parseVariableStatement(fullStart, modifiers); - case 81 /* FunctionKeyword */: - return parseFunctionDeclaration(fullStart, modifiers); - case 67 /* ClassKeyword */: - return parseClassDeclaration(fullStart, modifiers); - case 101 /* InterfaceKeyword */: - return parseInterfaceDeclaration(fullStart, modifiers); - case 119 /* TypeKeyword */: - return parseTypeAliasDeclaration(fullStart, modifiers); - case 75 /* EnumKeyword */: - return parseEnumDeclaration(fullStart, modifiers); - case 114 /* ModuleKeyword */: - return parseModuleDeclaration(fullStart, modifiers); - case 83 /* ImportKeyword */: - return parseImportDeclaration(fullStart, modifiers); - default: - ts.Debug.fail("Mismatch between isDeclarationStart and parseDeclaration"); - } - } - function isSourceElement(inErrorRecovery) { - return isDeclarationStart() || isStatement(inErrorRecovery); - } - function parseSourceElement() { - return parseSourceElementOrModuleElement(); - } - function parseModuleElement() { - return parseSourceElementOrModuleElement(); - } - function parseSourceElementOrModuleElement() { - return isDeclarationStart() ? parseDeclaration() : parseStatement(); - } - function processReferenceComments() { - var triviaScanner = ts.createScanner(languageVersion, false, sourceText); - var referencedFiles = []; - var amdDependencies = []; - var amdModuleName; - while (true) { - var kind = triviaScanner.scan(); - if (kind === 5 /* WhitespaceTrivia */ || kind === 4 /* NewLineTrivia */ || kind === 3 /* MultiLineCommentTrivia */) { - continue; - } - if (kind !== 2 /* SingleLineCommentTrivia */) { - break; - } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos() }; - var comment = sourceText.substring(range.pos, range.end); - var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); - if (referencePathMatchResult) { - var fileReference = referencePathMatchResult.fileReference; - sourceFile.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib; - var diagnosticMessage = referencePathMatchResult.diagnosticMessage; - if (fileReference) { - referencedFiles.push(fileReference); - } - if (diagnosticMessage) { - sourceFile.referenceDiagnostics.push(ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, diagnosticMessage)); - } - } - else { - var amdModuleNameRegEx = /^\/\/\/\s* 0) { - syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.parseDiagnostics); - } - else { - checkGrammar(sourceText, languageVersion, sourceFile); - syntacticDiagnostics = sourceFile.referenceDiagnostics.concat(sourceFile.grammarDiagnostics); - } - } - ts.Debug.assert(syntacticDiagnostics !== undefined); - return syntacticDiagnostics; - } - var rootNodeFlags = 0; - if (ts.fileExtensionIs(filename, ".d.ts")) { - rootNodeFlags = 1024 /* DeclarationFile */; - } - var sourceFile = createRootNode(201 /* SourceFile */, 0, sourceText.length, rootNodeFlags); - sourceFile.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition; - sourceFile.getPositionFromLineAndCharacter = getPositionFromSourceLineAndCharacter; - sourceFile.getLineStarts = getLineStarts; - sourceFile.getSyntacticDiagnostics = getSyntacticDiagnostics; - sourceFile.filename = ts.normalizePath(filename); - sourceFile.text = sourceText; - sourceFile.referenceDiagnostics = []; - sourceFile.parseDiagnostics = []; - sourceFile.grammarDiagnostics = []; - sourceFile.semanticDiagnostics = []; - var referenceComments = processReferenceComments(); - sourceFile.referencedFiles = referenceComments.referencedFiles; - sourceFile.amdDependencies = referenceComments.amdDependencies; - sourceFile.amdModuleName = referenceComments.amdModuleName; - var scanner = ts.createScanner(languageVersion, true, sourceText, scanError); - nextToken(); - sourceFile.statements = parseList(0 /* SourceElements */, true, parseSourceElement); - ts.Debug.assert(token === 1 /* EndOfFileToken */); - sourceFile.endOfFileToken = parseTokenNode(); - sourceFile.externalModuleIndicator = getExternalModuleIndicator(); - sourceFile.nodeCount = nodeCount; - sourceFile.identifierCount = identifierCount; - sourceFile.version = version; - sourceFile.isOpen = isOpen; - sourceFile.languageVersion = languageVersion; - sourceFile.identifiers = identifiers; - return sourceFile; - } - ts.createSourceFile = createSourceFile; - function isLeftHandSideExpression(expr) { - if (expr) { - switch (expr.kind) { - case 143 /* PropertyAccessExpression */: - case 144 /* ElementAccessExpression */: - case 146 /* NewExpression */: - case 145 /* CallExpression */: - case 147 /* TaggedTemplateExpression */: - case 141 /* ArrayLiteralExpression */: - case 149 /* ParenthesizedExpression */: - case 142 /* ObjectLiteralExpression */: - case 150 /* FunctionExpression */: - case 63 /* Identifier */: - case 8 /* RegularExpressionLiteral */: - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 159 /* TemplateExpression */: - case 78 /* FalseKeyword */: - case 87 /* NullKeyword */: - case 91 /* ThisKeyword */: - case 93 /* TrueKeyword */: - case 89 /* SuperKeyword */: - return true; - } - } - return false; - } - function isAssignmentOperator(token) { - return token >= 51 /* FirstAssignment */ && token <= 62 /* LastAssignment */; - } - function checkGrammar(sourceText, languageVersion, file) { - var grammarDiagnostics = file.grammarDiagnostics; - var scanner = ts.createScanner(languageVersion, true, sourceText); - var inAmbientContext = ts.fileExtensionIs(file.filename, ".d.ts"); - var inFunctionBlock = false; - var parent; - visitNode(file); - function visitNode(node) { - var savedParent = parent; - node.parent = parent; - parent = node; - if (!checkModifiers(node)) { - var savedInFunctionBlock = inFunctionBlock; - if (ts.isFunctionBlock(node)) { - inFunctionBlock = true; - } - var savedInAmbientContext = inAmbientContext; - if (node.flags & 2 /* Ambient */) { - inAmbientContext = true; - } - checkNodeAndChildren(node); - inAmbientContext = savedInAmbientContext; - inFunctionBlock = savedInFunctionBlock; - } - parent = savedParent; - } - function checkNodeAndChildren(node) { - var nodeKind = node.kind; - if (inAmbientContext && checkForStatementInAmbientContext(node, nodeKind)) { - return; - } - if (checkNode(node, nodeKind)) { - return; - } - forEachChild(node, visitNode); - } - function checkNode(node, nodeKind) { - switch (nodeKind) { - case 151 /* ArrowFunction */: - case 129 /* CallSignature */: - case 134 /* ConstructorType */: - case 130 /* ConstructSignature */: - case 133 /* FunctionType */: - return checkAnySignatureDeclaration(node); - case 173 /* BreakStatement */: - case 172 /* ContinueStatement */: - return checkBreakOrContinueStatement(node); - case 145 /* CallExpression */: - case 146 /* NewExpression */: - return checkCallOrNewExpression(node); - case 188 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 157 /* BinaryExpression */: return checkBinaryExpression(node); - case 197 /* CatchClause */: return checkCatchClause(node); - case 185 /* ClassDeclaration */: return checkClassDeclaration(node); - case 121 /* ComputedPropertyName */: return checkComputedPropertyName(node); - case 126 /* Constructor */: return checkConstructor(node); - case 152 /* DeleteExpression */: return checkDeleteExpression(node); - case 144 /* ElementAccessExpression */: return checkElementAccessExpression(node); - case 192 /* ExportAssignment */: return checkExportAssignment(node); - case 193 /* ExternalModuleReference */: return checkExternalModuleReference(node); - case 171 /* ForInStatement */: return checkForInStatement(node); - case 170 /* ForStatement */: return checkForStatement(node); - case 184 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 150 /* FunctionExpression */: return checkFunctionExpression(node); - case 127 /* GetAccessor */: return checkGetAccessor(node); - case 196 /* HeritageClause */: return checkHeritageClause(node); - case 131 /* IndexSignature */: return checkIndexSignature(node); - case 186 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 177 /* LabeledStatement */: return checkLabeledStatement(node); - case 198 /* PropertyAssignment */: return checkPropertyAssignment(node); - case 125 /* Method */: return checkMethod(node); - case 189 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 142 /* ObjectLiteralExpression */: return checkObjectLiteralExpression(node); - case 6 /* NumericLiteral */: return checkNumericLiteral(node); - case 123 /* Parameter */: return checkParameter(node); - case 156 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 155 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 124 /* Property */: return checkProperty(node); - case 174 /* ReturnStatement */: return checkReturnStatement(node); - case 128 /* SetAccessor */: return checkSetAccessor(node); - case 201 /* SourceFile */: return checkSourceFile(node); - case 199 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node); - case 176 /* SwitchStatement */: return checkSwitchStatement(node); - case 147 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 178 /* ThrowStatement */: return checkThrowStatement(node); - case 138 /* TupleType */: return checkTupleType(node); - case 122 /* TypeParameter */: return checkTypeParameter(node); - case 132 /* TypeReference */: return checkTypeReference(node); - case 183 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 164 /* VariableStatement */: return checkVariableStatement(node); - case 175 /* WithStatement */: return checkWithStatement(node); - case 160 /* YieldExpression */: return checkYieldExpression(node); - } - } - function scanToken(pos) { - var start = ts.skipTrivia(sourceText, pos); - scanner.setTextPos(start); - scanner.scan(); - return start; - } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { - var start = scanToken(node.pos); - grammarDiagnostics.push(ts.createFileDiagnostic(file, start, scanner.getTextPos() - start, message, arg0, arg1, arg2)); - return true; - } - function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { - scanToken(node.pos); - grammarDiagnostics.push(ts.createFileDiagnostic(file, scanner.getTextPos(), 0, message, arg0, arg1, arg2)); - return true; - } - function grammarErrorOnNode(node, message, arg0, arg1, arg2) { - var span = ts.getErrorSpanForNode(node); - var start = span.end > span.pos ? ts.skipTrivia(file.text, span.pos) : span.pos; - var length = span.end - start; - grammarDiagnostics.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); - return true; - } - function grammarErrorAtPos(start, length, message, arg0, arg1, arg2) { - grammarDiagnostics.push(ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2)); - return true; - } - function reportInvalidUseInStrictMode(node) { - var name = sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); - return grammarErrorOnNode(node, ts.Diagnostics.Invalid_use_of_0_in_strict_mode, name); - } - function checkForStatementInAmbientContext(node, kind) { - switch (kind) { - case 163 /* Block */: - case 165 /* EmptyStatement */: - case 167 /* IfStatement */: - case 168 /* DoStatement */: - case 169 /* WhileStatement */: - case 170 /* ForStatement */: - case 171 /* ForInStatement */: - case 172 /* ContinueStatement */: - case 173 /* BreakStatement */: - case 174 /* ReturnStatement */: - case 175 /* WithStatement */: - case 176 /* SwitchStatement */: - case 178 /* ThrowStatement */: - case 179 /* TryStatement */: - case 182 /* DebuggerStatement */: - case 177 /* LabeledStatement */: - case 166 /* ExpressionStatement */: - return grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); - } - } - function checkAnySignatureDeclaration(node) { - return checkTypeParameterList(node.typeParameters) || checkParameterList(node.parameters); - } - function checkBinaryExpression(node) { - if (node.parserContextFlags & 1 /* StrictMode */) { - if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) { - if (isEvalOrArgumentsIdentifier(node.left)) { - return reportInvalidUseInStrictMode(node.left); - } - } - } - } - function isIterationStatement(node, lookInLabeledStatements) { - switch (node.kind) { - case 170 /* ForStatement */: - case 171 /* ForInStatement */: - case 168 /* DoStatement */: - case 169 /* WhileStatement */: - return true; - case 177 /* LabeledStatement */: - return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); - } - return false; - } - function checkLabeledStatement(node) { - var current = node.parent; - while (current) { - if (ts.isAnyFunction(current)) { - break; - } - if (current.kind === 177 /* LabeledStatement */ && current.label.text === node.label.text) { - return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceText, node.label)); - } - current = current.parent; - } - } - function checkBreakOrContinueStatement(node) { - var current = node; - while (current) { - if (ts.isAnyFunction(current)) { - return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); - } - switch (current.kind) { - case 177 /* LabeledStatement */: - if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 172 /* ContinueStatement */ && !isIterationStatement(current.statement, true); - if (isMisplacedContinueLabel) { - return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); - } - return false; - } - break; - case 176 /* SwitchStatement */: - if (node.kind === 173 /* BreakStatement */ && !node.label) { - return false; - } - break; - default: - if (isIterationStatement(current, false) && !node.label) { - return false; - } - break; - } - current = current.parent; - } - if (node.label) { - var message = node.kind === 173 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - else { - var message = node.kind === 173 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; - return grammarErrorOnNode(node, message); - } - } - function checkCallOrNewExpression(node) { - return checkTypeArguments(node.typeArguments) || checkArguments(node.arguments); - } - function checkArguments(arguments) { - return checkForDisallowedTrailingComma(arguments) || checkForOmittedArgument(arguments); - } - function checkTypeArguments(typeArguments) { - return checkForDisallowedTrailingComma(typeArguments) || checkForAtLeastOneTypeArgument(typeArguments); - } - function checkForOmittedArgument(arguments) { - if (arguments) { - for (var i = 0, n = arguments.length; i < n; i++) { - var arg = arguments[i]; - if (arg.kind === 161 /* OmittedExpression */) { - return grammarErrorAtPos(arg.pos, 0, ts.Diagnostics.Argument_expression_expected); - } - } - } - } - function checkForAtLeastOneTypeArgument(typeArguments) { - if (typeArguments && typeArguments.length === 0) { - var start = typeArguments.pos - "<".length; - var end = ts.skipTrivia(sourceText, typeArguments.end) + ">".length; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); - } - } - function checkForDisallowedTrailingComma(list) { - if (list && list.hasTrailingComma) { - var start = list.end - ",".length; - var end = list.end; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - function checkCatchClause(node) { - if (node.type) { - var colonStart = ts.skipTrivia(sourceText, node.name.end); - return grammarErrorAtPos(colonStart, ":".length, ts.Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation); - } - if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { - return reportInvalidUseInStrictMode(node.name); - } - } - function checkClassDeclaration(node) { - return checkClassDeclarationHeritageClauses(node); - } - function checkClassDeclarationHeritageClauses(node) { - var seenExtendsClause = false; - var seenImplementsClause = false; - if (node.heritageClauses) { - for (var i = 0, n = node.heritageClauses.length; i < n; i++) { - ts.Debug.assert(i <= 2); - var heritageClause = node.heritageClauses[i]; - if (heritageClause.token === 77 /* ExtendsKeyword */) { - if (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause); - } - if (heritageClause.types.length > 1) { - return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 100 /* ImplementsKeyword */); - if (seenImplementsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); - } - seenImplementsClause = true; - } - } - } - return false; - } - function checkForAtLeastOneHeritageClause(types, listType) { - if (types && types.length === 0) { - return grammarErrorAtPos(types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); - } - } - function checkConstructor(node) { - return checkAnySignatureDeclaration(node) || checkConstructorTypeParameters(node) || checkConstructorTypeAnnotation(node) || checkForBodyInAmbientContext(node.body, true); - } - function checkConstructorTypeParameters(node) { - if (node.typeParameters) { - return grammarErrorAtPos(node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); - } - } - function checkConstructorTypeAnnotation(node) { - if (node.type) { - return grammarErrorOnNode(node.type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); - } - } - function checkDeleteExpression(node) { - if (node.parserContextFlags & 1 /* StrictMode */ && node.expression.kind === 63 /* Identifier */) { - return grammarErrorOnNode(node.expression, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); - } - } - function checkEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 4096 /* Const */) !== 0; - var hasError = false; - if (!enumIsConst) { - var inConstantEnumMemberSection = true; - for (var i = 0, n = enumDecl.members.length; i < n; i++) { - var node = enumDecl.members[i]; - if (node.name.kind === 121 /* ComputedPropertyName */) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); - } - else if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer)) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers) || hasError; - } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection) { - hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer) || hasError; - } - } - } - return hasError; - } - function isIntegerLiteral(expression) { - function isInteger(literalExpression) { - return /^[0-9]+([eE]\+?[0-9]+)?$/.test(literalExpression.text); - } - if (expression.kind === 155 /* PrefixUnaryExpression */) { - var unaryExpression = expression; - if (unaryExpression.operator === 32 /* PlusToken */ || unaryExpression.operator === 33 /* MinusToken */) { - expression = unaryExpression.operand; - } - } - if (expression.kind === 6 /* NumericLiteral */) { - return isInteger(expression); - } - return false; - } - function checkExportAssignment(node) { - if (node.flags & 243 /* Modifier */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); - } - } - function checkExternalModuleReference(node) { - if (node.expression.kind !== 7 /* StringLiteral */) { - return grammarErrorOnNode(node.expression, ts.Diagnostics.String_literal_expected); - } - } - function checkForInStatement(node) { - return checkVariableDeclarations(node.declarations) || checkForMoreThanOneDeclaration(node.declarations); - } - function checkForStatement(node) { - return checkVariableDeclarations(node.declarations); - } - function checkForMoreThanOneDeclaration(declarations) { - if (declarations && declarations.length > 1) { - return grammarErrorOnFirstToken(declarations[1], ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement); - } - } - function checkFunctionDeclaration(node) { - return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node); - } - function checkForGenerator(node) { - if (node.asteriskToken) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_currently_supported); - } - } - function checkFunctionExpression(node) { - return checkAnySignatureDeclaration(node) || checkFunctionName(node.name) || checkForGenerator(node); - } - function checkFunctionName(name) { - if (name && name.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(name)) { - return reportInvalidUseInStrictMode(name); - } - } - function checkGetAccessor(node) { - return checkAnySignatureDeclaration(node) || checkAccessor(node); - } - function checkElementAccessExpression(node) { - if (!node.argumentExpression) { - if (node.parent.kind === 146 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceText, node.expression.end); - var end = node.end; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.Expression_expected); - } - } - } - function checkHeritageClause(node) { - return checkForDisallowedTrailingComma(node.types) || checkForAtLeastOneHeritageClause(node.types, ts.tokenToString(node.token)); - } - function checkIndexSignature(node) { - return checkIndexSignatureParameters(node) || checkForIndexSignatureModifiers(node); - } - function checkForIndexSignatureModifiers(node) { - if (node.flags & 243 /* Modifier */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); - } - } - function checkIndexSignatureParameters(node) { - var parameter = node.parameters[0]; - if (node.parameters.length !== 1) { - if (parameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - else { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); - } - } - else if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); - } - else if (parameter.flags & 243 /* Modifier */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark); - } - else if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer); - } - else if (!parameter.type) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); - } - else if (parameter.type.kind !== 118 /* StringKeyword */ && parameter.type.kind !== 116 /* NumberKeyword */) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); - } - else if (!node.type) { - return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); - } - } - function checkInterfaceDeclaration(node) { - return checkInterfaceDeclarationHeritageClauses(node); - } - function checkInterfaceDeclarationHeritageClauses(node) { - var seenExtendsClause = false; - if (node.heritageClauses) { - for (var i = 0, n = node.heritageClauses.length; i < n; i++) { - ts.Debug.assert(i <= 1); - var heritageClause = node.heritageClauses[i]; - if (heritageClause.token === 77 /* ExtendsKeyword */) { - if (seenExtendsClause) { - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); - } - seenExtendsClause = true; - } - else { - ts.Debug.assert(heritageClause.token === 100 /* ImplementsKeyword */); - return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); - } - } - } - return false; - } - function checkMethod(node) { - if (checkAnySignatureDeclaration(node) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node)) { - return true; - } - if (node.parent.kind === 185 /* ClassDeclaration */) { - if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { - return true; - } - if (inAmbientContext) { - return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_an_ambient_context); - } - else if (!node.body) { - return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_method_overloads); - } - } - else if (node.parent.kind === 186 /* InterfaceDeclaration */) { - return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces); - } - else if (node.parent.kind === 136 /* TypeLiteral */) { - return checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals); - } - } - function checkForBodyInAmbientContext(body, isConstructor) { - if (inAmbientContext && body && body.kind === 163 /* Block */) { - var diagnostic = isConstructor ? ts.Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : ts.Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; - return grammarErrorOnFirstToken(body, diagnostic); - } - } - function checkModuleDeclaration(node) { - return checkModuleDeclarationName(node) || checkModuleDeclarationStatements(node); - } - function checkModuleDeclarationName(node) { - if (!inAmbientContext && node.name.kind === 7 /* StringLiteral */) { - return grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); - } - } - function checkModuleDeclarationStatements(node) { - if (node.name.kind === 63 /* Identifier */ && node.body.kind === 190 /* ModuleBlock */) { - var statements = node.body.statements; - for (var i = 0, n = statements.length; i < n; i++) { - var statement = statements[i]; - if (statement.kind === 192 /* ExportAssignment */) { - return grammarErrorOnNode(statement, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); - } - else if (ts.isExternalModuleImportDeclaration(statement)) { - return grammarErrorOnNode(ts.getExternalModuleImportDeclarationExpression(statement), ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); - } - } - } - } - function checkObjectLiteralExpression(node) { - var seen = {}; - var Property = 1; - var GetAccessor = 2; - var SetAccesor = 4; - var GetOrSetAccessor = GetAccessor | SetAccesor; - var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0; - for (var i = 0, n = node.properties.length; i < n; i++) { - var prop = node.properties[i]; - var name = prop.name; - if (prop.kind === 161 /* OmittedExpression */ || name.kind === 121 /* ComputedPropertyName */) { - continue; - } - var currentKind; - if (prop.kind === 198 /* PropertyAssignment */ || prop.kind === 199 /* ShorthandPropertyAssignment */ || prop.kind === 125 /* Method */) { - currentKind = Property; - } - else if (prop.kind === 127 /* GetAccessor */) { - currentKind = GetAccessor; - } - else if (prop.kind === 128 /* SetAccessor */) { - currentKind = SetAccesor; - } - else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); - } - if (!ts.hasProperty(seen, name.text)) { - seen[name.text] = currentKind; - } - else { - var existingKind = seen[name.text]; - if (currentKind === Property && existingKind === Property) { - if (inStrictMode) { - grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode); - } - } - else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { - if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name.text] = currentKind | existingKind; - } - else { - return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); - } - } - else { - return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); - } - } - } - } - function checkNumericLiteral(node) { - if (node.flags & 8192 /* OctalLiteral */) { - if (node.parserContextFlags & 1 /* StrictMode */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode); - } - else if (languageVersion >= 1 /* ES5 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); - } - } - } - function checkModifiers(node) { - switch (node.kind) { - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - case 124 /* Property */: - case 125 /* Method */: - case 131 /* IndexSignature */: - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - case 189 /* ModuleDeclaration */: - case 188 /* EnumDeclaration */: - case 192 /* ExportAssignment */: - case 164 /* VariableStatement */: - case 184 /* FunctionDeclaration */: - case 187 /* TypeAliasDeclaration */: - case 191 /* ImportDeclaration */: - case 123 /* Parameter */: - break; - default: - return false; - } - if (!node.modifiers) { - return; - } - var lastStatic, lastPrivate, lastProtected, lastDeclare; - var flags = 0; - for (var i = 0, n = node.modifiers.length; i < n; i++) { - var modifier = node.modifiers[i]; - switch (modifier.kind) { - case 106 /* PublicKeyword */: - case 105 /* ProtectedKeyword */: - case 104 /* PrivateKeyword */: - var text; - if (modifier.kind === 106 /* PublicKeyword */) { - text = "public"; - } - else if (modifier.kind === 105 /* ProtectedKeyword */) { - text = "protected"; - lastProtected = modifier; - } - else { - text = "private"; - lastPrivate = modifier; - } - if (flags & 112 /* AccessibilityModifier */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); - } - else if (flags & 128 /* Static */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); - } - else if (node.parent.kind === 190 /* ModuleBlock */ || node.parent.kind === 201 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); - } - flags |= modifierToFlag(modifier.kind); - break; - case 107 /* StaticKeyword */: - if (flags & 128 /* Static */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); - } - else if (node.parent.kind === 190 /* ModuleBlock */ || node.parent.kind === 201 /* SourceFile */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); - } - else if (node.kind === 123 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); - } - flags |= 128 /* Static */; - lastStatic = modifier; - break; - case 76 /* ExportKeyword */: - if (flags & 1 /* Export */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); - } - else if (flags & 2 /* Ambient */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); - } - else if (node.parent.kind === 185 /* ClassDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); - } - else if (node.kind === 123 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); - } - flags |= 1 /* Export */; - break; - case 112 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); - } - else if (node.parent.kind === 185 /* ClassDeclaration */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); - } - else if (node.kind === 123 /* Parameter */) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); - } - else if (inAmbientContext && node.parent.kind === 190 /* ModuleBlock */) { - return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); - } - flags |= 2 /* Ambient */; - lastDeclare = modifier; - break; - } - } - if (node.kind === 126 /* Constructor */) { - if (flags & 128 /* Static */) { - return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); - } - else if (flags & 64 /* Protected */) { - return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); - } - else if (flags & 32 /* Private */) { - return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); - } - } - else if (node.kind === 191 /* ImportDeclaration */ && flags & 2 /* Ambient */) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); - } - else if (node.kind === 186 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); - } - } - function checkParameter(node) { - if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { - return reportInvalidUseInStrictMode(node.name); - } - } - function checkTypeParameterList(typeParameters) { - if (checkForDisallowedTrailingComma(typeParameters)) { - return true; - } - if (typeParameters && typeParameters.length === 0) { - var start = typeParameters.pos - "<".length; - var end = ts.skipTrivia(sourceText, typeParameters.end) + ">".length; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); - } - } - function checkParameterList(parameters) { - if (checkForDisallowedTrailingComma(parameters)) { - return true; - } - var seenOptionalParameter = false; - var parameterCount = parameters.length; - for (var i = 0; i < parameterCount; i++) { - var parameter = parameters[i]; - if (parameter.dotDotDotToken) { - if (i !== (parameterCount - 1)) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); - } - if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional); - } - if (parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); - } - } - else if (parameter.questionToken || parameter.initializer) { - seenOptionalParameter = true; - if (parameter.questionToken && parameter.initializer) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); - } - } - else { - if (seenOptionalParameter) { - return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter); - } - } - } - } - function checkPostfixUnaryExpression(node) { - if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.operand)) { - return reportInvalidUseInStrictMode(node.operand); - } - } - function checkPrefixUnaryExpression(node) { - if (node.parserContextFlags & 1 /* StrictMode */) { - if ((node.operator === 37 /* PlusPlusToken */ || node.operator === 38 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(node.operand)) { - return reportInvalidUseInStrictMode(node.operand); - } - } - } - function checkProperty(node) { - if (node.parent.kind === 185 /* ClassDeclaration */) { - if (checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional) || checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_class_property_declarations)) { - return true; - } - } - else if (node.parent.kind === 186 /* InterfaceDeclaration */) { - if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_interfaces)) { - return true; - } - } - else if (node.parent.kind === 136 /* TypeLiteral */) { - if (checkForDisallowedComputedProperty(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_type_literals)) { - return true; - } - } - return checkForInitializerInAmbientContext(node); - } - function checkComputedPropertyName(node) { - return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_not_currently_supported); - if (languageVersion < 2 /* ES6 */) { - return grammarErrorOnNode(node, ts.Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - else if (node.expression.kind === 157 /* BinaryExpression */ && node.expression.operator === 22 /* CommaToken */) { - return grammarErrorOnNode(node.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); - } - } - function checkForDisallowedComputedProperty(node, message) { - if (node.kind === 121 /* ComputedPropertyName */) { - return grammarErrorOnNode(node, message); - } - } - function checkForInitializerInAmbientContext(node) { - if (inAmbientContext && node.initializer) { - return grammarErrorOnFirstToken(node.initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - } - function checkPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - } - function checkForInvalidQuestionMark(node, questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } - } - function checkReturnStatement(node) { - if (!inFunctionBlock) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body); - } - } - function checkSetAccessor(node) { - return checkAnySignatureDeclaration(node) || checkAccessor(node); - } - function checkAccessor(accessor) { - var kind = accessor.kind; - if (languageVersion < 1 /* ES5 */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); - } - else if (inAmbientContext) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context); - } - else if (accessor.body === undefined) { - return grammarErrorAtPos(accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); - } - else if (accessor.typeParameters) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); - } - else if (kind === 127 /* GetAccessor */ && accessor.parameters.length) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); - } - else if (kind === 128 /* SetAccessor */) { - if (accessor.type) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); - } - else if (accessor.parameters.length !== 1) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); - } - else { - var parameter = accessor.parameters[0]; - if (parameter.dotDotDotToken) { - return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); - } - else if (parameter.flags & 243 /* Modifier */) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - else if (parameter.questionToken) { - return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter); - } - else if (parameter.initializer) { - return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer); - } - } - } - } - function checkSourceFile(node) { - return inAmbientContext && checkTopLevelElementsForRequiredDeclareModifier(file); - } - function checkTopLevelElementsForRequiredDeclareModifier(file) { - for (var i = 0, n = file.statements.length; i < n; i++) { - var decl = file.statements[i]; - if (ts.isDeclaration(decl) || decl.kind === 164 /* VariableStatement */) { - if (checkTopLevelElementForRequiredDeclareModifier(decl)) { - return true; - } - } - } - } - function checkTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 186 /* InterfaceDeclaration */ || node.kind === 191 /* ImportDeclaration */ || node.kind === 192 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) { - return false; - } - return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); - } - function checkShorthandPropertyAssignment(node) { - return checkForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - } - function checkSwitchStatement(node) { - var firstDefaultClause; - for (var i = 0, n = node.clauses.length; i < n; i++) { - var clause = node.clauses[i]; - if (clause.kind === 195 /* DefaultClause */) { - if (firstDefaultClause === undefined) { - firstDefaultClause = clause; - } - else { - var start = ts.skipTrivia(file.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - return grammarErrorAtPos(start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); - } - } - } - } - function checkTaggedTemplateExpression(node) { - if (languageVersion < 2 /* ES6 */) { - return grammarErrorOnFirstToken(node.template, ts.Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - } - function checkThrowStatement(node) { - if (node.expression === undefined) { - return grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here); - } - } - function checkTupleType(node) { - return checkForDisallowedTrailingComma(node.elementTypes) || checkForAtLeastOneType(node); - } - function checkForAtLeastOneType(node) { - if (node.elementTypes.length === 0) { - return grammarErrorOnNode(node, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); - } - } - function checkTypeParameter(node) { - if (node.expression) { - return grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected); - } - } - function checkTypeReference(node) { - return checkTypeArguments(node.typeArguments); - } - function checkVariableDeclaration(node) { - if (inAmbientContext && node.initializer) { - var equalsPos = node.type ? ts.skipTrivia(sourceText, node.type.end) : ts.skipTrivia(sourceText, node.name.end); - return grammarErrorAtPos(equalsPos, "=".length, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } - if (!inAmbientContext && !node.initializer && ts.isConst(node)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized); - } - if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) { - return reportInvalidUseInStrictMode(node.name); - } - } - function checkVariableDeclarations(declarations) { - if (declarations) { - if (checkForDisallowedTrailingComma(declarations)) { - return true; - } - if (!declarations.length) { - return grammarErrorAtPos(declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); - } - var decl = declarations[0]; - if (languageVersion < 2 /* ES6 */) { - if (ts.isLet(decl)) { - return grammarErrorOnFirstToken(decl, ts.Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - else if (ts.isConst(decl)) { - return grammarErrorOnFirstToken(decl, ts.Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); - } - } - } - } - function checkVariableStatement(node) { - return checkVariableDeclarations(node.declarations) || checkForDisallowedLetOrConstStatement(node); - } - function checkForDisallowedLetOrConstStatement(node) { - if (!allowLetAndConstDeclarations(node.parent)) { - if (ts.isLet(node)) { - return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block); - } - else if (ts.isConst(node)) { - return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block); - } - } - } - function allowLetAndConstDeclarations(parent) { - switch (parent.kind) { - case 167 /* IfStatement */: - case 168 /* DoStatement */: - case 169 /* WhileStatement */: - case 175 /* WithStatement */: - case 170 /* ForStatement */: - case 171 /* ForInStatement */: - return false; - case 177 /* LabeledStatement */: - return allowLetAndConstDeclarations(parent.parent); - } - return true; - } - function checkWithStatement(node) { - if (node.parserContextFlags & 1 /* StrictMode */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); - } - } - function checkYieldExpression(node) { - if (!(node.parserContextFlags & 4 /* Yield */)) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration); - } - return grammarErrorOnFirstToken(node, ts.Diagnostics.yield_expressions_are_not_currently_supported); - } - } - function createProgram(rootNames, options, host) { - var program; - var files = []; - var filesByName = {}; - var errors = []; - var seenNoDefaultLib = options.noLib; - var commonSourceDirectory; - ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); - if (!seenNoDefaultLib) { - processRootFile(host.getDefaultLibFilename(options), true); - } - verifyCompilerOptions(); - errors.sort(ts.compareDiagnostics); - program = { - getSourceFile: getSourceFile, - getSourceFiles: function () { return files; }, - getCompilerOptions: function () { return options; }, - getCompilerHost: function () { return host; }, - getDiagnostics: getDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - getTypeChecker: function (fullTypeCheckMode) { return ts.createTypeChecker(program, fullTypeCheckMode); }, - getCommonSourceDirectory: function () { return commonSourceDirectory; } - }; - return program; - function getSourceFile(filename) { - filename = host.getCanonicalFileName(filename); - return ts.hasProperty(filesByName, filename) ? filesByName[filename] : undefined; - } - function getDiagnostics(sourceFile) { - return sourceFile ? ts.filter(errors, function (e) { return e.file === sourceFile; }) : errors; - } - function getGlobalDiagnostics() { - return ts.filter(errors, function (e) { return !e.file; }); - } - function hasExtension(filename) { - return ts.getBaseFilename(filename).indexOf(".") >= 0; - } - function processRootFile(filename, isDefaultLib) { - processSourceFile(ts.normalizePath(filename), isDefaultLib); - } - function processSourceFile(filename, isDefaultLib, refFile, refPos, refEnd) { - if (refEnd !== undefined && refPos !== undefined) { - var start = refPos; - var length = refEnd - refPos; - } - var diagnostic; - if (hasExtension(filename)) { - if (!options.allowNonTsExtensions && !ts.fileExtensionIs(filename, ".ts")) { - diagnostic = ts.Diagnostics.File_0_must_have_extension_ts_or_d_ts; - } - else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - } - else if (refFile && host.getCanonicalFileName(filename) === host.getCanonicalFileName(refFile.filename)) { - diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; - } - } - else { - if (options.allowNonTsExtensions && !findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - } - else if (!findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) && !findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd)) { - diagnostic = ts.Diagnostics.File_0_not_found; - filename += ".ts"; - } - } - if (diagnostic) { - if (refFile) { - errors.push(ts.createFileDiagnostic(refFile, start, length, diagnostic, filename)); - } - else { - errors.push(ts.createCompilerDiagnostic(diagnostic, filename)); - } - } - } - function findSourceFile(filename, isDefaultLib, refFile, refStart, refLength) { - var canonicalName = host.getCanonicalFileName(filename); - if (ts.hasProperty(filesByName, canonicalName)) { - return getSourceFileFromCache(filename, canonicalName, false); - } - else { - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(filename, host.getCurrentDirectory()); - var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath); - if (ts.hasProperty(filesByName, canonicalAbsolutePath)) { - return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true); - } - var file = filesByName[canonicalName] = host.getSourceFile(filename, options.target, function (hostErrorMessage) { - errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage)); - }); - if (file) { - seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib; - filesByName[canonicalAbsolutePath] = file; - if (!options.noResolve) { - var basePath = ts.getDirectoryPath(filename); - processReferencedFiles(file, basePath); - processImportedModules(file, basePath); - } - if (isDefaultLib) { - files.unshift(file); - } - else { - files.push(file); - } - ts.forEach(file.getSyntacticDiagnostics(), function (e) { - errors.push(e); - }); - } - } - return file; - function getSourceFileFromCache(filename, canonicalName, useAbsolutePath) { - var file = filesByName[canonicalName]; - if (file && host.useCaseSensitiveFileNames()) { - var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.filename, host.getCurrentDirectory()) : file.filename; - if (canonicalName !== sourceFileName) { - errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Filename_0_differs_from_already_included_filename_1_only_in_casing, filename, sourceFileName)); - } - } - return file; - } - } - function processReferencedFiles(file, basePath) { - ts.forEach(file.referencedFiles, function (ref) { - var referencedFilename = ts.isRootedDiskPath(ref.filename) ? ref.filename : ts.combinePaths(basePath, ref.filename); - processSourceFile(ts.normalizePath(referencedFilename), false, file, ref.pos, ref.end); - }); - } - function processImportedModules(file, basePath) { - ts.forEach(file.statements, function (node) { - if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 7 /* StringLiteral */) { - var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - var searchPath = basePath; - while (true) { - var searchName = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - if (findModuleSourceFile(searchName + ".ts", nameLiteral) || findModuleSourceFile(searchName + ".d.ts", nameLiteral)) { - break; - } - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) { - break; - } - searchPath = parentPath; - } - } - } - else if (node.kind === 189 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { - forEachChild(node.body, function (node) { - if (ts.isExternalModuleImportDeclaration(node) && ts.getExternalModuleImportDeclarationExpression(node).kind === 7 /* StringLiteral */) { - var nameLiteral = ts.getExternalModuleImportDeclarationExpression(node); - var moduleName = nameLiteral.text; - if (moduleName) { - var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); - var tsFile = findModuleSourceFile(searchName + ".ts", nameLiteral); - if (!tsFile) { - findModuleSourceFile(searchName + ".d.ts", nameLiteral); - } - } - } - }); - } - }); - function findModuleSourceFile(filename, nameLiteral) { - return findSourceFile(filename, false, file, nameLiteral.pos, nameLiteral.end - nameLiteral.pos); - } - } - function verifyCompilerOptions() { - if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { - if (options.mapRoot) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option)); - } - if (options.sourceRoot) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option)); - } - return; - } - var firstExternalModule = ts.forEach(files, function (f) { return ts.isExternalModule(f) ? f : undefined; }); - if (firstExternalModule && options.module === 0 /* None */) { - var externalModuleErrorSpan = ts.getErrorSpanForNode(firstExternalModule.externalModuleIndicator); - var errorStart = ts.skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos); - var errorLength = externalModuleErrorSpan.end - errorStart; - errors.push(ts.createFileDiagnostic(firstExternalModule, errorStart, errorLength, ts.Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); - } - if (options.outDir || options.sourceRoot || (options.mapRoot && (!options.out || firstExternalModule !== undefined))) { - var commonPathComponents; - ts.forEach(files, function (sourceFile) { - if (!(sourceFile.flags & 1024 /* DeclarationFile */) && !ts.fileExtensionIs(sourceFile.filename, ".js")) { - var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile.filename, host.getCurrentDirectory()); - sourcePathComponents.pop(); - if (commonPathComponents) { - for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) { - if (commonPathComponents[i] !== sourcePathComponents[i]) { - if (i === 0) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files)); - return; - } - commonPathComponents.length = i; - break; - } - } - if (sourcePathComponents.length < commonPathComponents.length) { - commonPathComponents.length = sourcePathComponents.length; - } - } - else { - commonPathComponents = sourcePathComponents; - } - } - }); - commonSourceDirectory = ts.getNormalizedPathFromPathComponents(commonPathComponents); - if (commonSourceDirectory) { - commonSourceDirectory += ts.directorySeparator; - } - } - } - } - ts.createProgram = createProgram; -})(ts || (ts = {})); -var ts; -(function (ts) { - function getModuleInstanceState(node) { - if (node.kind === 186 /* InterfaceDeclaration */) { - return 0 /* NonInstantiated */; - } - else if (ts.isConstEnumDeclaration(node)) { - return 2 /* ConstEnumOnly */; - } - else if (node.kind === 191 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { - return 0 /* NonInstantiated */; - } - else if (node.kind === 190 /* ModuleBlock */) { - var state = 0 /* NonInstantiated */; - ts.forEachChild(node, function (n) { - switch (getModuleInstanceState(n)) { - case 0 /* NonInstantiated */: - return false; - case 2 /* ConstEnumOnly */: - state = 2 /* ConstEnumOnly */; - return false; - case 1 /* Instantiated */: - state = 1 /* Instantiated */; - return true; - } - }); - return state; - } - else if (node.kind === 189 /* ModuleDeclaration */) { - return getModuleInstanceState(node.body); - } - else { - return 1 /* Instantiated */; - } - } - ts.getModuleInstanceState = getModuleInstanceState; - function hasComputedNameButNotSymbol(declaration) { - return declaration.name && declaration.name.kind === 121 /* ComputedPropertyName */; - } - ts.hasComputedNameButNotSymbol = hasComputedNameButNotSymbol; - function bindSourceFile(file) { - var parent; - var container; - var blockScopeContainer; - var lastContainer; - var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - if (!file.locals) { - file.locals = {}; - container = blockScopeContainer = file; - bind(file); - file.symbolCount = symbolCount; - } - function createSymbol(flags, name) { - symbolCount++; - return new Symbol(flags, name); - } - function addDeclarationToSymbol(symbol, node, symbolKind) { - symbol.flags |= symbolKind; - if (!symbol.declarations) - symbol.declarations = []; - symbol.declarations.push(node); - if (symbolKind & 1952 /* HasExports */ && !symbol.exports) - symbol.exports = {}; - if (symbolKind & 6240 /* HasMembers */ && !symbol.members) - symbol.members = {}; - node.symbol = symbol; - if (symbolKind & 107455 /* Value */ && !symbol.valueDeclaration) - symbol.valueDeclaration = node; - } - function getDeclarationName(node) { - if (node.name) { - if (node.kind === 189 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { - return '"' + node.name.text + '"'; - } - ts.Debug.assert(!hasComputedNameButNotSymbol(node)); - return node.name.text; - } - switch (node.kind) { - case 134 /* ConstructorType */: - case 126 /* Constructor */: - return "__constructor"; - case 133 /* FunctionType */: - case 129 /* CallSignature */: - return "__call"; - case 130 /* ConstructSignature */: - return "__new"; - case 131 /* IndexSignature */: - return "__index"; - } - } - function getDisplayName(node) { - return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); - } - function declareSymbol(symbols, parent, node, includes, excludes) { - if (hasComputedNameButNotSymbol(node)) { - return undefined; - } - var name = getDeclarationName(node); - if (name !== undefined) { - var symbol = ts.hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name)); - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; - } - var message = symbol.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(symbol.declarations, function (declaration) { - file.semanticDiagnostics.push(ts.createDiagnosticForNode(declaration.name, message, getDisplayName(declaration))); - }); - file.semanticDiagnostics.push(ts.createDiagnosticForNode(node.name, message, getDisplayName(node))); - symbol = createSymbol(0, name); - } - } - else { - symbol = createSymbol(0, "__missing"); - } - addDeclarationToSymbol(symbol, node, includes); - symbol.parent = parent; - if (node.kind === 185 /* ClassDeclaration */ && symbol.exports) { - var prototypeSymbol = createSymbol(4 /* Property */ | 536870912 /* Prototype */, "prototype"); - if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { - if (node.name) { - node.name.parent = node; - } - file.semanticDiagnostics.push(ts.createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0], ts.Diagnostics.Duplicate_identifier_0, prototypeSymbol.name)); - } - symbol.exports[prototypeSymbol.name] = prototypeSymbol; - prototypeSymbol.parent = symbol; - } - return symbol; - } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2 /* Ambient */) - return true; - node = node.parent; - } - return false; - } - function declareModuleMember(node, symbolKind, symbolExcludes) { - var exportKind = 0; - if (symbolKind & 107455 /* Value */) { - exportKind |= 4194304 /* ExportValue */; - } - if (symbolKind & 3152352 /* Type */) { - exportKind |= 8388608 /* ExportType */; - } - if (symbolKind & 1536 /* Namespace */) { - exportKind |= 16777216 /* ExportNamespace */; - } - if (node.flags & 1 /* Export */ || (node.kind !== 191 /* ImportDeclaration */ && isAmbientContext(container))) { - if (exportKind) { - var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); - local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - node.localSymbol = local; - } - else { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - } - } - else { - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - } - } - function bindChildren(node, symbolKind, isBlockScopeContainer) { - if (symbolKind & 1041936 /* HasLocals */) { - node.locals = {}; - } - var saveParent = parent; - var saveContainer = container; - var savedBlockScopeContainer = blockScopeContainer; - parent = node; - if (symbolKind & 1048560 /* IsContainer */) { - container = node; - if (lastContainer !== container && !container.nextContainer) { - if (lastContainer) { - lastContainer.nextContainer = container; - } - lastContainer = container; - } - } - if (isBlockScopeContainer) { - blockScopeContainer = node; - } - ts.forEachChild(node, bind); - container = saveContainer; - parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { - switch (container.kind) { - case 189 /* ModuleDeclaration */: - declareModuleMember(node, symbolKind, symbolExcludes); - break; - case 201 /* SourceFile */: - if (ts.isExternalModule(container)) { - declareModuleMember(node, symbolKind, symbolExcludes); - break; - } - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 184 /* FunctionDeclaration */: - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); - break; - case 185 /* ClassDeclaration */: - if (node.flags & 128 /* Static */) { - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - break; - } - case 136 /* TypeLiteral */: - case 142 /* ObjectLiteralExpression */: - case 186 /* InterfaceDeclaration */: - declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); - break; - case 188 /* EnumDeclaration */: - declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); - break; - } - bindChildren(node, symbolKind, isBlockScopeContainer); - } - function bindConstructorDeclaration(node) { - bindDeclaration(node, 16384 /* Constructor */, 0, true); - ts.forEach(node.parameters, function (p) { - if (p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */)) { - bindDeclaration(p, 4 /* Property */, 107455 /* PropertyExcludes */, false); - } - }); - } - function bindModuleDeclaration(node) { - if (node.name.kind === 7 /* StringLiteral */) { - bindDeclaration(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */, true); - } - else { - var state = getModuleInstanceState(node); - if (state === 0 /* NonInstantiated */) { - bindDeclaration(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */, true); - } - else { - bindDeclaration(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */, true); - if (state === 2 /* ConstEnumOnly */) { - node.symbol.constEnumOnlyModule = true; - } - else if (node.symbol.constEnumOnlyModule) { - node.symbol.constEnumOnlyModule = false; - } - } - } - } - function bindFunctionOrConstructorType(node) { - var symbolKind = node.kind === 133 /* FunctionType */ ? 131072 /* CallSignature */ : 262144 /* ConstructSignature */; - var symbol = createSymbol(symbolKind, getDeclarationName(node)); - addDeclarationToSymbol(symbol, node, symbolKind); - bindChildren(node, symbolKind, false); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type"); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); - typeLiteralSymbol.members = {}; - typeLiteralSymbol.members[node.kind === 133 /* FunctionType */ ? "__call" : "__new"] = symbol; - } - function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { - var symbol = createSymbol(symbolKind, name); - addDeclarationToSymbol(symbol, node, symbolKind); - bindChildren(node, symbolKind, isBlockScopeContainer); - } - function bindCatchVariableDeclaration(node) { - var symbol = createSymbol(1 /* FunctionScopedVariable */, node.name.text || "__missing"); - addDeclarationToSymbol(symbol, node, 1 /* FunctionScopedVariable */); - var saveParent = parent; - var savedBlockScopeContainer = blockScopeContainer; - parent = blockScopeContainer = node; - ts.forEachChild(node, bind); - parent = saveParent; - blockScopeContainer = savedBlockScopeContainer; - } - function bindBlockScopedVariableDeclaration(node) { - switch (blockScopeContainer.kind) { - case 189 /* ModuleDeclaration */: - declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); - break; - case 201 /* SourceFile */: - if (ts.isExternalModule(container)) { - declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); - break; - } - default: - if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; - } - declareSymbol(blockScopeContainer.locals, undefined, node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); - } - bindChildren(node, 2 /* BlockScopedVariable */, false); - } - function bind(node) { - node.parent = parent; - switch (node.kind) { - case 122 /* TypeParameter */: - bindDeclaration(node, 1048576 /* TypeParameter */, 2103776 /* TypeParameterExcludes */, false); - break; - case 123 /* Parameter */: - bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false); - break; - case 183 /* VariableDeclaration */: - if (node.flags & 6144 /* BlockScoped */) { - bindBlockScopedVariableDeclaration(node); - } - else { - bindDeclaration(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */, false); - } - break; - case 124 /* Property */: - case 198 /* PropertyAssignment */: - case 199 /* ShorthandPropertyAssignment */: - bindDeclaration(node, 4 /* Property */, 107455 /* PropertyExcludes */, false); - break; - case 200 /* EnumMember */: - bindDeclaration(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false); - break; - case 129 /* CallSignature */: - bindDeclaration(node, 131072 /* CallSignature */, 0, false); - break; - case 130 /* ConstructSignature */: - bindDeclaration(node, 262144 /* ConstructSignature */, 0, true); - break; - case 125 /* Method */: - bindDeclaration(node, 8192 /* Method */, ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */, true); - break; - case 131 /* IndexSignature */: - bindDeclaration(node, 524288 /* IndexSignature */, 0, false); - break; - case 184 /* FunctionDeclaration */: - bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true); - break; - case 126 /* Constructor */: - bindConstructorDeclaration(node); - break; - case 127 /* GetAccessor */: - bindDeclaration(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */, true); - break; - case 128 /* SetAccessor */: - bindDeclaration(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */, true); - break; - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - bindFunctionOrConstructorType(node); - break; - case 136 /* TypeLiteral */: - bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type", false); - break; - case 142 /* ObjectLiteralExpression */: - bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object", false); - break; - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - bindAnonymousDeclaration(node, 16 /* Function */, "__function", true); - break; - case 197 /* CatchClause */: - bindCatchVariableDeclaration(node); - break; - case 185 /* ClassDeclaration */: - bindDeclaration(node, 32 /* Class */, 3258879 /* ClassExcludes */, false); - break; - case 186 /* InterfaceDeclaration */: - bindDeclaration(node, 64 /* Interface */, 3152288 /* InterfaceExcludes */, false); - break; - case 187 /* TypeAliasDeclaration */: - bindDeclaration(node, 2097152 /* TypeAlias */, 3152352 /* TypeAliasExcludes */, false); - break; - case 188 /* EnumDeclaration */: - if (ts.isConst(node)) { - bindDeclaration(node, 128 /* ConstEnum */, 3259263 /* ConstEnumExcludes */, false); - } - else { - bindDeclaration(node, 256 /* RegularEnum */, 3258623 /* RegularEnumExcludes */, false); - } - break; - case 189 /* ModuleDeclaration */: - bindModuleDeclaration(node); - break; - case 191 /* ImportDeclaration */: - bindDeclaration(node, 33554432 /* Import */, 33554432 /* ImportExcludes */, false); - break; - case 201 /* SourceFile */: - if (ts.isExternalModule(node)) { - bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true); - break; - } - case 163 /* Block */: - case 180 /* TryBlock */: - case 197 /* CatchClause */: - case 181 /* FinallyBlock */: - case 170 /* ForStatement */: - case 171 /* ForInStatement */: - case 176 /* SwitchStatement */: - bindChildren(node, 0, true); - break; - default: - var saveParent = parent; - parent = node; - ts.forEachChild(node, bind); - parent = saveParent; - } - } - } - ts.bindSourceFile = bindSourceFile; -})(ts || (ts = {})); -var ts; -(function (ts) { - var indentStrings = ["", " "]; - function getIndentString(level) { - if (indentStrings[level] === undefined) { - indentStrings[level] = getIndentString(level - 1) + indentStrings[1]; - } - return indentStrings[level]; - } - ts.getIndentString = getIndentString; - function getIndentSize() { - return indentStrings[1].length; - } - function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!ts.isDeclarationFile(sourceFile)) { - if ((ts.isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.filename, ".js")) { - return true; - } - return false; - } - return false; - } - ts.shouldEmitToOwnFile = shouldEmitToOwnFile; - function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); - } - ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; - function createTextWriter(newLine) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.computeLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - function writeTextOfNode(sourceFile, node) { - write(ts.getSourceTextOfNodeFromSourceFile(sourceFile, node)); - } - return { - write: write, - rawWrite: rawWrite, - writeTextOfNode: writeTextOfNode, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - function getLineOfLocalPosition(currentSourceFile, pos) { - return currentSourceFile.getLineAndCharacterFromPosition(pos).line; - } - function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { - writer.writeLine(); - } - } - function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(currentSourceFile, writer, comment, newLine); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - emitLeadingSpace = true; - } - }); - } - function writeCommentRange(currentSourceFile, writer, comment, newLine) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { - var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos); - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, 1); - if (pos !== comment.pos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, 1), comment.pos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); - if (currentLineText) { - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - } - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 126 /* Constructor */ && member.body) { - return member; - } - }); - } - function getAllAccessorDeclarations(node, accessor) { - var firstAccessor; - var getAccessor; - var setAccessor; - if (accessor.name.kind === 121 /* ComputedPropertyName */) { - firstAccessor = accessor; - if (accessor.kind === 127 /* GetAccessor */) { - getAccessor = accessor; - } - else if (accessor.kind === 128 /* SetAccessor */) { - setAccessor = accessor; - } - else { - ts.Debug.fail("Accessor has wrong kind"); - } - } - else { - ts.forEach(node.members, function (member) { - if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 127 /* GetAccessor */ && !getAccessor) { - getAccessor = member; - } - if (member.kind === 128 /* SetAccessor */ && !setAccessor) { - setAccessor = member; - } - } - }); - } - return { - firstAccessor: firstAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - function getSourceFilePathInNewDir(sourceFile, program, newDirPath) { - var compilerHost = program.getCompilerHost(); - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.filename, compilerHost.getCurrentDirectory()); - sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - function getOwnEmitOutputFilePath(sourceFile, program, extension) { - var compilerOptions = program.getCompilerOptions(); - if (compilerOptions.outDir) { - var emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, program, compilerOptions.outDir)); - } - else { - var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.filename); - } - return emitOutputFilePathWithoutExtension + extension; - } - function writeFile(compilerHost, diagnostics, filename, data, writeByteOrderMark) { - compilerHost.writeFile(filename, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage)); - }); - } - function emitDeclarations(program, resolver, diagnostics, jsFilePath, root) { - var newLine = program.getCompilerHost().getNewLine(); - var compilerOptions = program.getCompilerOptions(); - var compilerHost = program.getCompilerHost(); - var write; - var writeLine; - var increaseIndent; - var decreaseIndent; - var writeTextOfNode; - var writer = createAndSetNewTextWriterWithSymbolWriter(); - var enclosingDeclaration; - var currentSourceFile; - var reportedDeclarationError = false; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { - } : writeJsDocComments; - var aliasDeclarationEmitInfo = []; - function createAndSetNewTextWriterWithSymbolWriter() { - var writer = createTextWriter(newLine); - writer.trackSymbol = trackSymbol; - writer.writeKeyword = writer.write; - writer.writeOperator = writer.write; - writer.writePunctuation = writer.write; - writer.writeSpace = writer.write; - writer.writeStringLiteral = writer.writeLiteral; - writer.writeParameter = writer.write; - writer.writeSymbol = writer.write; - setWriter(writer); - return writer; - } - function setWriter(newWriter) { - writer = newWriter; - write = newWriter.write; - writeTextOfNode = newWriter.writeTextOfNode; - writeLine = newWriter.writeLine; - increaseIndent = newWriter.increaseIndent; - decreaseIndent = newWriter.decreaseIndent; - } - function writeAsychronousImportDeclarations(importDeclarations) { - var oldWriter = writer; - ts.forEach(importDeclarations, function (aliasToWrite) { - var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; }); - if (aliasEmitInfo) { - createAndSetNewTextWriterWithSymbolWriter(); - for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { - increaseIndent(); - } - writeImportDeclaration(aliasToWrite); - aliasEmitInfo.asynchronousOutput = writer.getText(); - } - }); - setWriter(oldWriter); - } - function handleSymbolAccessibilityError(symbolAccesibilityResult) { - if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - reportedDeclarationError = true; - var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult); - if (errorInfo) { - if (errorInfo.typeName) { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - else { - diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - } - } - } - function trackSymbol(symbol, enclosingDeclaration, meaning) { - handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning)); - } - function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (type) { - emitType(type); - } - else { - resolver.writeTypeOfDeclaration(declaration, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - } - function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - write(": "); - if (signature.type) { - emitType(signature.type); - } - else { - resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - } - function emitLines(nodes) { - for (var i = 0, n = nodes.length; i < n; i++) { - emitNode(nodes[i]); - } - } - function emitSeparatedList(nodes, separator, eachNodeEmitFn) { - var currentWriterPos = writer.getTextPos(); - for (var i = 0, n = nodes.length; i < n; i++) { - if (currentWriterPos !== writer.getTextPos()) { - write(separator); - } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(nodes[i]); - } - } - function emitCommaList(nodes, eachNodeEmitFn) { - emitSeparatedList(nodes, ", ", eachNodeEmitFn); - } - function writeJsDocComments(declaration) { - if (declaration) { - var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); - emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); - } - } - function emitTypeWithNewGetSymbolAccessibilityDiagnostic(type, getSymbolAccessibilityDiagnostic) { - writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; - emitType(type); - } - function emitType(type) { - switch (type.kind) { - case 109 /* AnyKeyword */: - case 118 /* StringKeyword */: - case 116 /* NumberKeyword */: - case 110 /* BooleanKeyword */: - case 97 /* VoidKeyword */: - case 7 /* StringLiteral */: - return writeTextOfNode(currentSourceFile, type); - case 132 /* TypeReference */: - return emitTypeReference(type); - case 135 /* TypeQuery */: - return emitTypeQuery(type); - case 137 /* ArrayType */: - return emitArrayType(type); - case 138 /* TupleType */: - return emitTupleType(type); - case 139 /* UnionType */: - return emitUnionType(type); - case 140 /* ParenthesizedType */: - return emitParenType(type); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - return emitSignatureDeclarationWithJsDocComments(type); - case 136 /* TypeLiteral */: - return emitTypeLiteral(type); - case 63 /* Identifier */: - return emitEntityName(type); - case 120 /* QualifiedName */: - return emitEntityName(type); - default: - ts.Debug.fail("Unknown type annotation: " + type.kind); - } - function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 191 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration); - handleSymbolAccessibilityError(visibilityResult); - writeEntityName(entityName); - function writeEntityName(entityName) { - if (entityName.kind === 63 /* Identifier */) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - var qualifiedName = entityName; - writeEntityName(qualifiedName.left); - write("."); - writeTextOfNode(currentSourceFile, qualifiedName.right); - } - } - } - function emitTypeReference(type) { - emitEntityName(type.typeName); - if (type.typeArguments) { - write("<"); - emitCommaList(type.typeArguments, emitType); - write(">"); - } - } - function emitTypeQuery(type) { - write("typeof "); - emitEntityName(type.exprName); - } - function emitArrayType(type) { - emitType(type.elementType); - write("[]"); - } - function emitTupleType(type) { - write("["); - emitCommaList(type.elementTypes, emitType); - write("]"); - } - function emitUnionType(type) { - emitSeparatedList(type.types, " | ", emitType); - } - function emitParenType(type) { - write("("); - emitType(type.type); - write(")"); - } - function emitTypeLiteral(type) { - write("{"); - if (type.members.length) { - writeLine(); - increaseIndent(); - emitLines(type.members); - decreaseIndent(); - } - write("}"); - } - } - function emitSourceFile(node) { - currentSourceFile = node; - enclosingDeclaration = node; - emitLines(node.statements); - } - function emitExportAssignment(node) { - write("export = "); - writeTextOfNode(currentSourceFile, node.exportName); - write(";"); - writeLine(); - } - function emitModuleElementDeclarationFlags(node) { - if (node.parent === currentSourceFile) { - if (node.flags & 1 /* Export */) { - write("export "); - } - if (node.kind !== 186 /* InterfaceDeclaration */) { - write("declare "); - } - } - } - function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32 /* Private */) { - write("private "); - } - else if (node.flags & 64 /* Protected */) { - write("protected "); - } - if (node.flags & 128 /* Static */) { - write("static "); - } - } - function emitImportDeclaration(node) { - var nodeEmitInfo = { - declaration: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - hasWritten: resolver.isDeclarationVisible(node) - }; - aliasDeclarationEmitInfo.push(nodeEmitInfo); - if (nodeEmitInfo.hasWritten) { - writeImportDeclaration(node); - } - } - function writeImportDeclaration(node) { - emitJsDocComments(node); - if (node.flags & 1 /* Export */) { - write("export "); - } - write("import "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - if (ts.isInternalModuleImportDeclaration(node)) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.moduleReference, getImportEntityNameVisibilityError); - write(";"); - } - else { - write("require("); - writeTextOfNode(currentSourceFile, ts.getExternalModuleImportDeclarationExpression(node)); - write(");"); - } - writer.writeLine(); - function getImportEntityNameVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1, - errorNode: node, - typeName: node.name - }; - } - } - function emitModuleDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("module "); - writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 190 /* ModuleBlock */) { - node = node.body; - write("."); - writeTextOfNode(currentSourceFile, node.name); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - function emitTypeAliasDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("type "); - writeTextOfNode(currentSourceFile, node.name); - write(" = "); - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.type, getTypeAliasDeclarationVisibilityError); - write(";"); - writeLine(); - } - function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) { - return { - diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1, - errorNode: node.type, - typeName: node.name - }; - } - } - function emitEnumDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isConst(node)) { - write("const "); - } - write("enum "); - writeTextOfNode(currentSourceFile, node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - } - } - function emitEnumMemberDeclaration(node) { - emitJsDocComments(node); - writeTextOfNode(currentSourceFile, node.name); - var enumMemberValue = resolver.getEnumMemberValue(node); - if (enumMemberValue !== undefined) { - write(" = "); - write(enumMemberValue.toString()); - } - write(","); - writeLine(); - } - function emitTypeParameters(typeParameters) { - function emitTypeParameter(node) { - increaseIndent(); - emitJsDocComments(node); - decreaseIndent(); - writeTextOfNode(currentSourceFile, node.name); - if (node.constraint && (node.parent.kind !== 125 /* Method */ || !(node.parent.flags & 32 /* Private */))) { - write(" extends "); - if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || (node.parent.parent && node.parent.parent.kind === 136 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 125 /* Method */ || node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.kind === 129 /* CallSignature */ || node.parent.kind === 130 /* ConstructSignature */); - emitType(node.constraint); - } - else { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node.constraint, getTypeParameterConstraintVisibilityError); - } - } - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.parent.kind) { - case 185 /* ClassDeclaration */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; - break; - case 186 /* InterfaceDeclaration */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; - break; - case 130 /* ConstructSignature */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 129 /* CallSignature */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 125 /* Method */: - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 185 /* ClassDeclaration */) { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 184 /* FunctionDeclaration */: - diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - if (typeParameters) { - write("<"); - emitCommaList(typeParameters, emitTypeParameter); - write(">"); - } - } - function emitHeritageClause(typeReferences, isImplementsList) { - if (typeReferences) { - write(isImplementsList ? " implements " : " extends "); - emitCommaList(typeReferences, emitTypeOfTypeReference); - } - function emitTypeOfTypeReference(node) { - emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.parent.parent.kind === 185 /* ClassDeclaration */) { - diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.parent.parent.name - }; - } - } - } - function emitClassDeclaration(node) { - function emitParameterProperties(constructorDeclaration) { - if (constructorDeclaration) { - ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { - emitPropertyDeclaration(param); - } - }); - } - } - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("class "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - var baseTypeNode = ts.getClassBaseTypeNode(node); - if (baseTypeNode) { - emitHeritageClause([baseTypeNode], false); - } - emitHeritageClause(ts.getClassImplementedTypeNodes(node), true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - function emitInterfaceDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - write("interface "); - writeTextOfNode(currentSourceFile, node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - function emitPropertyDeclaration(node) { - emitJsDocComments(node); - emitClassMemberDeclarationFlags(node); - emitVariableDeclaration(node); - write(";"); - writeLine(); - } - function emitVariableDeclaration(node) { - if (node.kind !== 183 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { - writeTextOfNode(currentSourceFile, node.name); - if (node.kind === 124 /* Property */ && ts.hasQuestionToken(node)) { - write("?"); - } - if (node.kind === 124 /* Property */ && node.parent.kind === 136 /* TypeLiteral */) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.flags & 32 /* Private */)) { - writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); - } - } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.kind === 183 /* VariableDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } - else if (node.kind === 124 /* Property */) { - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.kind === 185 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; - } - } - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - } - function emitTypeOfVariableDeclarationFromTypeLiteral(node) { - if (node.type) { - write(": "); - emitType(node.type); - } - } - function emitVariableStatement(node) { - var hasDeclarationWithEmit = ts.forEach(node.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - if (hasDeclarationWithEmit) { - emitJsDocComments(node); - emitModuleElementDeclarationFlags(node); - if (ts.isLet(node)) { - write("let "); - } - else if (ts.isConst(node)) { - write("const "); - } - else { - write("var "); - } - emitCommaList(node.declarations, emitVariableDeclaration); - write(";"); - writeLine(); - } - } - function emitAccessorDeclaration(node) { - var accessors = getAllAccessorDeclarations(node.parent, node); - if (node === accessors.firstAccessor) { - emitJsDocComments(accessors.getAccessor); - emitJsDocComments(accessors.setAccessor); - emitClassMemberDeclarationFlags(node); - writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32 /* Private */)) { - var accessorWithTypeAnnotation = node; - var type = getTypeAnnotationFromAccessor(node); - if (!type) { - var anotherAccessor = node.kind === 127 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; - type = getTypeAnnotationFromAccessor(anotherAccessor); - if (type) { - accessorWithTypeAnnotation = anotherAccessor; - } - } - writeTypeOfDeclaration(node, type, getAccessorDeclarationTypeVisibilityError); - } - write(";"); - writeLine(); - } - function getTypeAnnotationFromAccessor(accessor) { - if (accessor) { - return accessor.kind === 127 /* GetAccessor */ ? accessor.type : accessor.parameters[0].type; - } - } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 128 /* SetAccessor */) { - if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.parameters[0], - typeName: accessorWithTypeAnnotation.name - }; - } - else { - if (accessorWithTypeAnnotation.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: accessorWithTypeAnnotation.name, - typeName: undefined - }; - } - } - } - function emitFunctionDeclaration(node) { - if ((node.kind !== 184 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { - emitJsDocComments(node); - if (node.kind === 184 /* FunctionDeclaration */) { - emitModuleElementDeclarationFlags(node); - } - else if (node.kind === 125 /* Method */) { - emitClassMemberDeclarationFlags(node); - } - if (node.kind === 184 /* FunctionDeclaration */) { - write("function "); - writeTextOfNode(currentSourceFile, node.name); - } - else if (node.kind === 126 /* Constructor */) { - write("constructor"); - } - else { - writeTextOfNode(currentSourceFile, node.name); - if (ts.hasQuestionToken(node)) { - write("?"); - } - } - emitSignatureDeclaration(node); - } - } - function emitSignatureDeclarationWithJsDocComments(node) { - emitJsDocComments(node); - emitSignatureDeclaration(node); - } - function emitSignatureDeclaration(node) { - if (node.kind === 130 /* ConstructSignature */ || node.kind === 134 /* ConstructorType */) { - write("new "); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 131 /* IndexSignature */) { - write("["); - } - else { - write("("); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 131 /* IndexSignature */) { - write("]"); - } - else { - write(")"); - } - var isFunctionTypeOrConstructorType = node.kind === 133 /* FunctionType */ || node.kind === 134 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 136 /* TypeLiteral */) { - if (node.type) { - write(isFunctionTypeOrConstructorType ? " => " : ": "); - emitType(node.type); - } - } - else if (node.kind !== 126 /* Constructor */ && !(node.flags & 32 /* Private */)) { - writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); - } - enclosingDeclaration = prevEnclosingDeclaration; - if (!isFunctionTypeOrConstructorType) { - write(";"); - writeLine(); - } - function getReturnTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.kind) { - case 130 /* ConstructSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 129 /* CallSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 131 /* IndexSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 125 /* Method */: - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; - } - else if (node.parent.kind === 185 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; - } - break; - case 184 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; - break; - default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.name || node - }; - } - } - function emitParameterDeclaration(node) { - increaseIndent(); - emitJsDocComments(node); - if (node.dotDotDotToken) { - write("..."); - } - writeTextOfNode(currentSourceFile, node.name); - if (node.initializer || ts.hasQuestionToken(node)) { - write("?"); - } - decreaseIndent(); - if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.parent.kind === 136 /* TypeLiteral */) { - emitTypeOfVariableDeclarationFromTypeLiteral(node); - } - else if (!(node.parent.flags & 32 /* Private */)) { - writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); - } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.parent.kind) { - case 126 /* Constructor */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - break; - case 130 /* ConstructSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 129 /* CallSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 125 /* Method */: - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 185 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 184 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - function emitNode(node) { - switch (node.kind) { - case 126 /* Constructor */: - case 184 /* FunctionDeclaration */: - case 125 /* Method */: - return emitFunctionDeclaration(node); - case 130 /* ConstructSignature */: - case 129 /* CallSignature */: - case 131 /* IndexSignature */: - return emitSignatureDeclarationWithJsDocComments(node); - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - return emitAccessorDeclaration(node); - case 164 /* VariableStatement */: - return emitVariableStatement(node); - case 124 /* Property */: - return emitPropertyDeclaration(node); - case 186 /* InterfaceDeclaration */: - return emitInterfaceDeclaration(node); - case 185 /* ClassDeclaration */: - return emitClassDeclaration(node); - case 187 /* TypeAliasDeclaration */: - return emitTypeAliasDeclaration(node); - case 200 /* EnumMember */: - return emitEnumMemberDeclaration(node); - case 188 /* EnumDeclaration */: - return emitEnumDeclaration(node); - case 189 /* ModuleDeclaration */: - return emitModuleDeclaration(node); - case 191 /* ImportDeclaration */: - return emitImportDeclaration(node); - case 192 /* ExportAssignment */: - return emitExportAssignment(node); - case 201 /* SourceFile */: - return emitSourceFile(node); - } - } - var referencePathsOutput = ""; - function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 1024 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, program, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; - declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, false); - referencePathsOutput += "/// " + newLine; - } - if (root) { - if (!compilerOptions.noResolve) { - var addedGlobalFileReference = false; - ts.forEach(root.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(program, root, fileReference); - if (referencedFile && ((referencedFile.flags & 1024 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { - writeReferencePath(referencedFile); - if (!isExternalModuleOrDeclarationFile(referencedFile)) { - addedGlobalFileReference = true; - } - } - }); - } - emitNode(root); - } - else { - var emittedReferencedFiles = []; - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - if (!compilerOptions.noResolve) { - ts.forEach(sourceFile.referencedFiles, function (fileReference) { - var referencedFile = ts.tryResolveScriptReference(program, sourceFile, fileReference); - if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) { - writeReferencePath(referencedFile); - emittedReferencedFiles.push(referencedFile); - } - }); - } - emitNode(sourceFile); - } - }); - } - return { - reportedDeclarationError: reportedDeclarationError, - aliasDeclarationEmitInfo: aliasDeclarationEmitInfo, - synchronousDeclarationOutput: writer.getText(), - referencePathsOutput: referencePathsOutput - }; - } - function getDeclarationDiagnostics(program, resolver, targetSourceFile) { - var diagnostics = []; - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); - emitDeclarations(program, resolver, diagnostics, jsFilePath, targetSourceFile); - return diagnostics; - } - ts.getDeclarationDiagnostics = getDeclarationDiagnostics; - function emitFiles(resolver, targetSourceFile) { - var program = resolver.getProgram(); - var compilerHost = program.getCompilerHost(); - var compilerOptions = program.getCompilerOptions(); - var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; - var diagnostics = []; - var newLine = program.getCompilerHost().getNewLine(); - function emitJavaScript(jsFilePath, root) { - var writer = createTextWriter(newLine); - var write = writer.write; - var writeTextOfNode = writer.writeTextOfNode; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; - var currentSourceFile; - var extendsEmitted = false; - var writeEmittedFiles = writeJavaScriptFile; - var emitLeadingComments = compilerOptions.removeComments ? function (node) { - } : emitLeadingDeclarationComments; - var emitTrailingComments = compilerOptions.removeComments ? function (node) { - } : emitTrailingDeclarationComments; - var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { - } : emitLeadingCommentsOfLocalPosition; - var detachedCommentsInfo; - var emitDetachedComments = compilerOptions.removeComments ? function (node) { - } : emitDetachedCommentsAtPosition; - var emitPinnedOrTripleSlashComments = compilerOptions.removeComments ? function (node) { - } : emitPinnedOrTripleSlashCommentsOfNode; - var writeComment = writeCommentRange; - var emit = emitNode; - var emitStart = function (node) { - }; - var emitEnd = function (node) { - }; - var emitToken = emitTokenText; - var scopeEmitStart = function (scopeDeclaration, scopeName) { - }; - var scopeEmitEnd = function () { - }; - var sourceMapData; - function initializeEmitterWithSourceMaps() { - var sourceMapDir; - var sourceMapSourceIndex = -1; - var sourceMapNameIndexMap = {}; - var sourceMapNameIndices = []; - function getSourceMapNameIndex() { - return sourceMapNameIndices.length ? sourceMapNameIndices[sourceMapNameIndices.length - 1] : -1; - } - var lastRecordedSourceMapSpan; - var lastEncodedSourceMapSpan = { - emittedLine: 1, - emittedColumn: 1, - sourceLine: 1, - sourceColumn: 1, - sourceIndex: 0 - }; - var lastEncodedNameIndex = 0; - function encodeLastRecordedSourceMapSpan() { - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { - return; - } - var prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn; - if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) { - if (sourceMapData.sourceMapMappings) { - sourceMapData.sourceMapMappings += ","; - } - } - else { - for (var encodedLine = lastEncodedSourceMapSpan.emittedLine; encodedLine < lastRecordedSourceMapSpan.emittedLine; encodedLine++) { - sourceMapData.sourceMapMappings += ";"; - } - prevEncodedEmittedColumn = 1; - } - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine); - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn); - if (lastRecordedSourceMapSpan.nameIndex >= 0) { - sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.nameIndex - lastEncodedNameIndex); - lastEncodedNameIndex = lastRecordedSourceMapSpan.nameIndex; - } - lastEncodedSourceMapSpan = lastRecordedSourceMapSpan; - sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); - function base64VLQFormatEncode(inValue) { - function base64FormatEncode(inValue) { - if (inValue < 64) { - return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(inValue); - } - throw TypeError(inValue + ": not a 64 based value"); - } - if (inValue < 0) { - inValue = ((-inValue) << 1) + 1; - } - else { - inValue = inValue << 1; - } - var encodedStr = ""; - do { - var currentDigit = inValue & 31; - inValue = inValue >> 5; - if (inValue > 0) { - currentDigit = currentDigit | 32; - } - encodedStr = encodedStr + base64FormatEncode(currentDigit); - } while (inValue > 0); - return encodedStr; - } - } - function recordSourceMapSpan(pos) { - var sourceLinePos = currentSourceFile.getLineAndCharacterFromPosition(pos); - var emittedLine = writer.getLine(); - var emittedColumn = writer.getColumn(); - if (!lastRecordedSourceMapSpan || lastRecordedSourceMapSpan.emittedLine != emittedLine || lastRecordedSourceMapSpan.emittedColumn != emittedColumn || (lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex && (lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line || (lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) { - encodeLastRecordedSourceMapSpan(); - lastRecordedSourceMapSpan = { - emittedLine: emittedLine, - emittedColumn: emittedColumn, - sourceLine: sourceLinePos.line, - sourceColumn: sourceLinePos.character, - nameIndex: getSourceMapNameIndex(), - sourceIndex: sourceMapSourceIndex - }; - } - else { - lastRecordedSourceMapSpan.sourceLine = sourceLinePos.line; - lastRecordedSourceMapSpan.sourceColumn = sourceLinePos.character; - lastRecordedSourceMapSpan.sourceIndex = sourceMapSourceIndex; - } - } - function recordEmitNodeStartSpan(node) { - recordSourceMapSpan(ts.skipTrivia(currentSourceFile.text, node.pos)); - } - function recordEmitNodeEndSpan(node) { - recordSourceMapSpan(node.end); - } - function writeTextWithSpanRecord(tokenKind, startPos, emitFn) { - var tokenStartPos = ts.skipTrivia(currentSourceFile.text, startPos); - recordSourceMapSpan(tokenStartPos); - var tokenEndPos = emitTokenText(tokenKind, tokenStartPos, emitFn); - recordSourceMapSpan(tokenEndPos); - return tokenEndPos; - } - function recordNewSourceFileStart(node) { - var sourcesDirectoryPath = compilerOptions.sourceRoot ? program.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.filename, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, true)); - sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; - sourceMapData.inputSourceFileNames.push(node.filename); - } - function recordScopeNameOfNode(node, scopeName) { - function recordScopeNameIndex(scopeNameIndex) { - sourceMapNameIndices.push(scopeNameIndex); - } - function recordScopeNameStart(scopeName) { - var scopeNameIndex = -1; - if (scopeName) { - var parentIndex = getSourceMapNameIndex(); - if (parentIndex !== -1) { - scopeName = sourceMapData.sourceMapNames[parentIndex] + "." + scopeName; - } - scopeNameIndex = ts.getProperty(sourceMapNameIndexMap, scopeName); - if (scopeNameIndex === undefined) { - scopeNameIndex = sourceMapData.sourceMapNames.length; - sourceMapData.sourceMapNames.push(scopeName); - sourceMapNameIndexMap[scopeName] = scopeNameIndex; - } - } - recordScopeNameIndex(scopeNameIndex); - } - if (scopeName) { - recordScopeNameStart(scopeName); - } - else if (node.kind === 184 /* FunctionDeclaration */ || node.kind === 150 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 189 /* ModuleDeclaration */ || node.kind === 185 /* ClassDeclaration */ || node.kind === 188 /* EnumDeclaration */) { - if (node.name) { - scopeName = node.name.text; - } - recordScopeNameStart(scopeName); - } - else { - recordScopeNameIndex(getSourceMapNameIndex()); - } - } - function recordScopeNameEnd() { - sourceMapNameIndices.pop(); - } - ; - function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { - recordSourceMapSpan(comment.pos); - writeCommentRange(currentSourceFile, writer, comment, newLine); - recordSourceMapSpan(comment.end); - } - function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { - if (typeof JSON !== "undefined") { - return JSON.stringify({ - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }); - } - return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\"}"; - function serializeStringArray(list) { - var output = ""; - for (var i = 0, n = list.length; i < n; i++) { - if (i) { - output += ","; - } - output += "\"" + ts.escapeString(list[i]) + "\""; - } - return output; - } - } - function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { - encodeLastRecordedSourceMapSpan(); - writeFile(compilerHost, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); - sourceMapDataList.push(sourceMapData); - writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); - } - var sourceMapJsFile = ts.getBaseFilename(ts.normalizeSlashes(jsFilePath)); - sourceMapData = { - sourceMapFilePath: jsFilePath + ".map", - jsSourceMappingURL: sourceMapJsFile + ".map", - sourceMapFile: sourceMapJsFile, - sourceMapSourceRoot: compilerOptions.sourceRoot || "", - sourceMapSources: [], - inputSourceFileNames: [], - sourceMapNames: [], - sourceMapMappings: "", - sourceMapDecodedMappings: [] - }; - sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot); - if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== 47 /* slash */) { - sourceMapData.sourceMapSourceRoot += ts.directorySeparator; - } - if (compilerOptions.mapRoot) { - sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (root) { - sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(root, program, sourceMapDir)); - } - if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { - sourceMapDir = ts.combinePaths(program.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, true); - } - else { - sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); - } - } - else { - sourceMapDir = ts.getDirectoryPath(ts.normalizePath(jsFilePath)); - } - function emitNodeWithMap(node) { - if (node) { - if (node.kind != 201 /* SourceFile */) { - recordEmitNodeStartSpan(node); - emitNode(node); - recordEmitNodeEndSpan(node); - } - else { - recordNewSourceFileStart(node); - emitNode(node); - } - } - } - writeEmittedFiles = writeJavaScriptAndSourceMapFile; - emit = emitNodeWithMap; - emitStart = recordEmitNodeStartSpan; - emitEnd = recordEmitNodeEndSpan; - emitToken = writeTextWithSpanRecord; - scopeEmitStart = recordScopeNameOfNode; - scopeEmitEnd = recordScopeNameEnd; - writeComment = writeCommentRangeWithMap; - } - function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - writeFile(compilerHost, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); - } - function emitTokenText(tokenKind, startPos, emitFn) { - var tokenString = ts.tokenToString(tokenKind); - if (emitFn) { - emitFn(); - } - else { - write(tokenString); - } - return startPos + tokenString.length; - } - function emitOptional(prefix, node) { - if (node) { - write(prefix); - emit(node); - } - } - function emitTrailingCommaIfPresent(nodeList, isMultiline) { - if (nodeList.hasTrailingComma) { - write(","); - if (isMultiline) { - writeLine(); - } - } - } - function emitCommaList(nodes, includeTrailingComma, count) { - if (!(count >= 0)) { - count = nodes.length; - } - if (nodes) { - for (var i = 0; i < count; i++) { - if (i) { - write(", "); - } - emit(nodes[i]); - } - if (includeTrailingComma) { - emitTrailingCommaIfPresent(nodes, false); - } - } - } - function emitMultiLineList(nodes, includeTrailingComma) { - if (nodes) { - for (var i = 0; i < nodes.length; i++) { - if (i) { - write(","); - } - writeLine(); - emit(nodes[i]); - } - if (includeTrailingComma) { - emitTrailingCommaIfPresent(nodes, true); - } - } - } - function emitLines(nodes) { - emitLinesStartingAt(nodes, 0); - } - function emitLinesStartingAt(nodes, startIndex) { - for (var i = startIndex; i < nodes.length; i++) { - writeLine(); - emit(nodes[i]); - } - } - function isBinaryOrOctalIntegerLiteral(text) { - if (text.length <= 0) { - return false; - } - if (text.charCodeAt(1) === 66 /* B */ || text.charCodeAt(1) === 98 /* b */ || text.charCodeAt(1) === 79 /* O */ || text.charCodeAt(1) === 111 /* o */) { - return true; - } - return false; - } - function emitLiteral(node) { - var text = getLiteralText(); - if (compilerOptions.sourceMap && (node.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { - writer.writeLiteral(text); - } - else if (compilerOptions.target < 2 /* ES6 */ && node.kind === 6 /* NumericLiteral */ && isBinaryOrOctalIntegerLiteral(text)) { - write(node.text); - } - else { - write(text); - } - function getLiteralText() { - if (compilerOptions.target < 2 /* ES6 */ && ts.isTemplateLiteralKind(node.kind)) { - return getTemplateLiteralAsStringLiteral(node); - } - return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - } - } - function getTemplateLiteralAsStringLiteral(node) { - return '"' + ts.escapeString(node.text) + '"'; - } - function emitTemplateExpression(node) { - if (compilerOptions.target >= 2 /* ES6 */) { - ts.forEachChild(node, emit); - return; - } - ts.Debug.assert(node.parent.kind !== 147 /* TaggedTemplateExpression */); - var emitOuterParens = ts.isExpression(node.parent) && templateNeedsParens(node, node.parent); - if (emitOuterParens) { - write("("); - } - emitLiteral(node.head); - ts.forEach(node.templateSpans, function (templateSpan) { - var needsParens = templateSpan.expression.kind !== 149 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; - write(" + "); - if (needsParens) { - write("("); - } - emit(templateSpan.expression); - if (needsParens) { - write(")"); - } - if (templateSpan.literal.text.length !== 0) { - write(" + "); - emitLiteral(templateSpan.literal); - } - }); - if (emitOuterParens) { - write(")"); - } - function templateNeedsParens(template, parent) { - switch (parent.kind) { - case 145 /* CallExpression */: - case 146 /* NewExpression */: - return parent.expression === template; - case 149 /* ParenthesizedExpression */: - return false; - case 147 /* TaggedTemplateExpression */: - ts.Debug.fail("Path should be unreachable; tagged templates not supported pre-ES6."); - default: - return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; - } - } - function comparePrecedenceToBinaryPlus(expression) { - ts.Debug.assert(compilerOptions.target <= 1 /* ES5 */); - switch (expression.kind) { - case 157 /* BinaryExpression */: - switch (expression.operator) { - case 34 /* AsteriskToken */: - case 35 /* SlashToken */: - case 36 /* PercentToken */: - return 1 /* GreaterThan */; - case 32 /* PlusToken */: - return 0 /* EqualTo */; - default: - return -1 /* LessThan */; - } - case 158 /* ConditionalExpression */: - return -1 /* LessThan */; - default: - return 1 /* GreaterThan */; - } - } - } - function emitTemplateSpan(span) { - emit(span.expression); - emit(span.literal); - } - function emitExpressionForPropertyName(node) { - if (node.kind === 7 /* StringLiteral */) { - emitLiteral(node); - } - else if (node.kind === 121 /* ComputedPropertyName */) { - emit(node.expression); - } - else { - write("\""); - if (node.kind === 6 /* NumericLiteral */) { - write(node.text); - } - else { - writeTextOfNode(currentSourceFile, node); - } - write("\""); - } - } - function isNotExpressionIdentifier(node) { - var parent = node.parent; - switch (parent.kind) { - case 123 /* Parameter */: - case 183 /* VariableDeclaration */: - case 124 /* Property */: - case 198 /* PropertyAssignment */: - case 199 /* ShorthandPropertyAssignment */: - case 200 /* EnumMember */: - case 125 /* Method */: - case 184 /* FunctionDeclaration */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 150 /* FunctionExpression */: - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - case 188 /* EnumDeclaration */: - case 189 /* ModuleDeclaration */: - case 191 /* ImportDeclaration */: - return parent.name === node; - case 173 /* BreakStatement */: - case 172 /* ContinueStatement */: - case 192 /* ExportAssignment */: - return false; - case 177 /* LabeledStatement */: - return node.parent.label === node; - case 197 /* CatchClause */: - return node.parent.name === node; - } - } - function emitExpressionIdentifier(node) { - var prefix = resolver.getExpressionNamePrefix(node); - if (prefix) { - write(prefix); - write("."); - } - writeTextOfNode(currentSourceFile, node); - } - function emitIdentifier(node) { - if (!isNotExpressionIdentifier(node)) { - emitExpressionIdentifier(node); - } - else { - writeTextOfNode(currentSourceFile, node); - } - } - function emitThis(node) { - if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { - write("_this"); - } - else { - write("this"); - } - } - function emitSuper(node) { - var flags = resolver.getNodeCheckFlags(node); - if (flags & 16 /* SuperInstance */) { - write("_super.prototype"); - } - else if (flags & 32 /* SuperStatic */) { - write("_super"); - } - else { - write("super"); - } - } - function emitArrayLiteral(node) { - if (node.flags & 256 /* MultiLine */) { - write("["); - increaseIndent(); - emitMultiLineList(node.elements, true); - decreaseIndent(); - writeLine(); - write("]"); - } - else { - write("["); - emitCommaList(node.elements, true); - write("]"); - } - } - function emitObjectLiteral(node) { - if (!node.properties.length) { - write("{}"); - } - else if (node.flags & 256 /* MultiLine */) { - write("{"); - increaseIndent(); - emitMultiLineList(node.properties, compilerOptions.target >= 1 /* ES5 */); - decreaseIndent(); - writeLine(); - write("}"); - } - else { - write("{ "); - emitCommaList(node.properties, compilerOptions.target >= 1 /* ES5 */); - write(" }"); - } - } - function emitComputedPropertyName(node) { - write("["); - emit(node.expression); - write("]"); - } - function emitDownlevelMethod(node) { - if (!ts.isObjectLiteralMethod(node)) { - return; - } - emitLeadingComments(node); - emit(node.name); - write(": "); - write("function "); - emitSignatureAndBody(node); - emitTrailingComments(node); - } - function emitMethod(node) { - if (!ts.isObjectLiteralMethod(node)) { - return; - } - emitLeadingComments(node); - emit(node.name); - emitSignatureAndBody(node); - emitTrailingComments(node); - } - function emitPropertyAssignment(node) { - emitLeadingComments(node); - emit(node.name); - write(": "); - emit(node.initializer); - emitTrailingComments(node); - } - function emitDownlevelShorthandPropertyAssignment(node) { - emitLeadingComments(node); - emit(node.name); - write(": "); - emitExpressionIdentifier(node.name); - emitTrailingComments(node); - } - function emitShorthandPropertyAssignment(node) { - var prefix = resolver.getExpressionNamePrefix(node.name); - if (prefix) { - emitDownlevelShorthandPropertyAssignment(node); - } - else { - emitLeadingComments(node); - emit(node.name); - emitTrailingComments(node); - } - } - function tryEmitConstantValue(node) { - var constantValue = resolver.getConstantValue(node); - if (constantValue !== undefined) { - var propertyName = node.kind === 143 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - write(constantValue.toString() + " /* " + propertyName + " */"); - return true; - } - return false; - } - function emitPropertyAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("."); - emit(node.name); - } - function emitQualifiedName(node) { - emit(node.left); - write("."); - emit(node.right); - } - function emitIndexedAccess(node) { - if (tryEmitConstantValue(node)) { - return; - } - emit(node.expression); - write("["); - emit(node.argumentExpression); - write("]"); - } - function emitCallExpression(node) { - var superCall = false; - if (node.expression.kind === 89 /* SuperKeyword */) { - write("_super"); - superCall = true; - } - else { - emit(node.expression); - superCall = node.expression.kind === 143 /* PropertyAccessExpression */ && node.expression.expression.kind === 89 /* SuperKeyword */; - } - if (superCall) { - write(".call("); - emitThis(node.expression); - if (node.arguments.length) { - write(", "); - emitCommaList(node.arguments, false); - } - write(")"); - } - else { - write("("); - emitCommaList(node.arguments, false); - write(")"); - } - } - function emitNewExpression(node) { - write("new "); - emit(node.expression); - if (node.arguments) { - write("("); - emitCommaList(node.arguments, false); - write(")"); - } - } - function emitTaggedTemplateExpression(node) { - ts.Debug.assert(compilerOptions.target >= 2 /* ES6 */, "Trying to emit a tagged template in pre-ES6 mode."); - emit(node.tag); - write(" "); - emit(node.template); - } - function emitParenExpression(node) { - if (node.expression.kind === 148 /* TypeAssertionExpression */) { - var operand = node.expression.expression; - while (operand.kind == 148 /* TypeAssertionExpression */) { - operand = operand.expression; - } - if (operand.kind !== 155 /* PrefixUnaryExpression */ && operand.kind !== 154 /* VoidExpression */ && operand.kind !== 153 /* TypeOfExpression */ && operand.kind !== 152 /* DeleteExpression */ && operand.kind !== 156 /* PostfixUnaryExpression */ && operand.kind !== 146 /* NewExpression */ && !(operand.kind === 145 /* CallExpression */ && node.parent.kind === 146 /* NewExpression */) && !(operand.kind === 150 /* FunctionExpression */ && node.parent.kind === 145 /* CallExpression */)) { - emit(operand); - return; - } - } - write("("); - emit(node.expression); - write(")"); - } - function emitDeleteExpression(node) { - write(ts.tokenToString(72 /* DeleteKeyword */)); - write(" "); - emit(node.expression); - } - function emitVoidExpression(node) { - write(ts.tokenToString(97 /* VoidKeyword */)); - write(" "); - emit(node.expression); - } - function emitTypeOfExpression(node) { - write(ts.tokenToString(95 /* TypeOfKeyword */)); - write(" "); - emit(node.expression); - } - function emitPrefixUnaryExpression(node) { - write(ts.tokenToString(node.operator)); - if (node.operand.kind === 155 /* PrefixUnaryExpression */) { - var operand = node.operand; - if (node.operator === 32 /* PlusToken */ && (operand.operator === 32 /* PlusToken */ || operand.operator === 37 /* PlusPlusToken */)) { - write(" "); - } - else if (node.operator === 33 /* MinusToken */ && (operand.operator === 33 /* MinusToken */ || operand.operator === 38 /* MinusMinusToken */)) { - write(" "); - } - } - emit(node.operand); - } - function emitPostfixUnaryExpression(node) { - emit(node.operand); - write(ts.tokenToString(node.operator)); - } - function emitBinaryExpression(node) { - emit(node.left); - if (node.operator !== 22 /* CommaToken */) - write(" "); - write(ts.tokenToString(node.operator)); - write(" "); - emit(node.right); - } - function emitConditionalExpression(node) { - emit(node.condition); - write(" ? "); - emit(node.whenTrue); - write(" : "); - emit(node.whenFalse); - } - function emitBlock(node) { - emitToken(13 /* OpenBraceToken */, node.pos); - increaseIndent(); - scopeEmitStart(node.parent); - if (node.kind === 190 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 189 /* ModuleDeclaration */); - emitCaptureThisForNodeIfNecessary(node.parent); - } - emitLines(node.statements); - decreaseIndent(); - writeLine(); - emitToken(14 /* CloseBraceToken */, node.statements.end); - scopeEmitEnd(); - } - function emitEmbeddedStatement(node) { - if (node.kind === 163 /* Block */) { - write(" "); - emit(node); - } - else { - increaseIndent(); - writeLine(); - emit(node); - decreaseIndent(); - } - } - function emitExpressionStatement(node) { - var isArrowExpression = node.expression.kind === 151 /* ArrowFunction */; - emitLeadingComments(node); - if (isArrowExpression) - write("("); - emit(node.expression); - if (isArrowExpression) - write(")"); - write(";"); - emitTrailingComments(node); - } - function emitIfStatement(node) { - emitLeadingComments(node); - var endPos = emitToken(82 /* IfKeyword */, node.pos); - write(" "); - endPos = emitToken(15 /* OpenParenToken */, endPos); - emit(node.expression); - emitToken(16 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.thenStatement); - if (node.elseStatement) { - writeLine(); - emitToken(74 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 167 /* IfStatement */) { - write(" "); - emit(node.elseStatement); - } - else { - emitEmbeddedStatement(node.elseStatement); - } - } - emitTrailingComments(node); - } - function emitDoStatement(node) { - write("do"); - emitEmbeddedStatement(node.statement); - if (node.statement.kind === 163 /* Block */) { - write(" "); - } - else { - writeLine(); - } - write("while ("); - emit(node.expression); - write(");"); - } - function emitWhileStatement(node) { - write("while ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForStatement(node) { - var endPos = emitToken(80 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(15 /* OpenParenToken */, endPos); - if (node.declarations) { - if (node.declarations[0] && ts.isLet(node.declarations[0])) { - emitToken(102 /* LetKeyword */, endPos); - } - else if (node.declarations[0] && ts.isConst(node.declarations[0])) { - emitToken(68 /* ConstKeyword */, endPos); - } - else { - emitToken(96 /* VarKeyword */, endPos); - } - write(" "); - emitCommaList(node.declarations, false); - } - if (node.initializer) { - emit(node.initializer); - } - write(";"); - emitOptional(" ", node.condition); - write(";"); - emitOptional(" ", node.iterator); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitForInStatement(node) { - var endPos = emitToken(80 /* ForKeyword */, node.pos); - write(" "); - endPos = emitToken(15 /* OpenParenToken */, endPos); - if (node.declarations) { - if (node.declarations.length >= 1) { - var decl = node.declarations[0]; - if (ts.isLet(decl)) { - emitToken(102 /* LetKeyword */, endPos); - } - else { - emitToken(96 /* VarKeyword */, endPos); - } - write(" "); - emit(decl); - } - } - else { - emit(node.variable); - } - write(" in "); - emit(node.expression); - emitToken(16 /* CloseParenToken */, node.expression.end); - emitEmbeddedStatement(node.statement); - } - function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 173 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos); - emitOptional(" ", node.label); - write(";"); - } - function emitReturnStatement(node) { - emitLeadingComments(node); - emitToken(88 /* ReturnKeyword */, node.pos); - emitOptional(" ", node.expression); - write(";"); - emitTrailingComments(node); - } - function emitWithStatement(node) { - write("with ("); - emit(node.expression); - write(")"); - emitEmbeddedStatement(node.statement); - } - function emitSwitchStatement(node) { - var endPos = emitToken(90 /* SwitchKeyword */, node.pos); - write(" "); - emitToken(15 /* OpenParenToken */, endPos); - emit(node.expression); - endPos = emitToken(16 /* CloseParenToken */, node.expression.end); - write(" "); - emitToken(13 /* OpenBraceToken */, endPos); - increaseIndent(); - emitLines(node.clauses); - decreaseIndent(); - writeLine(); - emitToken(14 /* CloseBraceToken */, node.clauses.end); - } - function isOnSameLine(node1, node2) { - return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); - } - function emitCaseOrDefaultClause(node) { - if (node.kind === 194 /* CaseClause */) { - write("case "); - emit(node.expression); - write(":"); - } - else { - write("default:"); - } - if (node.statements.length === 1 && isOnSameLine(node, node.statements[0])) { - write(" "); - emit(node.statements[0]); - } - else { - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); - } - } - function emitThrowStatement(node) { - write("throw "); - emit(node.expression); - write(";"); - } - function emitTryStatement(node) { - write("try "); - emit(node.tryBlock); - emit(node.catchClause); - if (node.finallyBlock) { - writeLine(); - write("finally "); - emit(node.finallyBlock); - } - } - function emitCatchClause(node) { - writeLine(); - var endPos = emitToken(66 /* CatchKeyword */, node.pos); - write(" "); - emitToken(15 /* OpenParenToken */, endPos); - emit(node.name); - emitToken(16 /* CloseParenToken */, node.name.end); - write(" "); - emitBlock(node.block); - } - function emitDebuggerStatement(node) { - emitToken(70 /* DebuggerKeyword */, node.pos); - write(";"); - } - function emitLabelledStatement(node) { - emit(node.label); - write(": "); - emit(node.statement); - } - function getContainingModule(node) { - do { - node = node.parent; - } while (node && node.kind !== 189 /* ModuleDeclaration */); - return node; - } - function emitModuleMemberName(node) { - emitStart(node.name); - if (node.flags & 1 /* Export */) { - var container = getContainingModule(node); - write(container ? resolver.getLocalNameOfContainer(container) : "exports"); - write("."); - } - emitNode(node.name); - emitEnd(node.name); - } - function emitVariableDeclaration(node) { - emitLeadingComments(node); - emitModuleMemberName(node); - emitOptional(" = ", node.initializer); - emitTrailingComments(node); - } - function emitVariableStatement(node) { - emitLeadingComments(node); - if (!(node.flags & 1 /* Export */)) { - if (ts.isLet(node)) { - write("let "); - } - else if (ts.isConst(node)) { - write("const "); - } - else { - write("var "); - } - } - emitCommaList(node.declarations, false); - write(";"); - emitTrailingComments(node); - } - function emitParameter(node) { - emitLeadingComments(node); - emit(node.name); - emitTrailingComments(node); - } - function emitDefaultValueAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.initializer) { - writeLine(); - emitStart(param); - write("if ("); - emitNode(param.name); - write(" === void 0)"); - emitEnd(param); - write(" { "); - emitStart(param); - emitNode(param.name); - write(" = "); - emitNode(param.initializer); - emitEnd(param); - write("; }"); - } - }); - } - function emitRestParameter(node) { - if (ts.hasRestParameters(node)) { - var restIndex = node.parameters.length - 1; - var restParam = node.parameters[restIndex]; - writeLine(); - emitLeadingComments(restParam); - emitStart(restParam); - write("var "); - emitNode(restParam.name); - write(" = [];"); - emitEnd(restParam); - emitTrailingComments(restParam); - writeLine(); - write("for ("); - emitStart(restParam); - write("var _i = " + restIndex + ";"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write("_i < arguments.length;"); - emitEnd(restParam); - write(" "); - emitStart(restParam); - write("_i++"); - emitEnd(restParam); - write(") {"); - increaseIndent(); - writeLine(); - emitStart(restParam); - emitNode(restParam.name); - write("[_i - " + restIndex + "] = arguments[_i];"); - emitEnd(restParam); - decreaseIndent(); - writeLine(); - write("}"); - } - } - function emitAccessor(node) { - emitLeadingComments(node); - write(node.kind === 127 /* GetAccessor */ ? "get " : "set "); - emit(node.name); - emitSignatureAndBody(node); - emitTrailingComments(node); - } - function emitFunctionDeclaration(node) { - if (!node.body) { - return emitPinnedOrTripleSlashComments(node); - } - if (node.kind !== 125 /* Method */) { - emitLeadingComments(node); - } - write("function "); - if (node.kind === 184 /* FunctionDeclaration */ || (node.kind === 150 /* FunctionExpression */ && node.name)) { - emit(node.name); - } - emitSignatureAndBody(node); - if (node.kind !== 125 /* Method */) { - emitTrailingComments(node); - } - } - function emitCaptureThisForNodeIfNecessary(node) { - if (resolver.getNodeCheckFlags(node) & 4 /* CaptureThis */) { - writeLine(); - emitStart(node); - write("var _this = this;"); - emitEnd(node); - } - } - function emitSignatureParameters(node) { - increaseIndent(); - write("("); - if (node) { - emitCommaList(node.parameters, false, node.parameters.length - (ts.hasRestParameters(node) ? 1 : 0)); - } - write(")"); - decreaseIndent(); - } - function emitSignatureAndBody(node) { - emitSignatureParameters(node); - write(" {"); - scopeEmitStart(node); - increaseIndent(); - emitDetachedComments(node.body.kind === 163 /* Block */ ? node.body.statements : node.body); - var startIndex = 0; - if (node.body.kind === 163 /* Block */) { - startIndex = emitDirectivePrologues(node.body.statements, true); - } - var outPos = writer.getTextPos(); - emitCaptureThisForNodeIfNecessary(node); - emitDefaultValueAssignments(node); - emitRestParameter(node); - if (node.body.kind !== 163 /* Block */ && outPos === writer.getTextPos()) { - decreaseIndent(); - write(" "); - emitStart(node.body); - write("return "); - emitNode(node.body); - emitEnd(node.body); - write("; "); - emitStart(node.body); - write("}"); - emitEnd(node.body); - } - else { - if (node.body.kind === 163 /* Block */) { - emitLinesStartingAt(node.body.statements, startIndex); - } - else { - writeLine(); - emitLeadingComments(node.body); - write("return "); - emit(node.body); - write(";"); - emitTrailingComments(node.body); - } - writeLine(); - if (node.body.kind === 163 /* Block */) { - emitLeadingCommentsOfPosition(node.body.statements.end); - decreaseIndent(); - emitToken(14 /* CloseBraceToken */, node.body.statements.end); - } - else { - decreaseIndent(); - emitStart(node.body); - write("}"); - emitEnd(node.body); - } - } - scopeEmitEnd(); - if (node.flags & 1 /* Export */) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emit(node.name); - emitEnd(node); - write(";"); - } - } - function findInitialSuperCall(ctor) { - if (ctor.body) { - var statement = ctor.body.statements[0]; - if (statement && statement.kind === 166 /* ExpressionStatement */) { - var expr = statement.expression; - if (expr && expr.kind === 145 /* CallExpression */) { - var func = expr.expression; - if (func && func.kind === 89 /* SuperKeyword */) { - return statement; - } - } - } - } - } - function emitParameterPropertyAssignments(node) { - ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { - writeLine(); - emitStart(param); - emitStart(param.name); - write("this."); - emitNode(param.name); - emitEnd(param.name); - write(" = "); - emit(param.name); - write(";"); - emitEnd(param); - } - }); - } - function emitMemberAccessForPropertyName(memberName) { - if (memberName.kind === 7 /* StringLiteral */ || memberName.kind === 6 /* NumericLiteral */) { - write("["); - emitNode(memberName); - write("]"); - } - else if (memberName.kind === 121 /* ComputedPropertyName */) { - emitComputedPropertyName(memberName); - } - else { - write("."); - emitNode(memberName); - } - } - function emitMemberAssignments(node, staticFlag) { - ts.forEach(node.members, function (member) { - if (member.kind === 124 /* Property */ && (member.flags & 128 /* Static */) === staticFlag && member.initializer) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - if (staticFlag) { - emitNode(node.name); - } - else { - write("this"); - } - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emit(member.initializer); - write(";"); - emitEnd(member); - emitTrailingComments(member); - } - }); - } - function emitMemberFunctions(node) { - ts.forEach(node.members, function (member) { - if (member.kind === 125 /* Method */) { - if (!member.body) { - return emitPinnedOrTripleSlashComments(member); - } - writeLine(); - emitLeadingComments(member); - emitStart(member); - emitStart(member.name); - emitNode(node.name); - if (!(member.flags & 128 /* Static */)) { - write(".prototype"); - } - emitMemberAccessForPropertyName(member.name); - emitEnd(member.name); - write(" = "); - emitStart(member); - emitFunctionDeclaration(member); - emitEnd(member); - emitEnd(member); - write(";"); - emitTrailingComments(member); - } - else if (member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) { - var accessors = getAllAccessorDeclarations(node, member); - if (member === accessors.firstAccessor) { - writeLine(); - emitStart(member); - write("Object.defineProperty("); - emitStart(member.name); - emitNode(node.name); - if (!(member.flags & 128 /* Static */)) { - write(".prototype"); - } - write(", "); - emitExpressionForPropertyName(member.name); - emitEnd(member.name); - write(", {"); - increaseIndent(); - if (accessors.getAccessor) { - writeLine(); - emitLeadingComments(accessors.getAccessor); - write("get: "); - emitStart(accessors.getAccessor); - write("function "); - emitSignatureAndBody(accessors.getAccessor); - emitEnd(accessors.getAccessor); - emitTrailingComments(accessors.getAccessor); - write(","); - } - if (accessors.setAccessor) { - writeLine(); - emitLeadingComments(accessors.setAccessor); - write("set: "); - emitStart(accessors.setAccessor); - write("function "); - emitSignatureAndBody(accessors.setAccessor); - emitEnd(accessors.setAccessor); - emitTrailingComments(accessors.setAccessor); - write(","); - } - writeLine(); - write("enumerable: true,"); - writeLine(); - write("configurable: true"); - decreaseIndent(); - writeLine(); - write("});"); - emitEnd(member); - } - } - }); - } - function emitClassDeclaration(node) { - emitLeadingComments(node); - write("var "); - emit(node.name); - write(" = (function ("); - var baseTypeNode = ts.getClassBaseTypeNode(node); - if (baseTypeNode) { - write("_super"); - } - write(") {"); - increaseIndent(); - scopeEmitStart(node); - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("__extends("); - emit(node.name); - write(", _super);"); - emitEnd(baseTypeNode); - } - writeLine(); - emitConstructorOfClass(); - emitMemberFunctions(node); - emitMemberAssignments(node, 128 /* Static */); - writeLine(); - function emitClassReturnStatement() { - write("return "); - emitNode(node.name); - } - emitToken(14 /* CloseBraceToken */, node.members.end, emitClassReturnStatement); - write(";"); - decreaseIndent(); - writeLine(); - emitToken(14 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - emitStart(node); - write(")("); - if (baseTypeNode) { - emit(baseTypeNode.typeName); - } - write(");"); - emitEnd(node); - if (node.flags & 1 /* Export */) { - writeLine(); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emit(node.name); - emitEnd(node); - write(";"); - } - emitTrailingComments(node); - function emitConstructorOfClass() { - ts.forEach(node.members, function (member) { - if (member.kind === 126 /* Constructor */ && !member.body) { - emitPinnedOrTripleSlashComments(member); - } - }); - var ctor = getFirstConstructorWithBody(node); - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - write("function "); - emit(node.name); - emitSignatureParameters(ctor); - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - emitDetachedComments(ctor.body.statements); - } - emitCaptureThisForNodeIfNecessary(node); - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeNode) { - var superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("_super.apply(this, arguments);"); - emitEnd(baseTypeNode); - } - } - emitMemberAssignments(node, 0); - if (ctor) { - var statements = ctor.body.statements; - if (superCall) - statements = statements.slice(1); - emitLines(statements); - } - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition(ctor.body.statements.end); - } - decreaseIndent(); - emitToken(14 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - } - } - function emitInterfaceDeclaration(node) { - emitPinnedOrTripleSlashComments(node); - } - function emitEnumDeclaration(node) { - var isConstEnum = ts.isConst(node); - if (isConstEnum && !compilerOptions.preserveConstEnums) { - return; - } - emitLeadingComments(node); - if (!(node.flags & 1 /* Export */)) { - emitStart(node); - write("var "); - emit(node.name); - emitEnd(node); - write(";"); - } - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(resolver.getLocalNameOfContainer(node)); - emitEnd(node.name); - write(") {"); - increaseIndent(); - scopeEmitStart(node); - emitEnumMemberDeclarations(isConstEnum); - decreaseIndent(); - writeLine(); - emitToken(14 /* CloseBraceToken */, node.members.end); - scopeEmitEnd(); - write(")("); - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - if (node.flags & 1 /* Export */) { - writeLine(); - emitStart(node); - write("var "); - emit(node.name); - write(" = "); - emitModuleMemberName(node); - emitEnd(node); - write(";"); - } - emitTrailingComments(node); - function emitEnumMemberDeclarations(isConstEnum) { - ts.forEach(node.members, function (member) { - writeLine(); - emitLeadingComments(member); - emitStart(member); - write(resolver.getLocalNameOfContainer(node)); - write("["); - write(resolver.getLocalNameOfContainer(node)); - write("["); - emitExpressionForPropertyName(member.name); - write("] = "); - if (member.initializer && !isConstEnum) { - emit(member.initializer); - } - else { - write(resolver.getEnumMemberValue(member).toString()); - } - write("] = "); - emitExpressionForPropertyName(member.name); - emitEnd(member); - write(";"); - emitTrailingComments(member); - }); - } - } - function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 189 /* ModuleDeclaration */) { - var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); - return recursiveInnerModule || moduleDeclaration.body; - } - } - function emitModuleDeclaration(node) { - var shouldEmit = ts.getModuleInstanceState(node) === 1 /* Instantiated */ || (ts.getModuleInstanceState(node) === 2 /* ConstEnumOnly */ && compilerOptions.preserveConstEnums); - if (!shouldEmit) { - return emitPinnedOrTripleSlashComments(node); - } - emitLeadingComments(node); - emitStart(node); - write("var "); - emit(node.name); - write(";"); - emitEnd(node); - writeLine(); - emitStart(node); - write("(function ("); - emitStart(node.name); - write(resolver.getLocalNameOfContainer(node)); - emitEnd(node.name); - write(") "); - if (node.body.kind === 190 /* ModuleBlock */) { - emit(node.body); - } - else { - write("{"); - increaseIndent(); - scopeEmitStart(node); - emitCaptureThisForNodeIfNecessary(node); - writeLine(); - emit(node.body); - decreaseIndent(); - writeLine(); - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(14 /* CloseBraceToken */, moduleBlock.statements.end); - scopeEmitEnd(); - } - write(")("); - if (node.flags & 1 /* Export */) { - emit(node.name); - write(" = "); - } - emitModuleMemberName(node); - write(" || ("); - emitModuleMemberName(node); - write(" = {}));"); - emitEnd(node); - emitTrailingComments(node); - } - function emitImportDeclaration(node) { - var emitImportDeclaration = resolver.isReferencedImportDeclaration(node); - if (!emitImportDeclaration) { - emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node); - } - if (emitImportDeclaration) { - if (ts.isExternalModuleImportDeclaration(node) && node.parent.kind === 201 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { - if (node.flags & 1 /* Export */) { - writeLine(); - emitLeadingComments(node); - emitStart(node); - emitModuleMemberName(node); - write(" = "); - emit(node.name); - write(";"); - emitEnd(node); - emitTrailingComments(node); - } - } - else { - writeLine(); - emitLeadingComments(node); - emitStart(node); - if (!(node.flags & 1 /* Export */)) - write("var "); - emitModuleMemberName(node); - write(" = "); - if (ts.isInternalModuleImportDeclaration(node)) { - emit(node.moduleReference); - } - else { - var literal = ts.getExternalModuleImportDeclarationExpression(node); - write("require("); - emitStart(literal); - emitLiteral(literal); - emitEnd(literal); - emitToken(16 /* CloseParenToken */, literal.end); - } - write(";"); - emitEnd(node); - emitTrailingComments(node); - } - } - } - function getExternalImportDeclarations(node) { - var result = []; - ts.forEach(node.statements, function (statement) { - if (ts.isExternalModuleImportDeclaration(statement) && resolver.isReferencedImportDeclaration(statement)) { - result.push(statement); - } - }); - return result; - } - function getFirstExportAssignment(sourceFile) { - return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 192 /* ExportAssignment */) { - return node; - } - }); - } - function emitAMDModule(node, startIndex) { - var imports = getExternalImportDeclarations(node); - writeLine(); - write("define("); - if (node.amdModuleName) { - write("\"" + node.amdModuleName + "\", "); - } - write("[\"require\", \"exports\""); - ts.forEach(imports, function (imp) { - write(", "); - emitLiteral(ts.getExternalModuleImportDeclarationExpression(imp)); - }); - ts.forEach(node.amdDependencies, function (amdDependency) { - var text = "\"" + amdDependency + "\""; - write(", "); - write(text); - }); - write("], function (require, exports"); - ts.forEach(imports, function (imp) { - write(", "); - emit(imp.name); - }); - write(") {"); - increaseIndent(); - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - var exportName = resolver.getExportAssignmentName(node); - if (exportName) { - writeLine(); - var exportAssignement = getFirstExportAssignment(node); - emitStart(exportAssignement); - write("return "); - emitStart(exportAssignement.exportName); - write(exportName); - emitEnd(exportAssignement.exportName); - write(";"); - emitEnd(exportAssignement); - } - decreaseIndent(); - writeLine(); - write("});"); - } - function emitCommonJSModule(node, startIndex) { - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - var exportName = resolver.getExportAssignmentName(node); - if (exportName) { - writeLine(); - var exportAssignement = getFirstExportAssignment(node); - emitStart(exportAssignement); - write("module.exports = "); - emitStart(exportAssignement.exportName); - write(exportName); - emitEnd(exportAssignement.exportName); - write(";"); - emitEnd(exportAssignement); - } - } - function emitDirectivePrologues(statements, startWithNewLine) { - for (var i = 0; i < statements.length; ++i) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); - } - emit(statements[i]); - } - else { - return i; - } - } - return statements.length; - } - function emitSourceFile(node) { - currentSourceFile = node; - writeLine(); - emitDetachedComments(node); - var startIndex = emitDirectivePrologues(node.statements, false); - if (!extendsEmitted && resolver.getNodeCheckFlags(node) & 8 /* EmitExtends */) { - writeLine(); - write("var __extends = this.__extends || function (d, b) {"); - increaseIndent(); - writeLine(); - write("for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];"); - writeLine(); - write("function __() { this.constructor = d; }"); - writeLine(); - write("__.prototype = b.prototype;"); - writeLine(); - write("d.prototype = new __();"); - decreaseIndent(); - writeLine(); - write("};"); - extendsEmitted = true; - } - if (ts.isExternalModule(node)) { - if (compilerOptions.module === 2 /* AMD */) { - emitAMDModule(node, startIndex); - } - else { - emitCommonJSModule(node, startIndex); - } - } - else { - emitCaptureThisForNodeIfNecessary(node); - emitLinesStartingAt(node.statements, startIndex); - } - emitLeadingComments(node.endOfFileToken); - } - function emitNode(node) { - if (!node) { - return; - } - if (node.flags & 2 /* Ambient */) { - return emitPinnedOrTripleSlashComments(node); - } - switch (node.kind) { - case 63 /* Identifier */: - return emitIdentifier(node); - case 123 /* Parameter */: - return emitParameter(node); - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - return emitAccessor(node); - case 91 /* ThisKeyword */: - return emitThis(node); - case 89 /* SuperKeyword */: - return emitSuper(node); - case 87 /* NullKeyword */: - return write("null"); - case 93 /* TrueKeyword */: - return write("true"); - case 78 /* FalseKeyword */: - return write("false"); - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - case 8 /* RegularExpressionLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - case 10 /* TemplateHead */: - case 11 /* TemplateMiddle */: - case 12 /* TemplateTail */: - return emitLiteral(node); - case 159 /* TemplateExpression */: - return emitTemplateExpression(node); - case 162 /* TemplateSpan */: - return emitTemplateSpan(node); - case 120 /* QualifiedName */: - return emitQualifiedName(node); - case 141 /* ArrayLiteralExpression */: - return emitArrayLiteral(node); - case 142 /* ObjectLiteralExpression */: - return emitObjectLiteral(node); - case 198 /* PropertyAssignment */: - return emitPropertyAssignment(node); - case 121 /* ComputedPropertyName */: - return emitComputedPropertyName(node); - case 143 /* PropertyAccessExpression */: - return emitPropertyAccess(node); - case 144 /* ElementAccessExpression */: - return emitIndexedAccess(node); - case 145 /* CallExpression */: - return emitCallExpression(node); - case 146 /* NewExpression */: - return emitNewExpression(node); - case 147 /* TaggedTemplateExpression */: - return emitTaggedTemplateExpression(node); - case 148 /* TypeAssertionExpression */: - return emit(node.expression); - case 149 /* ParenthesizedExpression */: - return emitParenExpression(node); - case 184 /* FunctionDeclaration */: - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - return emitFunctionDeclaration(node); - case 152 /* DeleteExpression */: - return emitDeleteExpression(node); - case 153 /* TypeOfExpression */: - return emitTypeOfExpression(node); - case 154 /* VoidExpression */: - return emitVoidExpression(node); - case 155 /* PrefixUnaryExpression */: - return emitPrefixUnaryExpression(node); - case 156 /* PostfixUnaryExpression */: - return emitPostfixUnaryExpression(node); - case 157 /* BinaryExpression */: - return emitBinaryExpression(node); - case 158 /* ConditionalExpression */: - return emitConditionalExpression(node); - case 161 /* OmittedExpression */: - return; - case 163 /* Block */: - case 180 /* TryBlock */: - case 181 /* FinallyBlock */: - case 190 /* ModuleBlock */: - return emitBlock(node); - case 164 /* VariableStatement */: - return emitVariableStatement(node); - case 165 /* EmptyStatement */: - return write(";"); - case 166 /* ExpressionStatement */: - return emitExpressionStatement(node); - case 167 /* IfStatement */: - return emitIfStatement(node); - case 168 /* DoStatement */: - return emitDoStatement(node); - case 169 /* WhileStatement */: - return emitWhileStatement(node); - case 170 /* ForStatement */: - return emitForStatement(node); - case 171 /* ForInStatement */: - return emitForInStatement(node); - case 172 /* ContinueStatement */: - case 173 /* BreakStatement */: - return emitBreakOrContinueStatement(node); - case 174 /* ReturnStatement */: - return emitReturnStatement(node); - case 175 /* WithStatement */: - return emitWithStatement(node); - case 176 /* SwitchStatement */: - return emitSwitchStatement(node); - case 194 /* CaseClause */: - case 195 /* DefaultClause */: - return emitCaseOrDefaultClause(node); - case 177 /* LabeledStatement */: - return emitLabelledStatement(node); - case 178 /* ThrowStatement */: - return emitThrowStatement(node); - case 179 /* TryStatement */: - return emitTryStatement(node); - case 197 /* CatchClause */: - return emitCatchClause(node); - case 182 /* DebuggerStatement */: - return emitDebuggerStatement(node); - case 183 /* VariableDeclaration */: - return emitVariableDeclaration(node); - case 185 /* ClassDeclaration */: - return emitClassDeclaration(node); - case 186 /* InterfaceDeclaration */: - return emitInterfaceDeclaration(node); - case 188 /* EnumDeclaration */: - return emitEnumDeclaration(node); - case 189 /* ModuleDeclaration */: - return emitModuleDeclaration(node); - case 191 /* ImportDeclaration */: - return emitImportDeclaration(node); - case 201 /* SourceFile */: - return emitSourceFile(node); - } - if (compilerOptions.target < 2 /* ES6 */) { - switch (node.kind) { - case 199 /* ShorthandPropertyAssignment */: - return emitDownlevelShorthandPropertyAssignment(node); - case 125 /* Method */: - return emitDownlevelMethod(node); - } - } - else { - ts.Debug.assert(compilerOptions.target >= 2 /* ES6 */, "Invalid ScriptTarget. We should emit as ES6 or above"); - switch (node.kind) { - case 199 /* ShorthandPropertyAssignment */: - return emitShorthandPropertyAssignment(node); - case 125 /* Method */: - return emitMethod(node); - } - } - } - function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; - } - function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); - if (detachedCommentsInfo.length - 1) { - detachedCommentsInfo.pop(); - } - else { - detachedCommentsInfo = undefined; - } - return leadingComments; - } - function getLeadingCommentsToEmit(node) { - if (node.parent.kind === 201 /* SourceFile */ || node.pos !== node.parent.pos) { - var leadingComments; - if (hasDetachedComments(node.pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - leadingComments = ts.getLeadingCommentRangesOfNode(node, currentSourceFile); - } - return leadingComments; - } - } - function emitLeadingDeclarationComments(node) { - var leadingComments = getLeadingCommentsToEmit(node); - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitTrailingDeclarationComments(node) { - if (node.parent.kind === 201 /* SourceFile */ || node.end !== node.parent.end) { - var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); - emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); - } - } - function emitLeadingCommentsOfLocalPosition(pos) { - var leadingComments; - if (hasDetachedComments(pos)) { - leadingComments = getLeadingCommentsWithoutDetachedComments(); - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); - } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); - emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); - } - function emitDetachedCommentsAtPosition(node) { - var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); - var astLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (astLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } - } - } - } - function emitPinnedOrTripleSlashCommentsOfNode(node) { - var pinnedComments = ts.filter(getLeadingCommentsToEmit(node), isPinnedOrTripleSlashComment); - function isPinnedOrTripleSlashComment(comment) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { - return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } - else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && comment.pos + 2 < comment.end && currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ && currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) { - return true; - } - } - emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments); - emitComments(currentSourceFile, writer, pinnedComments, true, newLine, writeComment); - } - if (compilerOptions.sourceMap) { - initializeEmitterWithSourceMaps(); - } - if (root) { - emit(root); - } - else { - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - emit(sourceFile); - } - }); - } - writeLine(); - writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); - } - function writeDeclarationFile(jsFilePath, sourceFile) { - var emitDeclarationResult = emitDeclarations(program, resolver, diagnostics, jsFilePath, sourceFile); - if (!emitDeclarationResult.reportedDeclarationError) { - var declarationOutput = emitDeclarationResult.referencePathsOutput; - var appliedSyncOutputPos = 0; - ts.forEach(emitDeclarationResult.aliasDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += aliasEmitInfo.asynchronousOutput; - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos); - writeFile(compilerHost, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); - } - } - var hasSemanticErrors = false; - var isEmitBlocked = false; - if (targetSourceFile === undefined) { - hasSemanticErrors = resolver.hasSemanticErrors(); - isEmitBlocked = resolver.isEmitBlocked(); - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js"); - emitFile(jsFilePath, sourceFile); - } - }); - if (compilerOptions.out) { - emitFile(compilerOptions.out); - } - } - else { - if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - hasSemanticErrors = resolver.hasSemanticErrors(targetSourceFile); - isEmitBlocked = resolver.isEmitBlocked(targetSourceFile); - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); - emitFile(jsFilePath, targetSourceFile); - } - else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (!shouldEmitToOwnFile(sourceFile, compilerOptions)) { - hasSemanticErrors = hasSemanticErrors || resolver.hasSemanticErrors(sourceFile); - isEmitBlocked = isEmitBlocked || resolver.isEmitBlocked(sourceFile); - } - }); - emitFile(compilerOptions.out); - } - } - function emitFile(jsFilePath, sourceFile) { - if (!isEmitBlocked) { - emitJavaScript(jsFilePath, sourceFile); - if (!hasSemanticErrors && compilerOptions.declaration) { - writeDeclarationFile(jsFilePath, sourceFile); - } - } - } - diagnostics.sort(ts.compareDiagnostics); - diagnostics = ts.deduplicateSortedDiagnostics(diagnostics); - var hasEmitterError = ts.forEach(diagnostics, function (diagnostic) { return diagnostic.category === 1 /* Error */; }); - var emitResultStatus; - if (isEmitBlocked) { - emitResultStatus = 1 /* AllOutputGenerationSkipped */; - } - else if (hasEmitterError) { - emitResultStatus = 4 /* EmitErrorsEncountered */; - } - else if (hasSemanticErrors && compilerOptions.declaration) { - emitResultStatus = 3 /* DeclarationGenerationSkipped */; - } - else if (hasSemanticErrors && !compilerOptions.declaration) { - emitResultStatus = 2 /* JSGeneratedWithSemanticErrors */; - } - else { - emitResultStatus = 0 /* Succeeded */; - } - return { - emitResultStatus: emitResultStatus, - diagnostics: diagnostics, - sourceMaps: sourceMapDataList - }; - } - ts.emitFiles = emitFiles; -})(ts || (ts = {})); -var ts; -(function (ts) { - var nextSymbolId = 1; - var nextNodeId = 1; - var nextMergeId = 1; - function createTypeChecker(program, fullTypeCheck) { - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var Type = ts.objectAllocator.getTypeConstructor(); - var Signature = ts.objectAllocator.getSignatureConstructor(); - var typeCount = 0; - var emptyArray = []; - var emptySymbols = {}; - var compilerOptions = program.getCompilerOptions(); - var checker = { - getProgram: function () { return program; }, - getNodeCount: function () { return ts.sum(program.getSourceFiles(), "nodeCount"); }, - getIdentifierCount: function () { return ts.sum(program.getSourceFiles(), "identifierCount"); }, - getSymbolCount: function () { return ts.sum(program.getSourceFiles(), "symbolCount"); }, - getTypeCount: function () { return typeCount; }, - isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, - isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, - emitFiles: invokeEmitter, - getDiagnostics: getDiagnostics, - getDeclarationDiagnostics: getDeclarationDiagnostics, - getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, - getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, - getPropertiesOfType: getPropertiesOfType, - getPropertyOfType: getPropertyOfType, - getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: getIndexTypeOfType, - getReturnTypeOfSignature: getReturnTypeOfSignature, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getTypeAtLocation: getTypeAtLocation, - typeToString: typeToString, - getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, - getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, - getRootSymbols: getRootSymbols, - getContextualType: getContextualType, - getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getEnumMemberValue: getEnumMemberValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, - getAliasedSymbol: resolveImport, - hasEarlyErrors: hasEarlyErrors, - isEmitBlocked: isEmitBlocked - }; - var undefinedSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "undefined"); - var argumentsSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "arguments"); - var unknownSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(268435456 /* Transient */, "__resolving__"); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var stringType = createIntrinsicType(2 /* String */, "string"); - var numberType = createIntrinsicType(4 /* Number */, "number"); - var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */, "null"); - var unknownType = createIntrinsicType(1 /* Any */, "unknown"); - var resolvingType = createIntrinsicType(1 /* Any */, "__resolving__"); - var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var inferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - var anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false); - var globals = {}; - var globalArraySymbol; - var globalObjectType; - var globalFunctionType; - var globalArrayType; - var globalStringType; - var globalNumberType; - var globalBooleanType; - var globalRegExpType; - var globalTemplateStringsArrayType; - var tupleTypes = {}; - var unionTypes = {}; - var stringLiteralTypes = {}; - var emitExtends = false; - var mergedSymbols = []; - var symbolLinks = []; - var nodeLinks = []; - var potentialThisCollisions = []; - var diagnostics = []; - var diagnosticsModified = false; - function addDiagnostic(diagnostic) { - diagnostics.push(diagnostic); - diagnosticsModified = true; - } - function error(location, message, arg0, arg1, arg2) { - var diagnostic = location ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2) : ts.createCompilerDiagnostic(message, arg0, arg1, arg2); - addDiagnostic(diagnostic); - } - function createSymbol(flags, name) { - return new Symbol(flags, name); - } - function getExcludedSymbolFlags(flags) { - var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 107455 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 107454 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 107455 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 107455 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 106927 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 3258879 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 3152288 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 3258623 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 3259263 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 106639 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 99263 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 41919 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 74687 /* SetAccessorExcludes */; - if (flags & 1048576 /* TypeParameter */) - result |= 2103776 /* TypeParameterExcludes */; - if (flags & 2097152 /* TypeAlias */) - result |= 3152352 /* TypeAliasExcludes */; - if (flags & 33554432 /* Import */) - result |= 33554432 /* ImportExcludes */; - return result; - } - function recordMergedSymbol(target, source) { - if (!source.mergeId) - source.mergeId = nextMergeId++; - mergedSymbols[source.mergeId] = target; - } - function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 134217728 /* Merged */, symbol.name); - result.declarations = symbol.declarations.slice(0); - result.parent = symbol.parent; - if (symbol.valueDeclaration) - result.valueDeclaration = symbol.valueDeclaration; - if (symbol.constEnumOnlyModule) - result.constEnumOnlyModule = true; - if (symbol.members) - result.members = cloneSymbolTable(symbol.members); - if (symbol.exports) - result.exports = cloneSymbolTable(symbol.exports); - recordMergedSymbol(result, symbol); - return result; - } - function extendSymbol(target, source) { - if (!(target.flags & getExcludedSymbolFlags(source.flags))) { - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { - target.constEnumOnlyModule = false; - } - target.flags |= source.flags; - if (!target.valueDeclaration && source.valueDeclaration) - target.valueDeclaration = source.valueDeclaration; - ts.forEach(source.declarations, function (node) { - target.declarations.push(node); - }); - if (source.members) { - if (!target.members) - target.members = {}; - extendSymbolTable(target.members, source.members); - } - if (source.exports) { - if (!target.exports) - target.exports = {}; - extendSymbolTable(target.exports, source.exports); - } - recordMergedSymbol(target, source); - } - else { - var message = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; - ts.forEach(source.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - ts.forEach(target.declarations, function (node) { - error(node.name ? node.name : node, message, symbolToString(source)); - }); - } - } - function cloneSymbolTable(symbolTable) { - var result = {}; - for (var id in symbolTable) { - if (ts.hasProperty(symbolTable, id)) { - result[id] = symbolTable[id]; - } - } - return result; - } - function extendSymbolTable(target, source) { - for (var id in source) { - if (ts.hasProperty(source, id)) { - if (!ts.hasProperty(target, id)) { - target[id] = source[id]; - } - else { - var symbol = target[id]; - if (!(symbol.flags & 134217728 /* Merged */)) { - target[id] = symbol = cloneSymbol(symbol); - } - extendSymbol(symbol, source[id]); - } - } - } - } - function getSymbolLinks(symbol) { - if (symbol.flags & 268435456 /* Transient */) - return symbol; - if (!symbol.id) - symbol.id = nextSymbolId++; - return symbolLinks[symbol.id] || (symbolLinks[symbol.id] = {}); - } - function getNodeLinks(node) { - if (!node.id) - node.id = nextNodeId++; - return nodeLinks[node.id] || (nodeLinks[node.id] = {}); - } - function getSourceFile(node) { - return ts.getAncestor(node, 201 /* SourceFile */); - } - function isGlobalSourceFile(node) { - return node.kind === 201 /* SourceFile */ && !ts.isExternalModule(node); - } - function getSymbol(symbols, name, meaning) { - if (meaning && ts.hasProperty(symbols, name)) { - var symbol = symbols[name]; - ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (symbol.flags & meaning) { - return symbol; - } - if (symbol.flags & 33554432 /* Import */) { - var target = resolveImport(symbol); - if (target === unknownSymbol || target.flags & meaning) { - return symbol; - } - } - } - } - function isDefinedBefore(node1, node2) { - var file1 = ts.getSourceFileOfNode(node1); - var file2 = ts.getSourceFileOfNode(node2); - if (file1 === file2) { - return node1.pos <= node2.pos; - } - if (!compilerOptions.out) { - return true; - } - var sourceFiles = program.getSourceFiles(); - return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); - } - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { - var result; - var lastLocation; - var propertyWithInvalidInitializer; - var errorLocation = location; - loop: while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - if (result = getSymbol(location.locals, name, meaning)) { - break loop; - } - } - switch (location.kind) { - case 201 /* SourceFile */: - if (!ts.isExternalModule(location)) - break; - case 189 /* ModuleDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 35653619 /* ModuleMember */)) { - break loop; - } - break; - case 188 /* EnumDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { - break loop; - } - break; - case 124 /* Property */: - if (location.parent.kind === 185 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { - var ctor = findConstructorDeclaration(location.parent); - if (ctor && ctor.locals) { - if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { - propertyWithInvalidInitializer = location; - } - } - } - break; - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 3152352 /* Type */)) { - if (lastLocation && lastLocation.flags & 128 /* Static */) { - error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); - return undefined; - } - break loop; - } - break; - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 184 /* FunctionDeclaration */: - case 151 /* ArrowFunction */: - if (name === "arguments") { - result = argumentsSymbol; - break loop; - } - break; - case 150 /* FunctionExpression */: - if (name === "arguments") { - result = argumentsSymbol; - break loop; - } - var id = location.name; - if (id && name === id.text) { - result = location.symbol; - break loop; - } - break; - case 197 /* CatchClause */: - var id = location.name; - if (name === id.text) { - result = location.symbol; - break loop; - } - break; - } - lastLocation = location; - location = location.parent; - } - if (!result) { - result = getSymbol(globals, name, meaning); - } - if (!result) { - if (nameNotFoundMessage) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - } - return undefined; - } - if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer) { - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); - return undefined; - } - if (result.flags & 2 /* BlockScopedVariable */) { - var declaration = ts.forEach(result.declarations, function (d) { return d.flags & 6144 /* BlockScoped */ ? d : undefined; }); - ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!isDefinedBefore(declaration, errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); - } - } - } - return result; - } - function resolveImport(symbol) { - ts.Debug.assert((symbol.flags & 33554432 /* Import */) !== 0, "Should only get Imports here."); - var links = getSymbolLinks(symbol); - if (!links.target) { - links.target = resolvingSymbol; - var node = ts.getDeclarationOfKind(symbol, 191 /* ImportDeclaration */); - var target = node.moduleReference.kind === 193 /* ExternalModuleReference */ ? resolveExternalModuleName(node, ts.getExternalModuleImportDeclarationExpression(node)) : getSymbolOfPartOfRightHandSideOfImport(node.moduleReference, node); - if (links.target === resolvingSymbol) { - links.target = target || unknownSymbol; - } - else { - error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol)); - } - } - else if (links.target === resolvingSymbol) { - links.target = unknownSymbol; - } - return links.target; - } - function getSymbolOfPartOfRightHandSideOfImport(entityName, importDeclaration) { - if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 191 /* ImportDeclaration */); - ts.Debug.assert(importDeclaration !== undefined); - } - if (entityName.kind === 63 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; - } - if (entityName.kind === 63 /* Identifier */ || entityName.parent.kind === 120 /* QualifiedName */) { - return resolveEntityName(importDeclaration, entityName, 1536 /* Namespace */); - } - else { - ts.Debug.assert(entityName.parent.kind === 191 /* ImportDeclaration */); - return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */); - } - } - function getFullyQualifiedName(symbol) { - return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); - } - function resolveEntityName(location, name, meaning) { - if (ts.getFullWidth(name) === 0) { - return undefined; - } - if (name.kind === 63 /* Identifier */) { - var symbol = resolveName(location, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); - if (!symbol) { - return; - } - } - else if (name.kind === 120 /* QualifiedName */) { - var namespace = resolveEntityName(location, name.left, 1536 /* Namespace */); - if (!namespace || namespace === unknownSymbol || ts.getFullWidth(name.right) === 0) - return; - var symbol = getSymbol(namespace.exports, name.right.text, meaning); - if (!symbol) { - error(location, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(name.right)); - return; - } - } - ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - return symbol.flags & meaning ? symbol : resolveImport(symbol); - } - function isExternalModuleNameRelative(moduleName) { - return moduleName.substr(0, 2) === "./" || moduleName.substr(0, 3) === "../" || moduleName.substr(0, 2) === ".\\" || moduleName.substr(0, 3) === "..\\"; - } - function resolveExternalModuleName(location, moduleReferenceExpression) { - if (moduleReferenceExpression.kind !== 7 /* StringLiteral */) { - return; - } - var moduleReferenceLiteral = moduleReferenceExpression; - var searchPath = ts.getDirectoryPath(getSourceFile(location).filename); - var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text); - if (!moduleName) - return; - var isRelative = isExternalModuleNameRelative(moduleName); - if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); - if (symbol) { - return getResolvedExportSymbol(symbol); - } - } - while (true) { - var filename = ts.normalizePath(ts.combinePaths(searchPath, moduleName)); - var sourceFile = program.getSourceFile(filename + ".ts") || program.getSourceFile(filename + ".d.ts"); - if (sourceFile || isRelative) - break; - var parentPath = ts.getDirectoryPath(searchPath); - if (parentPath === searchPath) - break; - searchPath = parentPath; - } - if (sourceFile) { - if (sourceFile.symbol) { - return getResolvedExportSymbol(sourceFile.symbol); - } - error(moduleReferenceLiteral, ts.Diagnostics.File_0_is_not_an_external_module, sourceFile.filename); - return; - } - error(moduleReferenceLiteral, ts.Diagnostics.Cannot_find_external_module_0, moduleName); - } - function getResolvedExportSymbol(moduleSymbol) { - var symbol = getExportAssignmentSymbol(moduleSymbol); - if (symbol) { - if (symbol.flags & (107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */)) { - return symbol; - } - if (symbol.flags & 33554432 /* Import */) { - return resolveImport(symbol); - } - } - return moduleSymbol; - } - function getExportAssignmentSymbol(symbol) { - checkTypeOfExportAssignmentSymbol(symbol); - var symbolLinks = getSymbolLinks(symbol); - return symbolLinks.exportAssignSymbol === unknownSymbol ? undefined : symbolLinks.exportAssignSymbol; - } - function checkTypeOfExportAssignmentSymbol(containerSymbol) { - var symbolLinks = getSymbolLinks(containerSymbol); - if (!symbolLinks.exportAssignSymbol) { - var exportInformation = collectExportInformationForSourceFileOrModule(containerSymbol); - if (exportInformation.exportAssignments.length) { - if (exportInformation.exportAssignments.length > 1) { - ts.forEach(exportInformation.exportAssignments, function (node) { return error(node, ts.Diagnostics.A_module_cannot_have_more_than_one_export_assignment); }); - } - var node = exportInformation.exportAssignments[0]; - if (exportInformation.hasExportedMember) { - error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); - } - if (node.exportName.text) { - var meaning = 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */; - var exportSymbol = resolveName(node, node.exportName.text, meaning, ts.Diagnostics.Cannot_find_name_0, node.exportName); - } - } - symbolLinks.exportAssignSymbol = exportSymbol || unknownSymbol; - } - } - function collectExportInformationForSourceFileOrModule(symbol) { - var seenExportedMember = false; - var result = []; - ts.forEach(symbol.declarations, function (declaration) { - var block = (declaration.kind === 201 /* SourceFile */ ? declaration : declaration.body); - ts.forEach(block.statements, function (node) { - if (node.kind === 192 /* ExportAssignment */) { - result.push(node); - } - else { - seenExportedMember = seenExportedMember || (node.flags & 1 /* Export */) !== 0; - } - }); - }); - return { - hasExportedMember: seenExportedMember, - exportAssignments: result - }; - } - function getMergedSymbol(symbol) { - var merged; - return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol; - } - function getSymbolOfNode(node) { - return getMergedSymbol(node.symbol); - } - function getParentOfSymbol(symbol) { - return getMergedSymbol(symbol.parent); - } - function getExportSymbolOfValueSymbolIfExported(symbol) { - return symbol && (symbol.flags & 4194304 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) : symbol; - } - function symbolIsValue(symbol) { - if (symbol.flags & 67108864 /* Instantiated */) { - return symbolIsValue(getSymbolLinks(symbol).target); - } - if (symbol.flags & 107455 /* Value */) { - return true; - } - if (symbol.flags & 33554432 /* Import */) { - return (resolveImport(symbol).flags & 107455 /* Value */) !== 0; - } - return false; - } - function findConstructorDeclaration(node) { - var members = node.members; - for (var i = 0; i < members.length; i++) { - var member = members[i]; - if (member.kind === 126 /* Constructor */ && member.body) { - return member; - } - } - } - function createType(flags) { - var result = new Type(checker, flags); - result.id = typeCount++; - return result; - } - function createIntrinsicType(kind, intrinsicName) { - var type = createType(kind); - type.intrinsicName = intrinsicName; - return type; - } - function createObjectType(kind, symbol) { - var type = createType(kind); - type.symbol = symbol; - return type; - } - function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && name.charCodeAt(1) === 95 /* _ */ && name.charCodeAt(2) !== 95 /* _ */; - } - function getNamedMembers(members) { - var result; - for (var id in members) { - if (ts.hasProperty(members, id)) { - if (!isReservedMemberName(id)) { - if (!result) - result = []; - var symbol = members[id]; - if (symbolIsValue(symbol)) { - result.push(symbol); - } - } - } - } - return result || emptyArray; - } - function setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - type.members = members; - type.properties = getNamedMembers(members); - type.callSignatures = callSignatures; - type.constructSignatures = constructSignatures; - if (stringIndexType) - type.stringIndexType = stringIndexType; - if (numberIndexType) - type.numberIndexType = numberIndexType; - return type; - } - function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function isOptionalProperty(propertySymbol) { - return propertySymbol.valueDeclaration && ts.hasQuestionToken(propertySymbol.valueDeclaration) && propertySymbol.valueDeclaration.kind !== 123 /* Parameter */; - } - function forEachSymbolTableInScope(enclosingDeclaration, callback) { - var result; - for (var location = enclosingDeclaration; location; location = location.parent) { - if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals)) { - return result; - } - } - switch (location.kind) { - case 201 /* SourceFile */: - if (!ts.isExternalModule(location)) { - break; - } - case 189 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; - } - break; - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - if (result = callback(getSymbolOfNode(location).members)) { - return result; - } - break; - } - } - return callback(globals); - } - function getQualifiedLeftMeaning(rightMeaning) { - return rightMeaning === 107455 /* Value */ ? 107455 /* Value */ : 1536 /* Namespace */; - } - function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - function canQualifySymbol(symbolFromSymbolTable, meaning) { - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - return !ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return hasExternalModuleSymbol(declaration); }) && canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - if (isAccessible(ts.lookUp(symbols, symbol.name))) { - return [symbol]; - } - return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 33554432 /* Import */) { - if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportDeclaration)) { - var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { - return [symbolFromSymbolTable]; - } - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } - if (symbol) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); - } - } - function needsQualification(symbol, enclosingDeclaration, meaning) { - var qualify = false; - forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - if (!ts.hasProperty(symbolTable, symbol.name)) { - return false; - } - var symbolFromSymbolTable = symbolTable[symbol.name]; - if (symbolFromSymbolTable === symbol) { - return true; - } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 33554432 /* Import */) ? resolveImport(symbolFromSymbolTable) : symbolFromSymbolTable; - if (symbolFromSymbolTable.flags & meaning) { - qualify = true; - return true; - } - return false; - }); - return qualify; - } - function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { - if (symbol && enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { - var initialSymbol = symbol; - var meaningToLook = meaning; - while (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); - if (accessibleSymbolChain) { - var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); - if (!hasAccessibleDeclarations) { - return { - accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536 /* Namespace */) : undefined - }; - } - return hasAccessibleDeclarations; - } - meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); - } - var symbolExternalModule = ts.forEach(initialSymbol.declarations, function (declaration) { return getExternalModuleContainer(declaration); }); - if (symbolExternalModule) { - var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); - if (symbolExternalModule !== enclosingExternalModule) { - return { - accessibility: 2 /* CannotBeNamed */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbolToString(symbolExternalModule) - }; - } - } - return { - accessibility: 1 /* NotAccessible */, - errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning) - }; - } - return { accessibility: 0 /* Accessible */ }; - function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } - } - } - function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 189 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 201 /* SourceFile */ && ts.isExternalModule(declaration)); - } - function hasVisibleDeclarations(symbol) { - var aliasesToMakeVisible; - if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) { - return undefined; - } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; - function getIsDeclarationVisible(declaration) { - if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 191 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { - getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, declaration)) { - aliasesToMakeVisible.push(declaration); - } - } - else { - aliasesToMakeVisible = [declaration]; - } - return true; - } - return false; - } - return true; - } - } - function isEntityNameVisible(entityName, enclosingDeclaration) { - var meaning; - if (entityName.parent.kind === 135 /* TypeQuery */) { - meaning = 107455 /* Value */ | 4194304 /* ExportValue */; - } - else if (entityName.kind === 120 /* QualifiedName */ || entityName.parent.kind === 191 /* ImportDeclaration */) { - meaning = 1536 /* Namespace */; - } - else { - meaning = 3152352 /* Type */; - } - var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined); - return (symbol && hasVisibleDeclarations(symbol)) || { - accessibility: 1 /* NotAccessible */, - errorSymbolName: ts.getTextOfNode(firstIdentifier), - errorNode: firstIdentifier - }; - } - function writeKeyword(writer, kind) { - writer.writeKeyword(ts.tokenToString(kind)); - } - function writePunctuation(writer, kind) { - writer.writePunctuation(ts.tokenToString(kind)); - } - function writeSpace(writer) { - writer.writeSpace(" "); - } - function symbolToString(symbol, enclosingDeclaration, meaning) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning); - var result = writer.string(); - ts.releaseStringWriter(writer); - return result; - } - function typeToString(type, enclosingDeclaration, flags) { - var writer = ts.getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - var result = writer.string(); - ts.releaseStringWriter(writer); - var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; - if (maxLength && result.length >= maxLength) { - result = result.substr(0, maxLength - "...".length) + "..."; - } - return result; - } - function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 140 /* ParenthesizedType */) { - node = node.parent; - } - if (node.kind === 187 /* TypeAliasDeclaration */) { - return getSymbolOfNode(node); - } - } - return undefined; - } - var _displayBuilder; - function getSymbolDisplayBuilder() { - function appendSymbolNameOnly(symbol, writer) { - if (symbol.declarations && symbol.declarations.length > 0) { - var declaration = symbol.declarations[0]; - if (declaration.name) { - writer.writeSymbol(ts.declarationNameToString(declaration.name), symbol); - return; - } - } - writer.writeSymbol(symbol.name, symbol); - } - function buildSymbolDisplay(symbol, writer, enclosingDeclaration, meaning, flags) { - var parentSymbol; - function appendParentTypeArgumentsAndSymbolName(symbol) { - if (parentSymbol) { - if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 67108864 /* Instantiated */) { - buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); - } - else { - buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); - } - } - writePunctuation(writer, 19 /* DotToken */); - } - parentSymbol = symbol; - appendSymbolNameOnly(symbol, writer); - } - writer.trackSymbol(symbol, enclosingDeclaration, meaning); - function walkSymbol(symbol, meaning) { - if (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2 /* UseOnlyExternalAliasing */)); - if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); - } - if (accessibleSymbolChain) { - for (var i = 0, n = accessibleSymbolChain.length; i < n; i++) { - appendParentTypeArgumentsAndSymbolName(accessibleSymbolChain[i]); - } - } - else { - if (!parentSymbol && ts.forEach(symbol.declarations, function (declaration) { return hasExternalModuleSymbol(declaration); })) { - return; - } - if (symbol.flags & 2048 /* TypeLiteral */ || symbol.flags & 4096 /* ObjectLiteral */) { - return; - } - appendParentTypeArgumentsAndSymbolName(symbol); - } - } - } - if (enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { - walkSymbol(symbol, meaning); - return; - } - return appendParentTypeArgumentsAndSymbolName(symbol); - } - function buildTypeDisplay(type, writer, enclosingDeclaration, globalFlags, typeStack) { - var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; - return writeType(type, globalFlags); - function writeType(type, flags) { - if (type.flags & 127 /* Intrinsic */) { - writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && (type.flags & 1 /* Any */) ? "any" : type.intrinsicName); - } - else if (type.flags & 4096 /* Reference */) { - writeTypeReference(type, flags); - } - else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 3152352 /* Type */); - } - else if (type.flags & 8192 /* Tuple */) { - writeTupleType(type); - } - else if (type.flags & 16384 /* Union */) { - writeUnionType(type, flags); - } - else if (type.flags & 32768 /* Anonymous */) { - writeAnonymousType(type, flags); - } - else if (type.flags & 256 /* StringLiteral */) { - writer.writeStringLiteral(type.text); - } - else { - writePunctuation(writer, 13 /* OpenBraceToken */); - writeSpace(writer); - writePunctuation(writer, 20 /* DotDotDotToken */); - writeSpace(writer); - writePunctuation(writer, 14 /* CloseBraceToken */); - } - } - function writeTypeList(types, union) { - for (var i = 0; i < types.length; i++) { - if (i > 0) { - if (union) { - writeSpace(writer); - } - writePunctuation(writer, union ? 43 /* BarToken */ : 22 /* CommaToken */); - writeSpace(writer); - } - writeType(types[i], union ? 64 /* InElementType */ : 0 /* None */); - } - } - function writeTypeReference(type, flags) { - if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { - writeType(type.typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 17 /* OpenBracketToken */); - writePunctuation(writer, 18 /* CloseBracketToken */); - } - else { - buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, 3152352 /* Type */); - writePunctuation(writer, 23 /* LessThanToken */); - writeTypeList(type.typeArguments, false); - writePunctuation(writer, 24 /* GreaterThanToken */); - } - } - function writeTupleType(type) { - writePunctuation(writer, 17 /* OpenBracketToken */); - writeTypeList(type.elementTypes, false); - writePunctuation(writer, 18 /* CloseBracketToken */); - } - function writeUnionType(type, flags) { - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 15 /* OpenParenToken */); - } - writeTypeList(type.types, true); - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* CloseParenToken */); - } - } - function writeAnonymousType(type, flags) { - if (type.symbol && type.symbol.flags & (32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { - writeTypeofSymbol(type); - } - else if (shouldWriteTypeOfFunctionSymbol()) { - writeTypeofSymbol(type); - } - else if (typeStack && ts.contains(typeStack, type)) { - var typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias) { - buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 3152352 /* Type */); - } - else { - writeKeyword(writer, 109 /* AnyKeyword */); - } - } - else { - if (!typeStack) { - typeStack = []; - } - typeStack.push(type); - writeLiteralType(type, flags); - typeStack.pop(); - } - function shouldWriteTypeOfFunctionSymbol() { - if (type.symbol) { - var isStaticMethodSymbol = !!(type.symbol.flags & 8192 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); - var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 201 /* SourceFile */ || declaration.parent.kind === 190 /* ModuleBlock */; })); - if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - return !!(flags & 2 /* UseTypeOfFunction */) || (typeStack && ts.contains(typeStack, type)); - } - } - } - } - function writeTypeofSymbol(type) { - writeKeyword(writer, 95 /* TypeOfKeyword */); - writeSpace(writer); - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */); - } - function getIndexerParameterName(type, indexKind, fallbackName) { - var declaration = getIndexDeclarationOfSymbol(type.symbol, indexKind); - if (!declaration) { - return fallbackName; - } - ts.Debug.assert(declaration.parameters.length !== 0); - return ts.declarationNameToString(declaration.parameters[0].name); - } - function writeLiteralType(type, flags) { - var resolved = resolveObjectOrUnionTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { - if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 13 /* OpenBraceToken */); - writePunctuation(writer, 14 /* CloseBraceToken */); - return; - } - if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 15 /* OpenParenToken */); - } - buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* CloseParenToken */); - } - return; - } - if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 15 /* OpenParenToken */); - } - writeKeyword(writer, 86 /* NewKeyword */); - writeSpace(writer); - buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); - if (flags & 64 /* InElementType */) { - writePunctuation(writer, 16 /* CloseParenToken */); - } - return; - } - } - writePunctuation(writer, 13 /* OpenBraceToken */); - writer.writeLine(); - writer.increaseIndent(); - for (var i = 0; i < resolved.callSignatures.length; i++) { - buildSignatureDisplay(resolved.callSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 21 /* SemicolonToken */); - writer.writeLine(); - } - for (var i = 0; i < resolved.constructSignatures.length; i++) { - writeKeyword(writer, 86 /* NewKeyword */); - writeSpace(writer); - buildSignatureDisplay(resolved.constructSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 21 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.stringIndexType) { - writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 50 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 118 /* StringKeyword */); - writePunctuation(writer, 18 /* CloseBracketToken */); - writePunctuation(writer, 50 /* ColonToken */); - writeSpace(writer); - writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 21 /* SemicolonToken */); - writer.writeLine(); - } - if (resolved.numberIndexType) { - writePunctuation(writer, 17 /* OpenBracketToken */); - writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); - writePunctuation(writer, 50 /* ColonToken */); - writeSpace(writer); - writeKeyword(writer, 116 /* NumberKeyword */); - writePunctuation(writer, 18 /* CloseBracketToken */); - writePunctuation(writer, 50 /* ColonToken */); - writeSpace(writer); - writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 21 /* SemicolonToken */); - writer.writeLine(); - } - for (var i = 0; i < resolved.properties.length; i++) { - var p = resolved.properties[i]; - var t = getTypeOfSymbol(p); - if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { - var signatures = getSignaturesOfType(t, 0 /* Call */); - for (var j = 0; j < signatures.length; j++) { - buildSymbolDisplay(p, writer); - if (isOptionalProperty(p)) { - writePunctuation(writer, 49 /* QuestionToken */); - } - buildSignatureDisplay(signatures[j], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 21 /* SemicolonToken */); - writer.writeLine(); - } - } - else { - buildSymbolDisplay(p, writer); - if (isOptionalProperty(p)) { - writePunctuation(writer, 49 /* QuestionToken */); - } - writePunctuation(writer, 50 /* ColonToken */); - writeSpace(writer); - writeType(t, 0 /* None */); - writePunctuation(writer, 21 /* SemicolonToken */); - writer.writeLine(); - } - } - writer.decreaseIndent(); - writePunctuation(writer, 14 /* CloseBraceToken */); - } - } - function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { - var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & 32 /* Class */ || targetSymbol.flags & 64 /* Interface */) { - buildDisplayForTypeParametersAndDelimiters(getTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); - } - } - function buildTypeParameterDisplay(tp, writer, enclosingDeclaration, flags, typeStack) { - appendSymbolNameOnly(tp.symbol, writer); - var constraint = getConstraintOfTypeParameter(tp); - if (constraint) { - writeSpace(writer); - writeKeyword(writer, 77 /* ExtendsKeyword */); - writeSpace(writer); - buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); - } - } - function buildParameterDisplay(p, writer, enclosingDeclaration, flags, typeStack) { - if (ts.hasDotDotDotToken(p.valueDeclaration)) { - writePunctuation(writer, 20 /* DotDotDotToken */); - } - appendSymbolNameOnly(p, writer); - if (ts.hasQuestionToken(p.valueDeclaration) || p.valueDeclaration.initializer) { - writePunctuation(writer, 49 /* QuestionToken */); - } - writePunctuation(writer, 50 /* ColonToken */); - writeSpace(writer); - buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, typeStack); - } - function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, typeStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 23 /* LessThanToken */); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 22 /* CommaToken */); - writeSpace(writer); - } - buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, typeStack); - } - writePunctuation(writer, 24 /* GreaterThanToken */); - } - } - function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, typeStack) { - if (typeParameters && typeParameters.length) { - writePunctuation(writer, 23 /* LessThanToken */); - for (var i = 0; i < typeParameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 22 /* CommaToken */); - writeSpace(writer); - } - buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); - } - writePunctuation(writer, 24 /* GreaterThanToken */); - } - } - function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, typeStack) { - writePunctuation(writer, 15 /* OpenParenToken */); - for (var i = 0; i < parameters.length; i++) { - if (i > 0) { - writePunctuation(writer, 22 /* CommaToken */); - writeSpace(writer); - } - buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, typeStack); - } - writePunctuation(writer, 16 /* CloseParenToken */); - } - function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, typeStack) { - if (flags & 8 /* WriteArrowStyleSignature */) { - writeSpace(writer); - writePunctuation(writer, 31 /* EqualsGreaterThanToken */); - } - else { - writePunctuation(writer, 50 /* ColonToken */); - } - writeSpace(writer); - buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, typeStack); - } - function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, typeStack) { - if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { - buildDisplayForTypeArgumentsAndDelimiters(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); - } - else { - buildDisplayForTypeParametersAndDelimiters(signature.typeParameters, writer, enclosingDeclaration, flags, typeStack); - } - buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, typeStack); - buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, typeStack); - } - return _displayBuilder || (_displayBuilder = { - symbolToString: symbolToString, - typeToString: typeToString, - buildSymbolDisplay: buildSymbolDisplay, - buildTypeDisplay: buildTypeDisplay, - buildTypeParameterDisplay: buildTypeParameterDisplay, - buildParameterDisplay: buildParameterDisplay, - buildDisplayForParametersAndDelimiters: buildDisplayForParametersAndDelimiters, - buildDisplayForTypeParametersAndDelimiters: buildDisplayForTypeParametersAndDelimiters, - buildDisplayForTypeArgumentsAndDelimiters: buildDisplayForTypeArgumentsAndDelimiters, - buildTypeParameterDisplayFromSymbol: buildTypeParameterDisplayFromSymbol, - buildSignatureDisplay: buildSignatureDisplay, - buildReturnTypeDisplay: buildReturnTypeDisplay - }); - } - function isDeclarationVisible(node) { - function getContainingExternalModule(node) { - for (; node; node = node.parent) { - if (node.kind === 189 /* ModuleDeclaration */) { - if (node.name.kind === 7 /* StringLiteral */) { - return node; - } - } - else if (node.kind === 201 /* SourceFile */) { - return ts.isExternalModule(node) ? node : undefined; - } - } - ts.Debug.fail("getContainingModule cant reach here"); - } - function isUsedInExportAssignment(node) { - var externalModule = getContainingExternalModule(node); - if (externalModule) { - var externalModuleSymbol = getSymbolOfNode(externalModule); - var exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol); - var resolvedExportSymbol; - var symbolOfNode = getSymbolOfNode(node); - if (isSymbolUsedInExportAssignment(symbolOfNode)) { - return true; - } - if (symbolOfNode.flags & 33554432 /* Import */) { - return isSymbolUsedInExportAssignment(resolveImport(symbolOfNode)); - } - } - function isSymbolUsedInExportAssignment(symbol) { - if (exportAssignmentSymbol === symbol) { - return true; - } - if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 33554432 /* Import */)) { - resolvedExportSymbol = resolvedExportSymbol || resolveImport(exportAssignmentSymbol); - if (resolvedExportSymbol === symbol) { - return true; - } - return ts.forEach(resolvedExportSymbol.declarations, function (current) { - while (current) { - if (current === node) { - return true; - } - current = current.parent; - } - }); - } - } - } - function determineIfDeclarationIsVisible() { - switch (node.kind) { - case 183 /* VariableDeclaration */: - case 189 /* ModuleDeclaration */: - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - case 187 /* TypeAliasDeclaration */: - case 184 /* FunctionDeclaration */: - case 188 /* EnumDeclaration */: - case 191 /* ImportDeclaration */: - var parent = node.kind === 183 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (!(node.flags & 1 /* Export */) && !(node.kind !== 191 /* ImportDeclaration */ && parent.kind !== 201 /* SourceFile */ && ts.isInAmbientContext(parent))) { - return isGlobalSourceFile(parent) || isUsedInExportAssignment(node); - } - return isDeclarationVisible(parent); - case 124 /* Property */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 125 /* Method */: - if (node.flags & (32 /* Private */ | 64 /* Protected */)) { - return false; - } - case 126 /* Constructor */: - case 130 /* ConstructSignature */: - case 129 /* CallSignature */: - case 131 /* IndexSignature */: - case 123 /* Parameter */: - case 190 /* ModuleBlock */: - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 136 /* TypeLiteral */: - case 132 /* TypeReference */: - case 137 /* ArrayType */: - case 138 /* TupleType */: - case 139 /* UnionType */: - case 140 /* ParenthesizedType */: - return isDeclarationVisible(node.parent); - case 122 /* TypeParameter */: - case 201 /* SourceFile */: - return true; - default: - ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); - } - } - if (node) { - var links = getNodeLinks(node); - if (links.isVisible === undefined) { - links.isVisible = !!determineIfDeclarationIsVisible(); - } - return links.isVisible; - } - } - function getTypeOfPrototypeProperty(prototype) { - var classType = getDeclaredTypeOfSymbol(prototype.parent); - return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; - } - function getTypeOfVariableOrParameterOrPropertyDeclaration(declaration) { - if (declaration.parent.kind === 171 /* ForInStatement */) { - return anyType; - } - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 123 /* Parameter */) { - var func = declaration.parent; - if (func.kind === 128 /* SetAccessor */ && !ts.hasComputedNameButNotSymbol(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 127 /* GetAccessor */); - if (getter) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); - } - } - var type = getContextuallyTypedParameterType(declaration); - if (type) { - return type; - } - } - if (declaration.initializer) { - var type = checkAndMarkExpression(declaration.initializer); - if (declaration.kind !== 198 /* PropertyAssignment */) { - var unwidenedType = type; - type = getWidenedType(type); - if (type !== unwidenedType) { - checkImplicitAny(type); - } - } - return type; - } - if (declaration.kind === 199 /* ShorthandPropertyAssignment */) { - var type = checkIdentifier(declaration.name); - return type; - } - var type = ts.hasDotDotDotToken(declaration) ? createArrayType(anyType) : anyType; - checkImplicitAny(type); - return type; - function checkImplicitAny(type) { - if (!fullTypeCheck || !compilerOptions.noImplicitAny) { - return; - } - if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) { - return; - } - if (isPrivateWithinAmbient(declaration) || (declaration.kind === 123 /* Parameter */ && isPrivateWithinAmbient(declaration.parent))) { - return; - } - switch (declaration.kind) { - case 124 /* Property */: - var diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; - break; - case 123 /* Parameter */: - var diagnostic = ts.hasDotDotDotToken(declaration) ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; - break; - default: - var diagnostic = ts.Diagnostics.Variable_0_implicitly_has_an_1_type; - } - error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeToString(type)); - } - } - function getTypeOfVariableOrParameterOrProperty(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - if (symbol.flags & 536870912 /* Prototype */) { - return links.type = getTypeOfPrototypeProperty(symbol); - } - var declaration = symbol.valueDeclaration; - if (declaration.kind === 197 /* CatchClause */) { - return links.type = anyType; - } - links.type = resolvingType; - var type = getTypeOfVariableOrParameterOrPropertyDeclaration(declaration); - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var diagnostic = symbol.valueDeclaration.type ? ts.Diagnostics._0_implicitly_has_type_any_because_it_is_referenced_directly_or_indirectly_in_its_own_type_annotation : ts.Diagnostics._0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer; - error(symbol.valueDeclaration, diagnostic, symbolToString(symbol)); - } - } - return links.type; - } - function getSetAccessorTypeAnnotationNode(accessor) { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } - function getAnnotatedAccessorType(accessor) { - if (accessor) { - if (accessor.kind === 127 /* GetAccessor */) { - return accessor.type && getTypeFromTypeNode(accessor.type); - } - else { - var setterTypeAnnotation = getSetAccessorTypeAnnotationNode(accessor); - return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); - } - } - return undefined; - } - function getTypeOfAccessors(symbol) { - var links = getSymbolLinks(symbol); - checkAndStoreTypeOfAccessors(symbol, links); - return links.type; - } - function checkAndStoreTypeOfAccessors(symbol, links) { - links = links || getSymbolLinks(symbol); - if (!links.type) { - links.type = resolvingType; - var getter = ts.getDeclarationOfKind(symbol, 127 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 128 /* SetAccessor */); - var type; - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - type = getterReturnType; - } - else { - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - type = setterParameterType; - } - else { - if (getter && getter.body) { - type = getReturnTypeFromBody(getter); - } - else { - if (compilerOptions.noImplicitAny) { - error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); - } - type = anyType; - } - } - } - if (links.type === resolvingType) { - links.type = type; - } - } - else if (links.type === resolvingType) { - links.type = anyType; - if (compilerOptions.noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 127 /* GetAccessor */); - error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - } - function getTypeOfFuncClassEnumModule(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = createObjectType(32768 /* Anonymous */, symbol); - } - return links.type; - } - function getTypeOfEnumMember(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); - } - return links.type; - } - function getTypeOfImport(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = getTypeOfSymbol(resolveImport(symbol)); - } - return links.type; - } - function getTypeOfInstantiatedSymbol(symbol) { - var links = getSymbolLinks(symbol); - if (!links.type) { - links.type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - } - return links.type; - } - function getTypeOfSymbol(symbol) { - if (symbol.flags & 67108864 /* Instantiated */) { - return getTypeOfInstantiatedSymbol(symbol); - } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - return getTypeOfVariableOrParameterOrProperty(symbol); - } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { - return getTypeOfFuncClassEnumModule(symbol); - } - if (symbol.flags & 8 /* EnumMember */) { - return getTypeOfEnumMember(symbol); - } - if (symbol.flags & 98304 /* Accessor */) { - return getTypeOfAccessors(symbol); - } - if (symbol.flags & 33554432 /* Import */) { - return getTypeOfImport(symbol); - } - return unknownType; - } - function getTargetType(type) { - return type.flags & 4096 /* Reference */ ? type.target : type; - } - function hasBaseType(type, checkBase) { - return check(type); - function check(type) { - var target = getTargetType(type); - return target === checkBase || ts.forEach(target.baseTypes, check); - } - } - function getTypeParametersOfClassOrInterface(symbol) { - var result; - ts.forEach(symbol.declarations, function (node) { - if (node.kind === 186 /* InterfaceDeclaration */ || node.kind === 185 /* ClassDeclaration */) { - var declaration = node; - if (declaration.typeParameters && declaration.typeParameters.length) { - ts.forEach(declaration.typeParameters, function (node) { - var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)); - if (!result) { - result = [tp]; - } - else if (!ts.contains(result, tp)) { - result.push(tp); - } - }); - } - } - }); - return result; - } - function getDeclaredTypeOfClass(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = links.declaredType = createObjectType(1024 /* Class */, symbol); - var typeParameters = getTypeParametersOfClassOrInterface(symbol); - if (typeParameters) { - type.flags |= 4096 /* Reference */; - type.typeParameters = typeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - } - type.baseTypes = []; - var declaration = ts.getDeclarationOfKind(symbol, 185 /* ClassDeclaration */); - var baseTypeNode = ts.getClassBaseTypeNode(declaration); - if (baseTypeNode) { - var baseType = getTypeFromTypeReferenceNode(baseTypeNode); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & 1024 /* Class */) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); - } - } - else { - error(baseTypeNode, ts.Diagnostics.A_class_may_only_extend_another_class); - } - } - } - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = emptyArray; - type.declaredConstructSignatures = emptyArray; - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - } - return links.declaredType; - } - function getDeclaredTypeOfInterface(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = links.declaredType = createObjectType(2048 /* Interface */, symbol); - var typeParameters = getTypeParametersOfClassOrInterface(symbol); - if (typeParameters) { - type.flags |= 4096 /* Reference */; - type.typeParameters = typeParameters; - type.instantiations = {}; - type.instantiations[getTypeListId(type.typeParameters)] = type; - type.target = type; - type.typeArguments = type.typeParameters; - } - type.baseTypes = []; - ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 186 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), function (node) { - var baseType = getTypeFromTypeReferenceNode(node); - if (baseType !== unknownType) { - if (getTargetType(baseType).flags & (1024 /* Class */ | 2048 /* Interface */)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - type.baseTypes.push(baseType); - } - else { - error(declaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */)); - } - } - else { - error(node, ts.Diagnostics.An_interface_may_only_extend_a_class_or_another_interface); - } - } - }); - } - }); - type.declaredProperties = getNamedMembers(symbol.members); - type.declaredCallSignatures = getSignaturesOfSymbol(symbol.members["__call"]); - type.declaredConstructSignatures = getSignaturesOfSymbol(symbol.members["__new"]); - type.declaredStringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - type.declaredNumberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - } - return links.declaredType; - } - function getDeclaredTypeOfTypeAlias(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - links.declaredType = resolvingType; - var declaration = ts.getDeclarationOfKind(symbol, 187 /* TypeAliasDeclaration */); - var type = getTypeFromTypeNode(declaration.type); - if (links.declaredType === resolvingType) { - links.declaredType = type; - } - } - else if (links.declaredType === resolvingType) { - links.declaredType = unknownType; - var declaration = ts.getDeclarationOfKind(symbol, 187 /* TypeAliasDeclaration */); - error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); - } - return links.declaredType; - } - function getDeclaredTypeOfEnum(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(128 /* Enum */); - type.symbol = symbol; - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfTypeParameter(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - var type = createType(512 /* TypeParameter */); - type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 122 /* TypeParameter */).constraint) { - type.constraint = noConstraintType; - } - links.declaredType = type; - } - return links.declaredType; - } - function getDeclaredTypeOfImport(symbol) { - var links = getSymbolLinks(symbol); - if (!links.declaredType) { - links.declaredType = getDeclaredTypeOfSymbol(resolveImport(symbol)); - } - return links.declaredType; - } - function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0); - if (symbol.flags & 32 /* Class */) { - return getDeclaredTypeOfClass(symbol); - } - if (symbol.flags & 64 /* Interface */) { - return getDeclaredTypeOfInterface(symbol); - } - if (symbol.flags & 2097152 /* TypeAlias */) { - return getDeclaredTypeOfTypeAlias(symbol); - } - if (symbol.flags & 384 /* Enum */) { - return getDeclaredTypeOfEnum(symbol); - } - if (symbol.flags & 1048576 /* TypeParameter */) { - return getDeclaredTypeOfTypeParameter(symbol); - } - if (symbol.flags & 33554432 /* Import */) { - return getDeclaredTypeOfImport(symbol); - } - return unknownType; - } - function createSymbolTable(symbols) { - var result = {}; - for (var i = 0; i < symbols.length; i++) { - var symbol = symbols[i]; - result[symbol.name] = symbol; - } - return result; - } - function createInstantiatedSymbolTable(symbols, mapper) { - var result = {}; - for (var i = 0; i < symbols.length; i++) { - var symbol = symbols[i]; - result[symbol.name] = instantiateSymbol(symbol, mapper); - } - return result; - } - function addInheritedMembers(symbols, baseSymbols) { - for (var i = 0; i < baseSymbols.length; i++) { - var s = baseSymbols[i]; - if (!ts.hasProperty(symbols, s.name)) { - symbols[s.name] = s; - } - } - } - function addInheritedSignatures(signatures, baseSignatures) { - if (baseSignatures) { - for (var i = 0; i < baseSignatures.length; i++) { - signatures.push(baseSignatures[i]); - } - } - } - function resolveClassOrInterfaceMembers(type) { - var members = type.symbol.members; - var callSignatures = type.declaredCallSignatures; - var constructSignatures = type.declaredConstructSignatures; - var stringIndexType = type.declaredStringIndexType; - var numberIndexType = type.declaredNumberIndexType; - if (type.baseTypes.length) { - members = createSymbolTable(type.declaredProperties); - ts.forEach(type.baseTypes, function (baseType) { - addInheritedMembers(members, getPropertiesOfObjectType(baseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(baseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(baseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(baseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(baseType, 1 /* Number */); - }); - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveTypeReferenceMembers(type) { - var target = type.target; - var mapper = createTypeMapper(target.typeParameters, type.typeArguments); - var members = createInstantiatedSymbolTable(target.declaredProperties, mapper); - var callSignatures = instantiateList(target.declaredCallSignatures, mapper, instantiateSignature); - var constructSignatures = instantiateList(target.declaredConstructSignatures, mapper, instantiateSignature); - var stringIndexType = target.declaredStringIndexType ? instantiateType(target.declaredStringIndexType, mapper) : undefined; - var numberIndexType = target.declaredNumberIndexType ? instantiateType(target.declaredNumberIndexType, mapper) : undefined; - ts.forEach(target.baseTypes, function (baseType) { - var instantiatedBaseType = instantiateType(baseType, mapper); - addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexType = stringIndexType || getIndexTypeOfType(instantiatedBaseType, 0 /* String */); - numberIndexType = numberIndexType || getIndexTypeOfType(instantiatedBaseType, 1 /* Number */); - }); - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function createSignature(declaration, typeParameters, parameters, resolvedReturnType, minArgumentCount, hasRestParameter, hasStringLiterals) { - var sig = new Signature(checker); - sig.declaration = declaration; - sig.typeParameters = typeParameters; - sig.parameters = parameters; - sig.resolvedReturnType = resolvedReturnType; - sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasStringLiterals = hasStringLiterals; - return sig; - } - function cloneSignature(sig) { - return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals); - } - function getDefaultConstructSignatures(classType) { - if (classType.baseTypes.length) { - var baseType = classType.baseTypes[0]; - var baseSignatures = getSignaturesOfType(getTypeOfSymbol(baseType.symbol), 1 /* Construct */); - return ts.map(baseSignatures, function (baseSignature) { - var signature = baseType.flags & 4096 /* Reference */ ? getSignatureInstantiation(baseSignature, baseType.typeArguments) : cloneSignature(baseSignature); - signature.typeParameters = classType.typeParameters; - signature.resolvedReturnType = classType; - return signature; - }); - } - return [createSignature(undefined, classType.typeParameters, emptyArray, classType, 0, false, false)]; - } - function createTupleTypeMemberSymbols(memberTypes) { - var members = {}; - for (var i = 0; i < memberTypes.length; i++) { - var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "" + i); - symbol.type = memberTypes[i]; - members[i] = symbol; - } - return members; - } - function resolveTupleTypeMembers(type) { - var arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); - var members = createTupleTypeMemberSymbols(type.elementTypes); - addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); - } - function signatureListsIdentical(s, t) { - if (s.length !== t.length) { - return false; - } - for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, compareTypes)) { - return false; - } - } - return true; - } - function getUnionSignatures(types, kind) { - var signatureLists = ts.map(types, function (t) { return getSignaturesOfType(t, kind); }); - var signatures = signatureLists[0]; - for (var i = 0; i < signatures.length; i++) { - if (signatures[i].typeParameters) { - return emptyArray; - } - } - for (var i = 1; i < signatureLists.length; i++) { - if (!signatureListsIdentical(signatures, signatureLists[i])) { - return emptyArray; - } - } - var result = ts.map(signatures, cloneSignature); - for (var i = 0; i < result.length; i++) { - var s = result[i]; - s.resolvedReturnType = undefined; - s.unionSignatures = ts.map(signatureLists, function (signatures) { return signatures[i]; }); - } - return result; - } - function getUnionIndexType(types, kind) { - var indexTypes = []; - for (var i = 0; i < types.length; i++) { - var indexType = getIndexTypeOfType(types[i], kind); - if (!indexType) { - return undefined; - } - indexTypes.push(indexType); - } - return getUnionType(indexTypes); - } - function resolveUnionTypeMembers(type) { - var callSignatures = getUnionSignatures(type.types, 0 /* Call */); - var constructSignatures = getUnionSignatures(type.types, 1 /* Construct */); - var stringIndexType = getUnionIndexType(type.types, 0 /* String */); - var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); - setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; - if (symbol.flags & 2048 /* TypeLiteral */) { - var members = symbol.members; - var callSignatures = getSignaturesOfSymbol(members["__call"]); - var constructSignatures = getSignaturesOfSymbol(members["__new"]); - var stringIndexType = getIndexTypeOfSymbol(symbol, 0 /* String */); - var numberIndexType = getIndexTypeOfSymbol(symbol, 1 /* Number */); - } - else { - var members = emptySymbols; - var callSignatures = emptyArray; - var constructSignatures = emptyArray; - if (symbol.flags & 1952 /* HasExports */) { - members = symbol.exports; - } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { - callSignatures = getSignaturesOfSymbol(symbol); - } - if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClass(symbol); - constructSignatures = getSignaturesOfSymbol(symbol.members["__constructor"]); - if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); - } - if (classType.baseTypes.length) { - members = createSymbolTable(getNamedMembers(members)); - addInheritedMembers(members, getPropertiesOfObjectType(getTypeOfSymbol(classType.baseTypes[0].symbol))); - } - } - var stringIndexType = undefined; - var numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; - } - setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); - } - function resolveObjectOrUnionTypeMembers(type) { - if (!type.members) { - if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { - resolveClassOrInterfaceMembers(type); - } - else if (type.flags & 32768 /* Anonymous */) { - resolveAnonymousTypeMembers(type); - } - else if (type.flags & 8192 /* Tuple */) { - resolveTupleTypeMembers(type); - } - else if (type.flags & 16384 /* Union */) { - resolveUnionTypeMembers(type); - } - else { - resolveTypeReferenceMembers(type); - } - } - return type; - } - function getPropertiesOfObjectType(type) { - if (type.flags & 48128 /* ObjectType */) { - return resolveObjectOrUnionTypeMembers(type).properties; - } - return emptyArray; - } - function getPropertyOfObjectType(type, name) { - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - } - } - function getPropertiesOfUnionType(type) { - var result = []; - ts.forEach(getPropertiesOfType(type.types[0]), function (prop) { - var unionProp = getPropertyOfUnionType(type, prop.name); - if (unionProp) { - result.push(unionProp); - } - }); - return result; - } - function getPropertiesOfType(type) { - if (type.flags & 16384 /* Union */) { - return getPropertiesOfUnionType(type); - } - return getPropertiesOfObjectType(getApparentType(type)); - } - function getApparentType(type) { - if (type.flags & 512 /* TypeParameter */) { - do { - type = getConstraintOfTypeParameter(type); - } while (type && type.flags & 512 /* TypeParameter */); - if (!type) { - type = emptyObjectType; - } - } - if (type.flags & 258 /* StringLike */) { - type = globalStringType; - } - else if (type.flags & 132 /* NumberLike */) { - type = globalNumberType; - } - else if (type.flags & 8 /* Boolean */) { - type = globalBooleanType; - } - return type; - } - function createUnionProperty(unionType, name) { - var types = unionType.types; - var props; - for (var i = 0; i < types.length; i++) { - var type = getApparentType(types[i]); - if (type !== unknownType) { - var prop = getPropertyOfType(type, name); - if (!prop) { - return undefined; - } - if (!props) { - props = [prop]; - } - else { - props.push(prop); - } - } - } - var propTypes = []; - var declarations = []; - for (var i = 0; i < props.length; i++) { - var prop = props[i]; - if (prop.declarations) { - declarations.push.apply(declarations, prop.declarations); - } - propTypes.push(getTypeOfSymbol(prop)); - } - var result = createSymbol(4 /* Property */ | 268435456 /* Transient */ | 1073741824 /* UnionProperty */, name); - result.unionType = unionType; - result.declarations = declarations; - result.type = getUnionType(propTypes); - return result; - } - function getPropertyOfUnionType(type, name) { - var properties = type.resolvedProperties || (type.resolvedProperties = {}); - if (ts.hasProperty(properties, name)) { - return properties[name]; - } - var property = createUnionProperty(type, name); - if (property) { - properties[name] = property; - } - return property; - } - function getPropertyOfType(type, name) { - if (type.flags & 16384 /* Union */) { - return getPropertyOfUnionType(type, name); - } - if (!(type.flags & 48128 /* ObjectType */)) { - type = getApparentType(type); - if (!(type.flags & 48128 /* ObjectType */)) { - return undefined; - } - } - var resolved = resolveObjectOrUnionTypeMembers(type); - if (ts.hasProperty(resolved.members, name)) { - var symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } - } - if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { - var symbol = getPropertyOfObjectType(globalFunctionType, name); - if (symbol) - return symbol; - } - return getPropertyOfObjectType(globalObjectType, name); - } - function getSignaturesOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveObjectOrUnionTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; - } - return emptyArray; - } - function getSignaturesOfType(type, kind) { - return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); - } - function getIndexTypeOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveObjectOrUnionTypeMembers(type); - return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; - } - } - function getIndexTypeOfType(type, kind) { - return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); - } - function getTypeParametersFromDeclaration(typeParameterDeclarations) { - var result = []; - ts.forEach(typeParameterDeclarations, function (node) { - var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - result.push(tp); - } - }); - return result; - } - function getSignatureFromDeclaration(declaration) { - var links = getNodeLinks(declaration); - if (!links.resolvedSignature) { - var classType = declaration.kind === 126 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; - var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; - var parameters = []; - var hasStringLiterals = false; - var minArgumentCount = -1; - for (var i = 0, n = declaration.parameters.length; i < n; i++) { - var param = declaration.parameters[i]; - parameters.push(param.symbol); - if (param.type && param.type.kind === 7 /* StringLiteral */) { - hasStringLiterals = true; - } - if (minArgumentCount < 0) { - if (param.initializer || param.questionToken || param.dotDotDotToken) { - minArgumentCount = i; - } - } - } - if (minArgumentCount < 0) { - minArgumentCount = declaration.parameters.length; - } - var returnType; - if (classType) { - returnType = classType; - } - else if (declaration.type) { - returnType = getTypeFromTypeNode(declaration.type); - } - else { - if (declaration.kind === 127 /* GetAccessor */ && !ts.hasComputedNameButNotSymbol(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 128 /* SetAccessor */); - returnType = getAnnotatedAccessorType(setter); - } - if (!returnType && !declaration.body) { - returnType = anyType; - } - } - links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, ts.hasRestParameters(declaration), hasStringLiterals); - } - return links.resolvedSignature; - } - function getSignaturesOfSymbol(symbol) { - if (!symbol) - return emptyArray; - var result = []; - for (var i = 0, len = symbol.declarations.length; i < len; i++) { - var node = symbol.declarations[i]; - switch (node.kind) { - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 184 /* FunctionDeclaration */: - case 125 /* Method */: - case 126 /* Constructor */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - if (i > 0 && node.body) { - var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { - break; - } - } - result.push(getSignatureFromDeclaration(node)); - } - } - return result; - } - function getReturnTypeOfSignature(signature) { - if (!signature.resolvedReturnType) { - signature.resolvedReturnType = resolvingType; - if (signature.target) { - var type = instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper); - } - else if (signature.unionSignatures) { - var type = getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature)); - } - else { - var type = getReturnTypeFromBody(signature.declaration); - } - if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = type; - } - } - else if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = anyType; - if (compilerOptions.noImplicitAny) { - var declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(declaration.name)); - } - else { - error(declaration, ts.Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); - } - } - } - return signature.resolvedReturnType; - } - function getRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { - var type = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); - if (type.flags & 4096 /* Reference */ && type.target === globalArrayType) { - return type.typeArguments[0]; - } - } - return anyType; - } - function getSignatureInstantiation(signature, typeArguments) { - return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); - } - function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - if (signature.target) { - signature.erasedSignatureCache = instantiateSignature(getErasedSignature(signature.target), signature.mapper); - } - else { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); - } - } - return signature.erasedSignatureCache; - } - function getOrCreateTypeFromSignature(signature) { - if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 126 /* Constructor */ || signature.declaration.kind === 130 /* ConstructSignature */; - var type = createObjectType(32768 /* Anonymous */ | 65536 /* FromSignature */); - type.members = emptySymbols; - type.properties = emptyArray; - type.callSignatures = !isConstructor ? [signature] : emptyArray; - type.constructSignatures = isConstructor ? [signature] : emptyArray; - signature.isolatedSignatureType = type; - } - return signature.isolatedSignatureType; - } - function getIndexSymbol(symbol) { - return symbol.members["__index"]; - } - function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 116 /* NumberKeyword */ : 118 /* StringKeyword */; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { - var len = indexSymbol.declarations.length; - for (var i = 0; i < len; i++) { - var node = indexSymbol.declarations[i]; - if (node.parameters.length === 1) { - var parameter = node.parameters[0]; - if (parameter && parameter.type && parameter.type.kind === syntaxKind) { - return node; - } - } - } - } - return undefined; - } - function getIndexTypeOfSymbol(symbol, kind) { - var declaration = getIndexDeclarationOfSymbol(symbol, kind); - return declaration ? declaration.type ? getTypeFromTypeNode(declaration.type) : anyType : undefined; - } - function getConstraintOfTypeParameter(type) { - if (!type.constraint) { - if (type.target) { - var targetConstraint = getConstraintOfTypeParameter(type.target); - type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; - } - else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 122 /* TypeParameter */).constraint); - } - } - return type.constraint === noConstraintType ? undefined : type.constraint; - } - function getTypeListId(types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - var result = ""; - for (var i = 0; i < types.length; i++) { - if (i > 0) - result += ","; - result += types[i].id; - } - return result; - } - } - function createTypeReference(target, typeArguments) { - var id = getTypeListId(typeArguments); - var type = target.instantiations[id]; - if (!type) { - type = target.instantiations[id] = createObjectType(4096 /* Reference */, target.symbol); - type.target = target; - type.typeArguments = typeArguments; - } - return type; - } - function isTypeParameterReferenceIllegalInConstraint(typeReferenceNode, typeParameterSymbol) { - var links = getNodeLinks(typeReferenceNode); - if (links.isIllegalTypeReferenceInConstraint !== undefined) { - return links.isIllegalTypeReferenceInConstraint; - } - var currentNode = typeReferenceNode; - while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { - currentNode = currentNode.parent; - } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 122 /* TypeParameter */; - return links.isIllegalTypeReferenceInConstraint; - } - function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { - var typeParameterSymbol; - function check(n) { - if (n.kind === 132 /* TypeReference */ && n.typeName.kind === 63 /* Identifier */) { - var links = getNodeLinks(n); - if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, 3152352 /* Type */, undefined, undefined); - if (symbol && (symbol.flags & 1048576 /* TypeParameter */)) { - links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); - } - } - if (links.isIllegalTypeReferenceInConstraint) { - error(typeParameter, ts.Diagnostics.Constraint_of_a_type_parameter_cannot_reference_any_type_parameter_from_the_same_type_parameter_list); - } - } - ts.forEachChild(n, check); - } - if (typeParameter.constraint) { - typeParameterSymbol = getSymbolOfNode(typeParameter); - check(typeParameter.constraint); - } - } - function getTypeFromTypeReferenceNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var symbol = resolveEntityName(node, node.typeName, 3152352 /* Type */); - if (symbol) { - var type; - if ((symbol.flags & 1048576 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { - type = unknownType; - } - else { - type = getDeclaredTypeOfSymbol(symbol); - if (type.flags & (1024 /* Class */ | 2048 /* Interface */) && type.flags & 4096 /* Reference */) { - var typeParameters = type.typeParameters; - if (node.typeArguments && node.typeArguments.length === typeParameters.length) { - type = createTypeReference(type, ts.map(node.typeArguments, getTypeFromTypeNode)); - } - else { - error(node, ts.Diagnostics.Generic_type_0_requires_1_type_argument_s, typeToString(type, undefined, 1 /* WriteArrayAsGenericType */), typeParameters.length); - type = undefined; - } - } - else { - if (node.typeArguments) { - error(node, ts.Diagnostics.Type_0_is_not_generic, typeToString(type)); - type = undefined; - } - } - } - } - links.resolvedType = type || unknownType; - } - return links.resolvedType; - } - function getTypeFromTypeQueryNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getWidenedType(checkExpressionOrQualifiedName(node.exprName)); - } - return links.resolvedType; - } - function getTypeOfGlobalSymbol(symbol, arity) { - function getTypeDeclaration(symbol) { - var declarations = symbol.declarations; - for (var i = 0; i < declarations.length; i++) { - var declaration = declarations[i]; - switch (declaration.kind) { - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - case 188 /* EnumDeclaration */: - return declaration; - } - } - } - if (!symbol) { - return emptyObjectType; - } - var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 48128 /* ObjectType */)) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); - return emptyObjectType; - } - if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) { - error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity); - return emptyObjectType; - } - return type; - } - function getGlobalSymbol(name) { - return resolveName(undefined, name, 3152352 /* Type */, ts.Diagnostics.Cannot_find_global_type_0, name); - } - function getGlobalType(name) { - return getTypeOfGlobalSymbol(getGlobalSymbol(name), 0); - } - function createArrayType(elementType) { - var arrayType = globalArrayType || getDeclaredTypeOfSymbol(globalArraySymbol); - return arrayType !== emptyObjectType ? createTypeReference(arrayType, [elementType]) : emptyObjectType; - } - function getTypeFromArrayTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType)); - } - return links.resolvedType; - } - function createTupleType(elementTypes) { - var id = getTypeListId(elementTypes); - var type = tupleTypes[id]; - if (!type) { - type = tupleTypes[id] = createObjectType(8192 /* Tuple */); - type.elementTypes = elementTypes; - } - return type; - } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createTupleType(ts.map(node.elementTypes, getTypeFromTypeNode)); - } - return links.resolvedType; - } - function addTypeToSortedSet(sortedSet, type) { - if (type.flags & 16384 /* Union */) { - addTypesToSortedSet(sortedSet, type.types); - } - else { - var i = 0; - var id = type.id; - while (i < sortedSet.length && sortedSet[i].id < id) { - i++; - } - if (i === sortedSet.length || sortedSet[i].id !== id) { - sortedSet.splice(i, 0, type); - } - } - } - function addTypesToSortedSet(sortedTypes, types) { - for (var i = 0, len = types.length; i < len; i++) { - addTypeToSortedSet(sortedTypes, types[i]); - } - } - function isSubtypeOfAny(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) { - return true; - } - } - return false; - } - function removeSubtypes(types) { - var i = types.length; - while (i > 0) { - i--; - if (isSubtypeOfAny(types[i], types)) { - types.splice(i, 1); - } - } - } - function containsAnyType(types) { - for (var i = 0; i < types.length; i++) { - if (types[i].flags & 1 /* Any */) { - return true; - } - } - return false; - } - function removeAllButLast(types, typeToRemove) { - var i = types.length; - while (i > 0 && types.length > 1) { - i--; - if (types[i] === typeToRemove) { - types.splice(i, 1); - } - } - } - function getUnionType(types, noSubtypeReduction) { - if (types.length === 0) { - return emptyObjectType; - } - var sortedTypes = []; - addTypesToSortedSet(sortedTypes, types); - if (noSubtypeReduction) { - if (containsAnyType(sortedTypes)) { - return anyType; - } - removeAllButLast(sortedTypes, undefinedType); - removeAllButLast(sortedTypes, nullType); - } - else { - removeSubtypes(sortedTypes); - } - if (sortedTypes.length === 1) { - return sortedTypes[0]; - } - var id = getTypeListId(sortedTypes); - var type = unionTypes[id]; - if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */); - type.types = sortedTypes; - } - return type; - } - function getTypeFromUnionTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), true); - } - return links.resolvedType; - } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = createObjectType(32768 /* Anonymous */, node.symbol); - } - return links.resolvedType; - } - function getStringLiteralType(node) { - if (ts.hasProperty(stringLiteralTypes, node.text)) { - return stringLiteralTypes[node.text]; - } - var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); - type.text = ts.getTextOfNode(node); - return type; - } - function getTypeFromStringLiteral(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getStringLiteralType(node); - } - return links.resolvedType; - } - function getTypeFromTypeNode(node) { - switch (node.kind) { - case 109 /* AnyKeyword */: - return anyType; - case 118 /* StringKeyword */: - return stringType; - case 116 /* NumberKeyword */: - return numberType; - case 110 /* BooleanKeyword */: - return booleanType; - case 97 /* VoidKeyword */: - return voidType; - case 7 /* StringLiteral */: - return getTypeFromStringLiteral(node); - case 132 /* TypeReference */: - return getTypeFromTypeReferenceNode(node); - case 135 /* TypeQuery */: - return getTypeFromTypeQueryNode(node); - case 137 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 138 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 139 /* UnionType */: - return getTypeFromUnionTypeNode(node); - case 140 /* ParenthesizedType */: - return getTypeFromTypeNode(node.type); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 136 /* TypeLiteral */: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 63 /* Identifier */: - case 120 /* QualifiedName */: - var symbol = getSymbolInfo(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - default: - return unknownType; - } - } - function instantiateList(items, mapper, instantiator) { - if (items && items.length) { - var result = []; - for (var i = 0; i < items.length; i++) { - result.push(instantiator(items[i], mapper)); - } - return result; - } - return items; - } - function createUnaryTypeMapper(source, target) { - return function (t) { return t === source ? target : t; }; - } - function createBinaryTypeMapper(source1, target1, source2, target2) { - return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; - } - function createTypeMapper(sources, targets) { - switch (sources.length) { - case 1: return createUnaryTypeMapper(sources[0], targets[0]); - case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); - } - return function (t) { - for (var i = 0; i < sources.length; i++) { - if (t === sources[i]) - return targets[i]; - } - return t; - }; - } - function createUnaryTypeEraser(source) { - return function (t) { return t === source ? anyType : t; }; - } - function createBinaryTypeEraser(source1, source2) { - return function (t) { return t === source1 || t === source2 ? anyType : t; }; - } - function createTypeEraser(sources) { - switch (sources.length) { - case 1: return createUnaryTypeEraser(sources[0]); - case 2: return createBinaryTypeEraser(sources[0], sources[1]); - } - return function (t) { - for (var i = 0; i < sources.length; i++) { - if (t === sources[i]) - return anyType; - } - return t; - }; - } - function createInferenceMapper(context) { - return function (t) { - for (var i = 0; i < context.typeParameters.length; i++) { - if (t === context.typeParameters[i]) { - return getInferredType(context, i); - } - } - return t; - }; - } - function identityMapper(type) { - return type; - } - function combineTypeMappers(mapper1, mapper2) { - return function (t) { return mapper2(mapper1(t)); }; - } - function instantiateTypeParameter(typeParameter, mapper) { - var result = createType(512 /* TypeParameter */); - result.symbol = typeParameter.symbol; - if (typeParameter.constraint) { - result.constraint = instantiateType(typeParameter.constraint, mapper); - } - else { - result.target = typeParameter; - result.mapper = mapper; - } - return result; - } - function instantiateSignature(signature, mapper, eraseTypeParameters) { - if (signature.typeParameters && !eraseTypeParameters) { - var freshTypeParameters = instantiateList(signature.typeParameters, mapper, instantiateTypeParameter); - mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper); - } - var result = createSignature(signature.declaration, freshTypeParameters, instantiateList(signature.parameters, mapper, instantiateSymbol), signature.resolvedReturnType ? instantiateType(signature.resolvedReturnType, mapper) : undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals); - result.target = signature; - result.mapper = mapper; - return result; - } - function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 67108864 /* Instantiated */) { - var links = getSymbolLinks(symbol); - symbol = links.target; - mapper = combineTypeMappers(links.mapper, mapper); - } - var result = createSymbol(67108864 /* Instantiated */ | 268435456 /* Transient */ | symbol.flags, symbol.name); - result.declarations = symbol.declarations; - result.parent = symbol.parent; - result.target = symbol; - result.mapper = mapper; - if (symbol.valueDeclaration) { - result.valueDeclaration = symbol.valueDeclaration; - } - return result; - } - function instantiateAnonymousType(type, mapper) { - var result = createObjectType(32768 /* Anonymous */, type.symbol); - result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); - result.members = createSymbolTable(result.properties); - result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature); - result.constructSignatures = instantiateList(getSignaturesOfType(type, 1 /* Construct */), mapper, instantiateSignature); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - result.stringIndexType = instantiateType(stringIndexType, mapper); - if (numberIndexType) - result.numberIndexType = instantiateType(numberIndexType, mapper); - return result; - } - function instantiateType(type, mapper) { - if (mapper !== identityMapper) { - if (type.flags & 512 /* TypeParameter */) { - return mapper(type); - } - if (type.flags & 32768 /* Anonymous */) { - return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) ? instantiateAnonymousType(type, mapper) : type; - } - if (type.flags & 4096 /* Reference */) { - return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); - } - if (type.flags & 8192 /* Tuple */) { - return createTupleType(instantiateList(type.elementTypes, mapper, instantiateType)); - } - if (type.flags & 16384 /* Union */) { - return getUnionType(instantiateList(type.types, mapper, instantiateType), true); - } - } - return type; - } - function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); - switch (node.kind) { - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - return isContextSensitiveFunctionLikeDeclaration(node); - case 142 /* ObjectLiteralExpression */: - return ts.forEach(node.properties, isContextSensitive); - case 141 /* ArrayLiteralExpression */: - return ts.forEach(node.elements, isContextSensitive); - case 158 /* ConditionalExpression */: - return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 157 /* BinaryExpression */: - return node.operator === 48 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 198 /* PropertyAssignment */: - return isContextSensitive(node.initializer); - case 125 /* Method */: - return isContextSensitiveFunctionLikeDeclaration(node); - } - return false; - } - function isContextSensitiveFunctionLikeDeclaration(node) { - return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); - } - function getTypeWithoutConstructors(type) { - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); - if (resolved.constructSignatures.length) { - var result = createObjectType(32768 /* Anonymous */, type.symbol); - result.members = resolved.members; - result.properties = resolved.properties; - result.callSignatures = resolved.callSignatures; - result.constructSignatures = emptyArray; - type = result; - } - } - return type; - } - var subtypeRelation = {}; - var assignableRelation = {}; - var identityRelation = {}; - function isTypeIdenticalTo(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined); - } - function compareTypes(source, target) { - return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 /* True */ : 0 /* False */; - } - function isTypeSubtypeOf(source, target) { - return checkTypeSubtypeOf(source, target, undefined); - } - function isTypeAssignableTo(source, target) { - return checkTypeAssignableTo(source, target, undefined); - } - function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); - } - function checkTypeAssignableTo(source, target, errorNode, headMessage) { - return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage); - } - function isSignatureAssignableTo(source, target) { - var sourceType = getOrCreateTypeFromSignature(source); - var targetType = getOrCreateTypeFromSignature(target); - return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); - } - function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { - var errorInfo; - var sourceStack; - var targetStack; - var maybeStack; - var expandingFlags; - var depth = 0; - var overflow = false; - ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); - if (overflow) { - error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); - } - else if (errorInfo) { - if (containingMessageChain) { - errorInfo = ts.concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); - } - addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, program.getCompilerHost().getNewLine())); - } - return result !== 0 /* False */; - function reportError(message, arg0, arg1, arg2) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); - } - function isRelatedTo(source, target, reportErrors, headMessage) { - var result; - if (relation === identityRelation) { - if (source === target) - return -1 /* True */; - } - else { - if (source === target) - return -1 /* True */; - if (target.flags & 1 /* Any */) - return -1 /* True */; - if (source === undefinedType) - return -1 /* True */; - if (source === nullType && target !== undefinedType) - return -1 /* True */; - if (source.flags & 128 /* Enum */ && target === numberType) - return -1 /* True */; - if (source.flags & 256 /* StringLiteral */ && target === stringType) - return -1 /* True */; - if (relation === assignableRelation) { - if (source.flags & 1 /* Any */) - return -1 /* True */; - if (source === numberType && target.flags & 128 /* Enum */) - return -1 /* True */; - } - } - if (source.flags & 16384 /* Union */) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else if (target.flags & 16384 /* Union */) { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { - return result; - } - } - else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - if (result = typeParameterRelatedTo(source, target, reportErrors)) { - return result; - } - } - else { - var saveErrorInfo = errorInfo; - if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return result; - } - } - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & 48128 /* ObjectType */ && target.flags & 48128 /* ObjectType */ && (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors))) { - errorInfo = saveErrorInfo; - return result; - } - } - if (reportErrors) { - headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - reportError(headMessage, typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - function typeRelatedToUnionType(source, target, reportErrors) { - var targetTypes = target.types; - for (var i = 0, len = targetTypes.length; i < len; i++) { - var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); - if (related) { - return related; - } - } - return 0 /* False */; - } - function unionTypeRelatedToType(source, target, reportErrors) { - var result = -1 /* True */; - var sourceTypes = source.types; - for (var i = 0, len = sourceTypes.length; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function typesRelatedTo(sources, targets, reportErrors) { - var result = -1 /* True */; - for (var i = 0, len = sources.length; i < len; i++) { - var related = isRelatedTo(sources[i], targets[i], reportErrors); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function typeParameterRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - if (source.symbol.name !== target.symbol.name) { - return 0 /* False */; - } - if (source.constraint === target.constraint) { - return -1 /* True */; - } - if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return 0 /* False */; - } - return isRelatedTo(source.constraint, target.constraint, reportErrors); - } - else { - while (true) { - var constraint = getConstraintOfTypeParameter(source); - if (constraint === target) - return -1 /* True */; - if (!(constraint && constraint.flags & 512 /* TypeParameter */)) - break; - source = constraint; - } - return 0 /* False */; - } - } - function objectTypeRelatedTo(source, target, reportErrors) { - if (overflow) { - return 0 /* False */; - } - var id = source.id + "," + target.id; - var related = relation[id]; - if (related !== undefined) { - return related ? -1 /* True */ : 0 /* False */; - } - if (depth > 0) { - for (var i = 0; i < depth; i++) { - if (maybeStack[i][id]) { - return 1 /* Maybe */; - } - } - if (depth === 100) { - overflow = true; - return 0 /* False */; - } - } - else { - sourceStack = []; - targetStack = []; - maybeStack = []; - expandingFlags = 0; - } - sourceStack[depth] = source; - targetStack[depth] = target; - maybeStack[depth] = {}; - maybeStack[depth][id] = true; - depth++; - var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack)) - expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) - expandingFlags |= 2; - if (expandingFlags === 3) { - var result = 1 /* Maybe */; - } - else { - var result = propertiesRelatedTo(source, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors); - if (result) { - result &= stringIndexTypesRelatedTo(source, target, reportErrors); - if (result) { - result &= numberIndexTypesRelatedTo(source, target, reportErrors); - } - } - } - } - } - expandingFlags = saveExpandingFlags; - depth--; - if (result) { - var maybeCache = maybeStack[depth]; - var destinationCache = result === -1 /* True */ || depth === 0 ? relation : maybeStack[depth - 1]; - for (var p in maybeCache) { - destinationCache[p] = maybeCache[p]; - } - } - else { - relation[id] = false; - } - return result; - } - function isDeeplyNestedGeneric(type, stack) { - if (type.flags & 4096 /* Reference */ && depth >= 10) { - var target = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 /* Reference */ && t.target === target) { - count++; - if (count >= 10) - return true; - } - } - } - return false; - } - function propertiesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return propertiesIdenticalTo(source, target); - } - var result = -1 /* True */; - var properties = getPropertiesOfObjectType(target); - for (var i = 0; i < properties.length; i++) { - var targetProp = properties[i]; - var sourceProp = getPropertyOfType(source, targetProp.name); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (relation === subtypeRelation || !isOptionalProperty(targetProp)) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0 /* False */; - } - } - else if (!(targetProp.flags & 536870912 /* Prototype */)) { - var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); - var targetFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourceFlags & 32 /* Private */ || targetFlags & 32 /* Private */) { - if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { - if (reportErrors) { - if (sourceFlags & 32 /* Private */ && targetFlags & 32 /* Private */) { - reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); - } - else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourceFlags & 32 /* Private */ ? source : target), typeToString(sourceFlags & 32 /* Private */ ? target : source)); - } - } - return 0 /* False */; - } - } - else if (targetFlags & 64 /* Protected */) { - var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; - var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; - var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); - if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); - } - return 0 /* False */; - } - } - else if (sourceFlags & 64 /* Protected */) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); - } - return 0 /* False */; - } - result &= related; - if (isOptionalProperty(sourceProp) && !isOptionalProperty(targetProp)) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); - } - return 0 /* False */; - } - } - } - } - return result; - } - function propertiesIdenticalTo(source, target) { - var sourceProperties = getPropertiesOfObjectType(source); - var targetProperties = getPropertiesOfObjectType(target); - if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; - } - var result = -1 /* True */; - for (var i = 0, len = sourceProperties.length; i < len; ++i) { - var sourceProp = sourceProperties[i]; - var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp) { - return 0 /* False */; - } - var related = compareProperties(sourceProp, targetProp, isRelatedTo); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function signaturesRelatedTo(source, target, kind, reportErrors) { - if (relation === identityRelation) { - return signaturesIdenticalTo(source, target, kind); - } - if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; - } - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var result = -1 /* True */; - var saveErrorInfo = errorInfo; - outer: for (var i = 0; i < targetSignatures.length; i++) { - var t = targetSignatures[i]; - if (!t.hasStringLiterals || target.flags & 65536 /* FromSignature */) { - var localErrors = reportErrors; - for (var j = 0; j < sourceSignatures.length; j++) { - var s = sourceSignatures[j]; - if (!s.hasStringLiterals || source.flags & 65536 /* FromSignature */) { - var related = signatureRelatedTo(s, t, localErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; - } - localErrors = false; - } - } - return 0 /* False */; - } - } - return result; - } - function signatureRelatedTo(source, target, reportErrors) { - if (source === target) { - return -1 /* True */; - } - if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return 0 /* False */; - } - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var checkCount; - if (source.hasRestParameter && target.hasRestParameter) { - checkCount = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - checkCount = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - checkCount = sourceMax; - } - else { - checkCount = sourceMax < targetMax ? sourceMax : targetMax; - } - source = getErasedSignature(source); - target = getErasedSignature(target); - var result = -1 /* True */; - for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - var saveErrorInfo = errorInfo; - var related = isRelatedTo(s, t, reportErrors); - if (!related) { - related = isRelatedTo(t, s, false); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); - } - return 0 /* False */; - } - errorInfo = saveErrorInfo; - } - result &= related; - } - var t = getReturnTypeOfSignature(target); - if (t === voidType) - return result; - var s = getReturnTypeOfSignature(source); - return result & isRelatedTo(s, t, reportErrors); - } - function signaturesIdenticalTo(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; - } - var result = -1 /* True */; - for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); - if (!related) { - return 0 /* False */; - } - result &= related; - } - return result; - } - function stringIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(0 /* String */, source, target); - } - var targetType = getIndexTypeOfType(target, 0 /* String */); - if (targetType) { - var sourceType = getIndexTypeOfType(source, 0 /* String */); - if (!sourceType) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; - } - var related = isRelatedTo(sourceType, targetType, reportErrors); - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; - } - return -1 /* True */; - } - function numberIndexTypesRelatedTo(source, target, reportErrors) { - if (relation === identityRelation) { - return indexTypesIdenticalTo(1 /* Number */, source, target); - } - var targetType = getIndexTypeOfType(target, 1 /* Number */); - if (targetType) { - var sourceStringType = getIndexTypeOfType(source, 0 /* String */); - var sourceNumberType = getIndexTypeOfType(source, 1 /* Number */); - if (!(sourceStringType || sourceNumberType)) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); - } - return 0 /* False */; - } - if (sourceStringType && sourceNumberType) { - var related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); - } - else { - var related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); - } - if (!related) { - if (reportErrors) { - reportError(ts.Diagnostics.Index_signatures_are_incompatible); - } - return 0 /* False */; - } - return related; - } - return -1 /* True */; - } - function indexTypesIdenticalTo(indexKind, source, target) { - var targetType = getIndexTypeOfType(target, indexKind); - var sourceType = getIndexTypeOfType(source, indexKind); - if (!sourceType && !targetType) { - return -1 /* True */; - } - if (sourceType && targetType) { - return isRelatedTo(sourceType, targetType); - } - return 0 /* False */; - } - } - function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; - } - function compareProperties(sourceProp, targetProp, compareTypes) { - if (sourceProp === targetProp) { - return -1 /* True */; - } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); - if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; - } - if (sourcePropAccessibility) { - if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; - } - } - else { - if (isOptionalProperty(sourceProp) !== isOptionalProperty(targetProp)) { - return 0 /* False */; - } - } - return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - function compareSignatures(source, target, compareReturnTypes, compareTypes) { - if (source === target) { - return -1 /* True */; - } - if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return 0 /* False */; - } - var result = -1 /* True */; - if (source.typeParameters && target.typeParameters) { - if (source.typeParameters.length !== target.typeParameters.length) { - return 0 /* False */; - } - for (var i = 0, len = source.typeParameters.length; i < len; ++i) { - var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); - if (!related) { - return 0 /* False */; - } - result &= related; - } - } - else if (source.typeParameters || source.typeParameters) { - return 0 /* False */; - } - source = getErasedSignature(source); - target = getErasedSignature(target); - for (var i = 0, len = source.parameters.length; i < len; i++) { - var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); - var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); - var related = compareTypes(s, t); - if (!related) { - return 0 /* False */; - } - result &= related; - } - if (compareReturnTypes) { - result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - return result; - } - function isSupertypeOfEach(candidate, types) { - for (var i = 0, len = types.length; i < len; i++) { - if (candidate !== types[i] && !isTypeSubtypeOf(types[i], candidate)) - return false; - } - return true; - } - function getCommonSupertype(types) { - return ts.forEach(types, function (t) { return isSupertypeOfEach(t, types) ? t : undefined; }); - } - function reportNoCommonSupertypeError(types, errorLocation, errorMessageChainHead) { - var bestSupertype; - var bestSupertypeDownfallType; - var bestSupertypeScore = 0; - for (var i = 0; i < types.length; i++) { - var score = 0; - var downfallType = undefined; - for (var j = 0; j < types.length; j++) { - if (isTypeSubtypeOf(types[j], types[i])) { - score++; - } - else if (!downfallType) { - downfallType = types[j]; - } - } - if (score > bestSupertypeScore) { - bestSupertype = types[i]; - bestSupertypeDownfallType = downfallType; - bestSupertypeScore = score; - } - if (bestSupertypeScore === types.length - 1) { - break; - } - } - checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); - } - function isTypeOfObjectLiteral(type) { - return (type.flags & 32768 /* Anonymous */) && type.symbol && (type.symbol.flags & 4096 /* ObjectLiteral */) ? true : false; - } - function isArrayType(type) { - return type.flags & 4096 /* Reference */ && type.target === globalArrayType; - } - function getInnermostTypeOfNestedArrayTypes(type) { - while (isArrayType(type)) { - type = type.typeArguments[0]; - } - return type; - } - function getWidenedType(type, suppressNoImplicitAnyErrors) { - if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { - return anyType; - } - if (type.flags & 16384 /* Union */) { - return getWidenedTypeOfUnion(type); - } - if (isTypeOfObjectLiteral(type)) { - return getWidenedTypeOfObjectLiteral(type); - } - if (isArrayType(type)) { - return getWidenedTypeOfArrayLiteral(type); - } - return type; - function getWidenedTypeOfUnion(type) { - return getUnionType(ts.map(type.types, function (t) { return getWidenedType(t, suppressNoImplicitAnyErrors); })); - } - function getWidenedTypeOfObjectLiteral(type) { - var properties = getPropertiesOfObjectType(type); - if (properties.length) { - var widenedTypes = []; - var propTypeWasWidened = false; - ts.forEach(properties, function (p) { - var propType = getTypeOfSymbol(p); - var widenedType = getWidenedType(propType); - if (propType !== widenedType) { - propTypeWasWidened = true; - if (!suppressNoImplicitAnyErrors && compilerOptions.noImplicitAny && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { - error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(widenedType)); - } - } - widenedTypes.push(widenedType); - }); - if (propTypeWasWidened) { - var members = {}; - var index = 0; - ts.forEach(properties, function (p) { - var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */ | p.flags, p.name); - symbol.declarations = p.declarations; - symbol.parent = p.parent; - symbol.type = widenedTypes[index++]; - symbol.target = p; - if (p.valueDeclaration) - symbol.valueDeclaration = p.valueDeclaration; - members[symbol.name] = symbol; - }); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType) - stringIndexType = getWidenedType(stringIndexType); - if (numberIndexType) - numberIndexType = getWidenedType(numberIndexType); - type = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); - } - } - return type; - } - function getWidenedTypeOfArrayLiteral(type) { - var elementType = type.typeArguments[0]; - var widenedType = getWidenedType(elementType, suppressNoImplicitAnyErrors); - type = elementType !== widenedType ? createArrayType(widenedType) : type; - return type; - } - } - function forEachMatchingParameterType(source, target, callback) { - var sourceMax = source.parameters.length; - var targetMax = target.parameters.length; - var count; - if (source.hasRestParameter && target.hasRestParameter) { - count = sourceMax > targetMax ? sourceMax : targetMax; - sourceMax--; - targetMax--; - } - else if (source.hasRestParameter) { - sourceMax--; - count = targetMax; - } - else if (target.hasRestParameter) { - targetMax--; - count = sourceMax; - } - else { - count = sourceMax < targetMax ? sourceMax : targetMax; - } - for (var i = 0; i < count; i++) { - var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); - callback(s, t); - } - } - function createInferenceContext(typeParameters, inferUnionTypes) { - var inferences = []; - for (var i = 0; i < typeParameters.length; i++) { - inferences.push({ primary: undefined, secondary: undefined }); - } - return { - typeParameters: typeParameters, - inferUnionTypes: inferUnionTypes, - inferenceCount: 0, - inferences: inferences, - inferredTypes: new Array(typeParameters.length) - }; - } - function inferTypes(context, source, target) { - var sourceStack; - var targetStack; - var depth = 0; - var inferiority = 0; - inferFromTypes(source, target); - function isInProcess(source, target) { - for (var i = 0; i < depth; i++) { - if (source === sourceStack[i] && target === targetStack[i]) - return true; - } - return false; - } - function isWithinDepthLimit(type, stack) { - if (depth >= 5) { - var target = type.target; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (t.flags & 4096 /* Reference */ && t.target === target) - count++; - } - return count < 5; - } - return true; - } - function inferFromTypes(source, target) { - if (target.flags & 512 /* TypeParameter */) { - var typeParameters = context.typeParameters; - for (var i = 0; i < typeParameters.length; i++) { - if (target === typeParameters[i]) { - var inferences = context.inferences[i]; - var candidates = inferiority ? inferences.secondary || (inferences.secondary = []) : inferences.primary || (inferences.primary = []); - if (!ts.contains(candidates, source)) - candidates.push(source); - break; - } - } - } - else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - var sourceTypes = source.typeArguments; - var targetTypes = target.typeArguments; - for (var i = 0; i < sourceTypes.length; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } - else if (target.flags & 16384 /* Union */) { - var targetTypes = target.types; - var typeParameterCount = 0; - var typeParameter; - for (var i = 0; i < targetTypes.length; i++) { - var t = targetTypes[i]; - if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { - typeParameter = t; - typeParameterCount++; - } - else { - inferFromTypes(source, t); - } - } - if (typeParameterCount === 1) { - inferiority++; - inferFromTypes(source, typeParameter); - inferiority--; - } - } - else if (source.flags & 16384 /* Union */) { - var sourceTypes = source.types; - for (var i = 0; i < sourceTypes.length; i++) { - inferFromTypes(sourceTypes[i], target); - } - } - else if (source.flags & 48128 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */))) { - if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { - if (depth === 0) { - sourceStack = []; - targetStack = []; - } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); - inferFromIndexTypes(source, target, 0 /* String */, 0 /* String */); - inferFromIndexTypes(source, target, 1 /* Number */, 1 /* Number */); - inferFromIndexTypes(source, target, 0 /* String */, 1 /* Number */); - depth--; - } - } - } - function inferFromProperties(source, target) { - var properties = getPropertiesOfObjectType(target); - for (var i = 0; i < properties.length; i++) { - var targetProp = properties[i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.name); - if (sourceProp) { - inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); - } - } - } - function inferFromSignatures(source, target, kind) { - var sourceSignatures = getSignaturesOfType(source, kind); - var targetSignatures = getSignaturesOfType(target, kind); - var sourceLen = sourceSignatures.length; - var targetLen = targetSignatures.length; - var len = sourceLen < targetLen ? sourceLen : targetLen; - for (var i = 0; i < len; i++) { - inferFromSignature(getErasedSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); - } - } - function inferFromSignature(source, target) { - forEachMatchingParameterType(source, target, inferFromTypes); - inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); - } - function inferFromIndexTypes(source, target, sourceKind, targetKind) { - var targetIndexType = getIndexTypeOfType(target, targetKind); - if (targetIndexType) { - var sourceIndexType = getIndexTypeOfType(source, sourceKind); - if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetIndexType); - } - } - } - } - function getInferenceCandidates(context, index) { - var inferences = context.inferences[index]; - return inferences.primary || inferences.secondary || emptyArray; - } - function getInferredType(context, index) { - var inferredType = context.inferredTypes[index]; - if (!inferredType) { - var inferences = getInferenceCandidates(context, index); - if (inferences.length) { - var unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences); - inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : inferenceFailureType; - } - else { - inferredType = emptyObjectType; - } - if (inferredType !== inferenceFailureType) { - var constraint = getConstraintOfTypeParameter(context.typeParameters[index]); - inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType; - } - context.inferredTypes[index] = inferredType; - } - return inferredType; - } - function getInferredTypes(context) { - for (var i = 0; i < context.inferredTypes.length; i++) { - getInferredType(context, i); - } - return context.inferredTypes; - } - function hasAncestor(node, kind) { - return ts.getAncestor(node, kind) !== undefined; - } - function getResolvedSymbol(node) { - var links = getNodeLinks(node); - if (!links.resolvedSymbol) { - links.resolvedSymbol = (ts.getFullWidth(node) > 0 && resolveName(node, node.text, 107455 /* Value */ | 4194304 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node)) || unknownSymbol; - } - return links.resolvedSymbol; - } - function isInTypeQuery(node) { - while (node) { - switch (node.kind) { - case 135 /* TypeQuery */: - return true; - case 63 /* Identifier */: - case 120 /* QualifiedName */: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); - } - function subtractPrimitiveTypes(type, subtractMask) { - if (type.flags & 16384 /* Union */) { - var types = type.types; - if (ts.forEach(types, function (t) { return t.flags & subtractMask; })) { - return getUnionType(ts.filter(types, function (t) { return !(t.flags & subtractMask); })); - } - } - return type; - } - function isVariableAssignedWithin(symbol, node) { - var links = getNodeLinks(node); - if (links.assignmentChecks) { - var cachedResult = links.assignmentChecks[symbol.id]; - if (cachedResult !== undefined) { - return cachedResult; - } - } - else { - links.assignmentChecks = {}; - } - return links.assignmentChecks[symbol.id] = isAssignedIn(node); - function isAssignedInBinaryExpression(node) { - if (node.operator >= 51 /* FirstAssignment */ && node.operator <= 62 /* LastAssignment */) { - var n = node.left; - while (n.kind === 149 /* ParenthesizedExpression */) { - n = n.expression; - } - if (n.kind === 63 /* Identifier */ && getResolvedSymbol(n) === symbol) { - return true; - } - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedInVariableDeclaration(node) { - if (getSymbolOfNode(node) === symbol && node.initializer) { - return true; - } - return ts.forEachChild(node, isAssignedIn); - } - function isAssignedIn(node) { - switch (node.kind) { - case 157 /* BinaryExpression */: - return isAssignedInBinaryExpression(node); - case 183 /* VariableDeclaration */: - return isAssignedInVariableDeclaration(node); - case 141 /* ArrayLiteralExpression */: - case 142 /* ObjectLiteralExpression */: - case 143 /* PropertyAccessExpression */: - case 144 /* ElementAccessExpression */: - case 145 /* CallExpression */: - case 146 /* NewExpression */: - case 148 /* TypeAssertionExpression */: - case 149 /* ParenthesizedExpression */: - case 155 /* PrefixUnaryExpression */: - case 152 /* DeleteExpression */: - case 153 /* TypeOfExpression */: - case 154 /* VoidExpression */: - case 156 /* PostfixUnaryExpression */: - case 158 /* ConditionalExpression */: - case 163 /* Block */: - case 164 /* VariableStatement */: - case 166 /* ExpressionStatement */: - case 167 /* IfStatement */: - case 168 /* DoStatement */: - case 169 /* WhileStatement */: - case 170 /* ForStatement */: - case 171 /* ForInStatement */: - case 174 /* ReturnStatement */: - case 175 /* WithStatement */: - case 176 /* SwitchStatement */: - case 194 /* CaseClause */: - case 195 /* DefaultClause */: - case 177 /* LabeledStatement */: - case 178 /* ThrowStatement */: - case 179 /* TryStatement */: - case 180 /* TryBlock */: - case 197 /* CatchClause */: - case 181 /* FinallyBlock */: - return ts.forEachChild(node, isAssignedIn); - } - return false; - } - } - function resolveLocation(node) { - var containerNodes = []; - for (var parent = node.parent; parent; parent = parent.parent) { - if ((ts.isExpression(parent) || ts.isObjectLiteralMethod(node)) && isContextSensitive(parent)) { - containerNodes.unshift(parent); - } - } - ts.forEach(containerNodes, function (node) { - getTypeOfNode(node); - }); - } - function getSymbolAtLocation(node) { - resolveLocation(node); - return getSymbolInfo(node); - } - function getTypeAtLocation(node) { - resolveLocation(node); - return getTypeOfNode(node); - } - function getTypeOfSymbolAtLocation(symbol, node) { - resolveLocation(node); - return getNarrowedTypeOfSymbol(symbol, node); - } - function getNarrowedTypeOfSymbol(symbol, node) { - var type = getTypeOfSymbol(symbol); - if (node && symbol.flags & 3 /* Variable */ && type.flags & (48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { - loop: while (node.parent) { - var child = node; - node = node.parent; - var narrowedType = type; - switch (node.kind) { - case 167 /* IfStatement */: - if (child !== node.expression) { - narrowedType = narrowType(type, node.expression, child === node.thenStatement); - } - break; - case 158 /* ConditionalExpression */: - if (child !== node.condition) { - narrowedType = narrowType(type, node.condition, child === node.whenTrue); - } - break; - case 157 /* BinaryExpression */: - if (child === node.right) { - if (node.operator === 47 /* AmpersandAmpersandToken */) { - narrowedType = narrowType(type, node.left, true); - } - else if (node.operator === 48 /* BarBarToken */) { - narrowedType = narrowType(type, node.left, false); - } - } - break; - case 201 /* SourceFile */: - case 189 /* ModuleDeclaration */: - case 184 /* FunctionDeclaration */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 126 /* Constructor */: - break loop; - } - if (narrowedType !== type && isTypeSubtypeOf(narrowedType, type)) { - if (isVariableAssignedWithin(symbol, node)) { - break; - } - type = narrowedType; - } - } - } - return type; - function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 153 /* TypeOfExpression */ || expr.right.kind !== 7 /* StringLiteral */) { - return type; - } - var left = expr.left; - var right = expr.right; - if (left.expression.kind !== 63 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { - return type; - } - var t = right.text; - var checkType = t === "string" ? stringType : t === "number" ? numberType : t === "boolean" ? booleanType : emptyObjectType; - if (expr.operator === 30 /* ExclamationEqualsEqualsToken */) { - assumeTrue = !assumeTrue; - } - if (assumeTrue) { - return checkType === emptyObjectType ? subtractPrimitiveTypes(type, 2 /* String */ | 4 /* Number */ | 8 /* Boolean */) : checkType; - } - else { - return checkType === emptyObjectType ? type : subtractPrimitiveTypes(type, checkType.flags); - } - } - function narrowTypeByAnd(type, expr, assumeTrue) { - if (assumeTrue) { - return narrowType(narrowType(type, expr.left, true), expr.right, true); - } - else { - return getUnionType([ - narrowType(type, expr.left, false), - narrowType(narrowType(type, expr.left, true), expr.right, false) - ]); - } - } - function narrowTypeByOr(type, expr, assumeTrue) { - if (assumeTrue) { - return getUnionType([ - narrowType(type, expr.left, true), - narrowType(narrowType(type, expr.left, false), expr.right, true) - ]); - } - else { - return narrowType(narrowType(type, expr.left, false), expr.right, false); - } - } - function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (!assumeTrue || expr.left.kind !== 63 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { - return type; - } - var rightType = checkExpression(expr.right); - if (!isTypeSubtypeOf(rightType, globalFunctionType)) { - return type; - } - var prototypeProperty = getPropertyOfType(rightType, "prototype"); - if (!prototypeProperty) { - return type; - } - var prototypeType = getTypeOfSymbol(prototypeProperty); - return isTypeSubtypeOf(prototypeType, type) ? prototypeType : type; - } - function narrowType(type, expr, assumeTrue) { - switch (expr.kind) { - case 149 /* ParenthesizedExpression */: - return narrowType(type, expr.expression, assumeTrue); - case 157 /* BinaryExpression */: - var operator = expr.operator; - if (operator === 29 /* EqualsEqualsEqualsToken */ || operator === 30 /* ExclamationEqualsEqualsToken */) { - return narrowTypeByEquality(type, expr, assumeTrue); - } - else if (operator === 47 /* AmpersandAmpersandToken */) { - return narrowTypeByAnd(type, expr, assumeTrue); - } - else if (operator === 48 /* BarBarToken */) { - return narrowTypeByOr(type, expr, assumeTrue); - } - else if (operator === 85 /* InstanceOfKeyword */) { - return narrowTypeByInstanceof(type, expr, assumeTrue); - } - break; - case 155 /* PrefixUnaryExpression */: - if (expr.operator === 45 /* ExclamationToken */) { - return narrowType(type, expr.operand, !assumeTrue); - } - break; - } - return type; - } - } - function checkIdentifier(node) { - var symbol = getResolvedSymbol(node); - if (symbol.flags & 33554432 /* Import */) { - getSymbolLinks(symbol).referenced = getSymbolLinks(symbol).referenced || (!isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol))); - } - checkCollisionWithCapturedSuperVariable(node, node); - checkCollisionWithCapturedThisVariable(node, node); - checkCollisionWithIndexVariableInGeneratedCode(node, node); - return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); - } - function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 185 /* ClassDeclaration */ ? container.parent : undefined; - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */) { - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; - } - else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; - } - } - function checkThisExpression(node) { - var container = ts.getThisContainer(node, true); - var needToCaptureLexicalThis = false; - if (container.kind === 151 /* ArrowFunction */) { - container = ts.getThisContainer(container, false); - needToCaptureLexicalThis = true; - } - switch (container.kind) { - case 189 /* ModuleDeclaration */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); - break; - case 188 /* EnumDeclaration */: - error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - break; - case 126 /* Constructor */: - if (isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); - } - break; - case 124 /* Property */: - if (container.flags & 128 /* Static */) { - error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); - } - break; - } - if (needToCaptureLexicalThis) { - captureLexicalThis(node, container); - } - var classNode = container.parent && container.parent.kind === 185 /* ClassDeclaration */ ? container.parent : undefined; - if (classNode) { - var symbol = getSymbolOfNode(classNode); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); - } - return anyType; - } - function getSuperContainer(node) { - while (true) { - node = node.parent; - if (!node) - return node; - switch (node.kind) { - case 184 /* FunctionDeclaration */: - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - case 124 /* Property */: - case 125 /* Method */: - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - return node; - } - } - } - function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 123 /* Parameter */) { - return true; - } - } - return false; - } - function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 145 /* CallExpression */ && node.parent.expression === node; - var enclosingClass = ts.getAncestor(node, 185 /* ClassDeclaration */); - var baseClass; - if (enclosingClass && ts.getClassBaseTypeNode(enclosingClass)) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); - baseClass = classType.baseTypes.length && classType.baseTypes[0]; - } - if (!baseClass) { - error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - return unknownType; - } - var container = getSuperContainer(node); - if (container) { - var canUseSuperExpression = false; - if (isCallExpression) { - canUseSuperExpression = container.kind === 126 /* Constructor */; - } - else { - var needToCaptureLexicalThis = false; - while (container && container.kind === 151 /* ArrowFunction */) { - container = getSuperContainer(container); - needToCaptureLexicalThis = true; - } - if (container && container.parent && container.parent.kind === 185 /* ClassDeclaration */) { - if (container.flags & 128 /* Static */) { - canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */; - } - else { - canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */ || container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */; - } - } - } - if (canUseSuperExpression) { - var returnType; - if ((container.flags & 128 /* Static */) || isCallExpression) { - getNodeLinks(node).flags |= 32 /* SuperStatic */; - returnType = getTypeOfSymbol(baseClass.symbol); - } - else { - getNodeLinks(node).flags |= 16 /* SuperInstance */; - returnType = baseClass; - } - if (container.kind === 126 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { - error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - returnType = unknownType; - } - if (!isCallExpression && needToCaptureLexicalThis) { - captureLexicalThis(node.parent, container); - } - return returnType; - } - } - if (isCallExpression) { - error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); - } - else { - error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); - } - return unknownType; - } - function getContextuallyTypedParameterType(parameter) { - if (isFunctionExpressionOrArrowFunction(parameter.parent)) { - var func = parameter.parent; - if (isContextSensitive(func)) { - var contextualSignature = getContextualSignature(func); - if (contextualSignature) { - var funcHasRestParameters = ts.hasRestParameters(func); - var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); - var indexOfParameter = ts.indexOf(func.parameters, parameter); - if (indexOfParameter < len) { - return getTypeAtPosition(contextualSignature, indexOfParameter); - } - if (indexOfParameter === (func.parameters.length - 1) && funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) { - return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]); - } - } - } - } - return undefined; - } - function getContextualTypeForInitializerExpression(node) { - var declaration = node.parent; - if (node === declaration.initializer) { - if (declaration.type) { - return getTypeFromTypeNode(declaration.type); - } - if (declaration.kind === 123 /* Parameter */) { - return getContextuallyTypedParameterType(declaration); - } - } - return undefined; - } - function getContextualTypeForReturnExpression(node) { - var func = ts.getContainingFunction(node); - if (func) { - if (func.type || func.kind === 126 /* Constructor */ || func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))) { - return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); - } - var signature = getContextualSignatureForFunctionLikeDeclaration(func); - if (signature) { - return getReturnTypeOfSignature(signature); - } - } - return undefined; - } - function getContextualTypeForArgument(callTarget, arg) { - var args = getEffectiveCallArguments(callTarget); - var argIndex = ts.indexOf(args, arg); - if (argIndex >= 0) { - var signature = getResolvedSignature(callTarget); - return getTypeAtPosition(signature, argIndex); - } - return undefined; - } - function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 147 /* TaggedTemplateExpression */) { - return getContextualTypeForArgument(template.parent, substitutionExpression); - } - return undefined; - } - function getContextualTypeForBinaryOperand(node) { - var binaryExpression = node.parent; - var operator = binaryExpression.operator; - if (operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { - if (node === binaryExpression.right) { - return checkExpression(binaryExpression.left); - } - } - else if (operator === 48 /* BarBarToken */) { - var type = getContextualType(binaryExpression); - if (!type && node === binaryExpression.right) { - type = checkExpression(binaryExpression.left); - } - return type; - } - return undefined; - } - function applyToContextualType(type, mapper) { - if (!(type.flags & 16384 /* Union */)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var i = 0; i < types.length; i++) { - var t = mapper(types[i]); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } - function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { - var prop = getPropertyOfObjectType(t, name); - return prop ? getTypeOfSymbol(prop) : undefined; - }); - } - function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); - } - function contextualTypeIsTupleType(type) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getPropertyOfObjectType(t, "0"); }) : getPropertyOfObjectType(type, "0")); - } - function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); - } - function getContextualTypeForObjectLiteralMethod(node) { - ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (isInsideWithStatementBody(node)) { - return undefined; - } - return getContextualTypeForObjectLiteralElement(node); - } - function getContextualTypeForObjectLiteralElement(element) { - var objectLiteral = element.parent; - var type = getContextualType(objectLiteral); - var name = element.name.text; - if (type && name) { - return getTypeOfPropertyOfContextualType(type, name) || isNumericName(name) && getIndexTypeOfContextualType(type, 1 /* Number */) || getIndexTypeOfContextualType(type, 0 /* String */); - } - return undefined; - } - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */); - } - return undefined; - } - function getContextualTypeForConditionalOperand(node) { - var conditional = node.parent; - return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; - } - function getContextualType(node) { - if (isInsideWithStatementBody(node)) { - return undefined; - } - if (node.contextualType) { - return node.contextualType; - } - var parent = node.parent; - switch (parent.kind) { - case 183 /* VariableDeclaration */: - case 123 /* Parameter */: - case 124 /* Property */: - return getContextualTypeForInitializerExpression(node); - case 151 /* ArrowFunction */: - case 174 /* ReturnStatement */: - return getContextualTypeForReturnExpression(node); - case 145 /* CallExpression */: - case 146 /* NewExpression */: - return getContextualTypeForArgument(parent, node); - case 148 /* TypeAssertionExpression */: - return getTypeFromTypeNode(parent.type); - case 157 /* BinaryExpression */: - return getContextualTypeForBinaryOperand(node); - case 198 /* PropertyAssignment */: - return getContextualTypeForObjectLiteralElement(parent); - case 141 /* ArrayLiteralExpression */: - return getContextualTypeForElementExpression(node); - case 158 /* ConditionalExpression */: - return getContextualTypeForConditionalOperand(node); - case 162 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 159 /* TemplateExpression */); - return getContextualTypeForSubstitutionExpression(parent.parent, node); - } - return undefined; - } - function getNonGenericSignature(type) { - var signatures = getSignaturesOfObjectOrUnionType(type, 0 /* Call */); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!signature.typeParameters) { - return signature; - } - } - } - function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 150 /* FunctionExpression */ || node.kind === 151 /* ArrowFunction */; - } - function getContextualSignatureForFunctionLikeDeclaration(node) { - return isFunctionExpressionOrArrowFunction(node) ? getContextualSignature(node) : undefined; - } - function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); - var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); - if (!type) { - return undefined; - } - if (!(type.flags & 16384 /* Union */)) { - return getNonGenericSignature(type); - } - var signatureList; - var types = type.types; - for (var i = 0; i < types.length; i++) { - if (signatureList && getSignaturesOfObjectOrUnionType(types[i], 0 /* Call */).length > 1) { - return undefined; - } - var signature = getNonGenericSignature(types[i]); - if (signature) { - if (!signatureList) { - signatureList = [signature]; - } - else if (!compareSignatures(signatureList[0], signature, false, compareTypes)) { - return undefined; - } - else { - signatureList.push(signature); - } - } - } - var result; - if (signatureList) { - result = cloneSignature(signatureList[0]); - result.resolvedReturnType = undefined; - result.unionSignatures = signatureList; - } - return result; - } - function isInferentialContext(mapper) { - return mapper && mapper !== identityMapper; - } - function checkArrayLiteral(node, contextualMapper) { - var elements = node.elements; - if (!elements.length) { - return createArrayType(undefinedType); - } - var elementTypes = ts.map(elements, function (e) { return checkExpression(e, contextualMapper); }); - var contextualType = getContextualType(node); - if (contextualType && contextualTypeIsTupleType(contextualType)) { - return createTupleType(elementTypes); - } - return createArrayType(getUnionType(elementTypes)); - } - function isNumericName(name) { - return (+name).toString() === name; - } - function checkObjectLiteral(node, contextualMapper) { - var members = node.symbol.members; - var properties = {}; - var contextualType = getContextualType(node); - for (var id in members) { - if (ts.hasProperty(members, id)) { - var member = members[id]; - if (member.flags & 4 /* Property */ || ts.isObjectLiteralMethod(member.declarations[0])) { - var memberDecl = member.declarations[0]; - var type; - if (memberDecl.kind === 198 /* PropertyAssignment */) { - type = checkExpression(memberDecl.initializer, contextualMapper); - } - else if (memberDecl.kind === 125 /* Method */) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); - } - else { - ts.Debug.assert(memberDecl.kind === 199 /* ShorthandPropertyAssignment */); - type = memberDecl.name.kind === 121 /* ComputedPropertyName */ ? unknownType : checkExpression(memberDecl.name, contextualMapper); - } - var prop = createSymbol(4 /* Property */ | 268435456 /* Transient */ | member.flags, member.name); - prop.declarations = member.declarations; - prop.parent = member.parent; - if (member.valueDeclaration) { - prop.valueDeclaration = member.valueDeclaration; - } - prop.type = type; - prop.target = member; - member = prop; - } - else { - var getAccessor = ts.getDeclarationOfKind(member, 127 /* GetAccessor */); - if (getAccessor) { - checkAccessorDeclaration(getAccessor); - } - var setAccessor = ts.getDeclarationOfKind(member, 128 /* SetAccessor */); - if (setAccessor) { - checkAccessorDeclaration(setAccessor); - } - } - properties[member.name] = member; - } - } - var stringIndexType = getIndexType(0 /* String */); - var numberIndexType = getIndexType(1 /* Number */); - return createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType); - function getIndexType(kind) { - if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { - var propTypes = []; - for (var id in properties) { - if (ts.hasProperty(properties, id)) { - if (kind === 0 /* String */ || isNumericName(id)) { - var type = getTypeOfSymbol(properties[id]); - if (!ts.contains(propTypes, type)) { - propTypes.push(type); - } - } - } - } - return propTypes.length ? getUnionType(propTypes) : undefinedType; - } - return undefined; - } - } - function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 124 /* Property */; - } - function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 536870912 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; - } - function checkClassPropertyAccess(node, left, type, prop) { - var flags = getDeclarationFlagsFromSymbol(prop); - if (!(flags & (32 /* Private */ | 64 /* Protected */))) { - return; - } - var enclosingClassDeclaration = ts.getAncestor(node, 185 /* ClassDeclaration */); - var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); - if (flags & 32 /* Private */) { - if (declaringClass !== enclosingClass) { - error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); - } - return; - } - if (left.kind === 89 /* SuperKeyword */) { - return; - } - if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return; - } - if (flags & 128 /* Static */) { - return; - } - if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && hasBaseType(type, enclosingClass))) { - error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); - } - } - function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); - } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); - } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var type = checkExpressionOrQualifiedName(left); - if (type === unknownType) - return type; - if (type !== anyType) { - var apparentType = getApparentType(getWidenedType(type)); - if (apparentType === unknownType) { - return unknownType; - } - var prop = getPropertyOfType(apparentType, right.text); - if (!prop) { - if (right.text) { - error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(right), typeToString(type)); - } - return unknownType; - } - getNodeLinks(node).resolvedSymbol = prop; - if (prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { - error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - } - else { - checkClassPropertyAccess(node, left, type, prop); - } - } - return getTypeOfSymbol(prop); - } - return anyType; - } - function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 143 /* PropertyAccessExpression */ ? node.expression : node.left; - var type = checkExpressionOrQualifiedName(left); - if (type !== unknownType && type !== anyType) { - var prop = getPropertyOfType(getWidenedType(type), propertyName); - if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { - return false; - } - else { - var diagnosticsCount = diagnostics.length; - checkClassPropertyAccess(node, left, type, prop); - return diagnostics.length === diagnosticsCount; - } - } - } - return true; - } - function checkIndexedAccess(node) { - var objectType = getApparentType(checkExpression(node.expression)); - var indexType = node.argumentExpression ? checkExpression(node.argumentExpression) : unknownType; - if (objectType === unknownType) { - return unknownType; - } - if (isConstEnumObjectType(objectType) && node.argumentExpression && node.argumentExpression.kind !== 7 /* StringLiteral */) { - error(node.argumentExpression, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); - } - if (node.argumentExpression) { - if (node.argumentExpression.kind === 7 /* StringLiteral */ || node.argumentExpression.kind === 6 /* NumericLiteral */) { - var name = node.argumentExpression.text; - var prop = getPropertyOfType(objectType, name); - if (prop) { - getNodeLinks(node).resolvedSymbol = prop; - return getTypeOfSymbol(prop); - } - } - } - if (indexType.flags & (1 /* Any */ | 258 /* StringLike */ | 132 /* NumberLike */)) { - if (indexType.flags & (1 /* Any */ | 132 /* NumberLike */)) { - var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); - if (numberIndexType) { - return numberIndexType; - } - } - var stringIndexType = getIndexTypeOfType(objectType, 0 /* String */); - if (stringIndexType) { - return stringIndexType; - } - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && objectType !== anyType) { - error(node, ts.Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type); - } - return anyType; - } - error(node, ts.Diagnostics.An_index_expression_argument_must_be_of_type_string_number_or_any); - return unknownType; - } - function resolveUntypedCall(node) { - if (node.kind === 147 /* TaggedTemplateExpression */) { - checkExpression(node.template); - } - else { - ts.forEach(node.arguments, function (argument) { - checkExpression(argument); - }); - } - return anySignature; - } - function resolveErrorCall(node) { - resolveUntypedCall(node); - return unknownSignature; - } - function hasCorrectArity(node, args, signature) { - var adjustedArgCount; - var typeArguments; - var callIsIncomplete; - if (node.kind === 147 /* TaggedTemplateExpression */) { - var tagExpression = node; - adjustedArgCount = args.length; - typeArguments = undefined; - if (tagExpression.template.kind === 159 /* TemplateExpression */) { - var templateExpression = tagExpression.template; - var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); - ts.Debug.assert(lastSpan !== undefined); - callIsIncomplete = ts.getFullWidth(lastSpan.literal) === 0 || !!lastSpan.literal.isUnterminated; - } - else { - var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 9 /* NoSubstitutionTemplateLiteral */); - callIsIncomplete = !!templateLiteral.isUnterminated; - } - } - else { - var callExpression = node; - if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 146 /* NewExpression */); - return signature.minArgumentCount === 0; - } - adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; - callIsIncomplete = callExpression.arguments.end === callExpression.end; - typeArguments = callExpression.typeArguments; - } - ts.Debug.assert(adjustedArgCount !== undefined, "'adjustedArgCount' undefined"); - ts.Debug.assert(callIsIncomplete !== undefined, "'callIsIncomplete' undefined"); - return checkArity(adjustedArgCount, typeArguments, callIsIncomplete, signature); - function checkArity(adjustedArgCount, typeArguments, callIsIncomplete, signature) { - if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) { - return false; - } - var hasRightNumberOfTypeArgs = !typeArguments || (signature.typeParameters && typeArguments.length === signature.typeParameters.length); - if (!hasRightNumberOfTypeArgs) { - return false; - } - var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount; - return callIsIncomplete || hasEnoughArguments; - } - } - function getSingleCallSignature(type) { - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); - if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { - return resolved.callSignatures[0]; - } - } - return undefined; - } - function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature.typeParameters, true); - forEachMatchingParameterType(contextualSignature, signature, function (source, target) { - inferTypes(context, instantiateType(source, contextualMapper), target); - }); - return getSignatureInstantiation(signature, getInferredTypes(context)); - } - function inferTypeArguments(signature, args, excludeArgument) { - var typeParameters = signature.typeParameters; - var context = createInferenceContext(typeParameters, false); - var mapper = createInferenceMapper(context); - for (var i = 0; i < args.length; i++) { - if (args[i].kind === 161 /* OmittedExpression */) { - continue; - } - if (!excludeArgument || excludeArgument[i] === undefined) { - var parameterType = getTypeAtPosition(signature, i); - if (i === 0 && args[i].parent.kind === 147 /* TaggedTemplateExpression */) { - inferTypes(context, globalTemplateStringsArrayType, parameterType); - continue; - } - inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType); - } - } - if (excludeArgument) { - for (var i = 0; i < args.length; i++) { - if (args[i].kind === 161 /* OmittedExpression */) { - continue; - } - if (excludeArgument[i] === false) { - var parameterType = getTypeAtPosition(signature, i); - inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType); - } - } - } - var inferredTypes = getInferredTypes(context); - context.failedTypeParameterIndex = ts.indexOf(inferredTypes, inferenceFailureType); - for (var i = 0; i < inferredTypes.length; i++) { - if (inferredTypes[i] === inferenceFailureType) { - inferredTypes[i] = unknownType; - } - } - return context; - } - function checkTypeArguments(signature, typeArguments, typeArgumentResultTypes, reportErrors) { - var typeParameters = signature.typeParameters; - var typeArgumentsAreAssignable = true; - for (var i = 0; i < typeParameters.length; i++) { - var typeArgNode = typeArguments[i]; - var typeArgument = getTypeFromTypeNode(typeArgNode); - typeArgumentResultTypes[i] = typeArgument; - if (typeArgumentsAreAssignable) { - var constraint = getConstraintOfTypeParameter(typeParameters[i]); - if (constraint) { - typeArgumentsAreAssignable = checkTypeAssignableTo(typeArgument, constraint, reportErrors ? typeArgNode : undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } - } - } - return typeArgumentsAreAssignable; - } - function checkApplicableSignature(node, args, signature, relation, excludeArgument, reportErrors) { - for (var i = 0; i < args.length; i++) { - var arg = args[i]; - var argType; - if (arg.kind === 161 /* OmittedExpression */) { - continue; - } - var paramType = getTypeAtPosition(signature, i); - if (i === 0 && node.kind === 147 /* TaggedTemplateExpression */) { - argType = globalTemplateStringsArrayType; - } - else { - argType = arg.kind === 7 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); - } - var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1); - if (!isValidArgument) { - return false; - } - } - return true; - } - function getEffectiveCallArguments(node) { - var args; - if (node.kind === 147 /* TaggedTemplateExpression */) { - var template = node.template; - args = [template]; - if (template.kind === 159 /* TemplateExpression */) { - ts.forEach(template.templateSpans, function (span) { - args.push(span.expression); - }); - } - } - else { - args = node.arguments || emptyArray; - } - return args; - } - function resolveCall(node, signatures, candidatesOutArray) { - var isTaggedTemplate = node.kind === 147 /* TaggedTemplateExpression */; - var typeArguments = isTaggedTemplate ? undefined : node.typeArguments; - ts.forEach(typeArguments, checkSourceElement); - var candidates = candidatesOutArray || []; - collectCandidates(); - if (!candidates.length) { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - return resolveErrorCall(node); - } - var args = getEffectiveCallArguments(node); - var excludeArgument; - for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) { - if (isContextSensitive(args[i])) { - if (!excludeArgument) { - excludeArgument = new Array(args.length); - } - excludeArgument[i] = true; - } - } - var candidateForArgumentError; - var candidateForTypeArgumentError; - var resultOfFailedInference; - var result; - if (candidates.length > 1) { - result = chooseOverload(candidates, subtypeRelation); - } - if (!result) { - candidateForArgumentError = undefined; - candidateForTypeArgumentError = undefined; - resultOfFailedInference = undefined; - result = chooseOverload(candidates, assignableRelation); - } - if (result) { - return result; - } - if (candidateForArgumentError) { - checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, undefined, true); - } - else if (candidateForTypeArgumentError) { - if (!isTaggedTemplate && node.typeArguments) { - checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], true); - } - else { - ts.Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0); - var failedTypeParameter = candidateForTypeArgumentError.typeParameters[resultOfFailedInference.failedTypeParameterIndex]; - var inferenceCandidates = getInferenceCandidates(resultOfFailedInference, resultOfFailedInference.failedTypeParameterIndex); - var diagnosticChainHead = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - reportNoCommonSupertypeError(inferenceCandidates, node.expression || node.tag, diagnosticChainHead); - } - } - else { - error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); - } - if (!fullTypeCheck) { - for (var i = 0, n = candidates.length; i < n; i++) { - if (hasCorrectArity(node, args, candidates[i])) { - return candidates[i]; - } - } - } - return resolveErrorCall(node); - function chooseOverload(candidates, relation) { - for (var i = 0; i < candidates.length; i++) { - if (!hasCorrectArity(node, args, candidates[i])) { - continue; - } - var originalCandidate = candidates[i]; - var inferenceResult; - while (true) { - var candidate = originalCandidate; - if (candidate.typeParameters) { - var typeArgumentTypes; - var typeArgumentsAreValid; - if (typeArguments) { - typeArgumentTypes = new Array(candidate.typeParameters.length); - typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false); - } - else { - inferenceResult = inferTypeArguments(candidate, args, excludeArgument); - typeArgumentsAreValid = inferenceResult.failedTypeParameterIndex < 0; - typeArgumentTypes = inferenceResult.inferredTypes; - } - if (!typeArgumentsAreValid) { - break; - } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); - } - if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { - break; - } - var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; - if (index < 0) { - return candidate; - } - excludeArgument[index] = false; - } - if (originalCandidate.typeParameters) { - var instantiatedCandidate = candidate; - if (typeArgumentsAreValid) { - candidateForArgumentError = instantiatedCandidate; - } - else { - candidateForTypeArgumentError = originalCandidate; - if (!typeArguments) { - resultOfFailedInference = inferenceResult; - } - } - } - else { - ts.Debug.assert(originalCandidate === candidate); - candidateForArgumentError = originalCandidate; - } - } - return undefined; - } - function collectCandidates() { - var result = candidates; - var lastParent; - var lastSymbol; - var cutoffPos = 0; - var pos; - ts.Debug.assert(!result.length); - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent === lastParent) { - pos++; - } - else { - lastParent = parent; - pos = cutoffPos; - } - } - else { - pos = cutoffPos = result.length; - lastParent = parent; - } - lastSymbol = symbol; - for (var j = result.length; j > pos; j--) { - result[j] = result[j - 1]; - } - result[pos] = signature; - } - } - } - function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 89 /* SuperKeyword */) { - var superType = checkSuperExpression(node.expression); - if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); - } - return resolveUntypedCall(node); - } - var funcType = checkExpression(node.expression); - var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var constructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */); - if (funcType === anyType || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & 16384 /* Union */) && isTypeAssignableTo(funcType, globalFunctionType))) { - if (node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - if (!callSignatures.length) { - if (constructSignatures.length) { - error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); - } - else { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - } - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - function resolveNewExpression(node, candidatesOutArray) { - var expressionType = checkExpression(node.expression); - if (expressionType === anyType) { - if (node.typeArguments) { - error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); - } - return resolveUntypedCall(node); - } - expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { - return resolveErrorCall(node); - } - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); - if (constructSignatures.length) { - return resolveCall(node, constructSignatures, candidatesOutArray); - } - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); - if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray); - if (getReturnTypeOfSignature(signature) !== voidType) { - error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); - } - return signature; - } - error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); - return resolveErrorCall(node); - } - function resolveTaggedTemplateExpression(node, candidatesOutArray) { - var tagType = checkExpression(node.tag); - var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { - return resolveErrorCall(node); - } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - if (tagType === anyType || (!callSignatures.length && !(tagType.flags & 16384 /* Union */) && isTypeAssignableTo(tagType, globalFunctionType))) { - return resolveUntypedCall(node); - } - if (!callSignatures.length) { - error(node, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); - return resolveErrorCall(node); - } - return resolveCall(node, callSignatures, candidatesOutArray); - } - function getResolvedSignature(node, candidatesOutArray) { - var links = getNodeLinks(node); - if (!links.resolvedSignature || candidatesOutArray) { - links.resolvedSignature = anySignature; - if (node.kind === 145 /* CallExpression */) { - links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); - } - else if (node.kind === 146 /* NewExpression */) { - links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); - } - else if (node.kind === 147 /* TaggedTemplateExpression */) { - links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); - } - else { - ts.Debug.fail("Branch in 'getResolvedSignature' should be unreachable."); - } - } - return links.resolvedSignature; - } - function checkCallExpression(node) { - var signature = getResolvedSignature(node); - if (node.expression.kind === 89 /* SuperKeyword */) { - return voidType; - } - if (node.kind === 146 /* NewExpression */) { - var declaration = signature.declaration; - if (declaration && declaration.kind !== 126 /* Constructor */ && declaration.kind !== 130 /* ConstructSignature */ && declaration.kind !== 134 /* ConstructorType */) { - if (compilerOptions.noImplicitAny) { - error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); - } - return anyType; - } - } - return getReturnTypeOfSignature(signature); - } - function checkTaggedTemplateExpression(node) { - return getReturnTypeOfSignature(getResolvedSignature(node)); - } - function checkTypeAssertion(node) { - var exprType = checkExpression(node.expression); - var targetType = getTypeFromTypeNode(node.type); - if (fullTypeCheck && targetType !== unknownType) { - var widenedType = getWidenedType(exprType, true); - if (!(isTypeAssignableTo(targetType, widenedType))) { - checkTypeAssignableTo(exprType, targetType, node, ts.Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other); - } - } - return targetType; - } - function getTypeAtPosition(signature, pos) { - return signature.hasRestParameter ? pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) : pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType; - } - function assignContextualParameterTypes(signature, context, mapper) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - for (var i = 0; i < len; i++) { - var parameter = signature.parameters[i]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeAtPosition(context, i), mapper); - } - if (signature.hasRestParameter && context.hasRestParameter && signature.parameters.length >= context.parameters.length) { - var parameter = signature.parameters[signature.parameters.length - 1]; - var links = getSymbolLinks(parameter); - links.type = instantiateType(getTypeOfSymbol(context.parameters[context.parameters.length - 1]), mapper); - } - } - function getReturnTypeFromBody(func, contextualMapper) { - var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); - if (func.body.kind !== 163 /* Block */) { - var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); - var widenedType = getWidenedType(unwidenedType); - if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { - error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeToString(widenedType)); - } - return widenedType; - } - var types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); - if (types.length > 0) { - var commonType = contextualSignature ? getUnionType(types) : getCommonSupertype(types); - if (!commonType) { - error(func, ts.Diagnostics.No_best_common_type_exists_among_return_expressions); - return unknownType; - } - var widenedType = getWidenedType(commonType); - if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== commonType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { - var typeName = typeToString(widenedType); - if (func.name) { - error(func, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.declarationNameToString(func.name), typeName); - } - else { - error(func, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeName); - } - } - return widenedType; - } - return voidType; - } - function checkAndAggregateReturnExpressionTypes(body, contextualMapper) { - var aggregatedTypes = []; - ts.forEachReturnStatement(body, function (returnStatement) { - var expr = returnStatement.expression; - if (expr) { - var type = checkAndMarkExpression(expr, contextualMapper); - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } - } - }); - return aggregatedTypes; - } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 178 /* ThrowStatement */); - } - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { - if (!fullTypeCheck) { - return; - } - if (returnType === voidType || returnType === anyType) { - return; - } - if (!func.body || func.body.kind !== 163 /* Block */) { - return; - } - var bodyBlock = func.body; - if (bodyContainsAReturnStatement(bodyBlock)) { - return; - } - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; - } - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); - } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); - if (contextualMapper === identityMapper) { - return anyFunctionType; - } - var links = getNodeLinks(node); - var type = getTypeOfSymbol(node.symbol); - if (!(links.flags & 64 /* ContextChecked */)) { - var contextualSignature = getContextualSignature(node); - if (!(links.flags & 64 /* ContextChecked */)) { - links.flags |= 64 /* ContextChecked */; - if (contextualSignature) { - var signature = getSignaturesOfType(type, 0 /* Call */)[0]; - if (isContextSensitive(node)) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); - } - if (!node.type) { - signature.resolvedReturnType = resolvingType; - var returnType = getReturnTypeFromBody(node, contextualMapper); - if (signature.resolvedReturnType === resolvingType) { - signature.resolvedReturnType = returnType; - } - } - } - checkSignatureDeclaration(node); - } - } - if (fullTypeCheck && node.kind !== 125 /* Method */) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - } - return type; - } - function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 125 /* Method */ || ts.isObjectLiteralMethod(node)); - if (node.type) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); - } - if (node.body) { - if (node.body.kind === 163 /* Block */) { - checkSourceElement(node.body); - } - else { - var exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); - } - checkFunctionExpressionBodies(node.body); - } - } - } - function checkArithmeticOperandType(operand, type, diagnostic) { - if (!(type.flags & (1 /* Any */ | 132 /* NumberLike */))) { - error(operand, diagnostic); - return false; - } - return true; - } - function checkReferenceExpression(n, invalidReferenceMessage, constantVarianleMessage) { - function findSymbol(n) { - var symbol = getNodeLinks(n).resolvedSymbol; - return symbol && getExportSymbolOfValueSymbolIfExported(symbol); - } - function isReferenceOrErrorExpression(n) { - switch (n.kind) { - case 63 /* Identifier */: - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; - case 143 /* PropertyAccessExpression */: - var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - case 144 /* ElementAccessExpression */: - return true; - case 149 /* ParenthesizedExpression */: - return isReferenceOrErrorExpression(n.expression); - default: - return false; - } - } - function isConstVariableReference(n) { - switch (n.kind) { - case 63 /* Identifier */: - case 143 /* PropertyAccessExpression */: - var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 4096 /* Const */) !== 0; - case 144 /* ElementAccessExpression */: - var index = n.argumentExpression; - var symbol = findSymbol(n.expression); - if (symbol && index && index.kind === 7 /* StringLiteral */) { - var name = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(symbol), name); - return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 4096 /* Const */) !== 0; - } - return false; - case 149 /* ParenthesizedExpression */: - return isConstVariableReference(n.expression); - default: - return false; - } - } - if (!isReferenceOrErrorExpression(n)) { - error(n, invalidReferenceMessage); - return false; - } - if (isConstVariableReference(n)) { - error(n, constantVarianleMessage); - return false; - } - return true; - } - function checkDeleteExpression(node) { - var operandType = checkExpression(node.expression); - return booleanType; - } - function checkTypeOfExpression(node) { - var operandType = checkExpression(node.expression); - return stringType; - } - function checkVoidExpression(node) { - var operandType = checkExpression(node.expression); - return undefinedType; - } - function checkPrefixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - switch (node.operator) { - case 32 /* PlusToken */: - case 33 /* MinusToken */: - case 46 /* TildeToken */: - return numberType; - case 45 /* ExclamationToken */: - return booleanType; - case 37 /* PlusPlusToken */: - case 38 /* MinusMinusToken */: - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); - } - return numberType; - } - return unknownType; - } - function checkPostfixUnaryExpression(node) { - var operandType = checkExpression(node.operand); - var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); - if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); - } - return numberType; - } - function isStructuredType(type) { - if (type.flags & 16384 /* Union */) { - return !ts.forEach(type.types, function (t) { return !isStructuredType(t); }); - } - return (type.flags & (48128 /* ObjectType */ | 512 /* TypeParameter */)) !== 0; - } - function isConstEnumObjectType(type) { - return type.flags & (48128 /* ObjectType */ | 32768 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); - } - function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; - } - function checkInstanceOfExpression(node, leftType, rightType) { - if (!(leftType.flags & 1 /* Any */ || isStructuredType(leftType))) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - if (!(rightType.flags & 1 /* Any */ || isTypeSubtypeOf(rightType, globalFunctionType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); - } - return booleanType; - } - function checkInExpression(node, leftType, rightType) { - if (leftType !== anyType && leftType !== stringType && leftType !== numberType) { - error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_types_any_string_or_number); - } - if (!(rightType.flags & 1 /* Any */ || isStructuredType(rightType))) { - error(node.right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - return booleanType; - } - function checkBinaryExpression(node, contextualMapper) { - var operator = node.operator; - var leftType = checkExpression(node.left, contextualMapper); - var rightType = checkExpression(node.right, contextualMapper); - switch (operator) { - case 34 /* AsteriskToken */: - case 54 /* AsteriskEqualsToken */: - case 35 /* SlashToken */: - case 55 /* SlashEqualsToken */: - case 36 /* PercentToken */: - case 56 /* PercentEqualsToken */: - case 33 /* MinusToken */: - case 53 /* MinusEqualsToken */: - case 39 /* LessThanLessThanToken */: - case 57 /* LessThanLessThanEqualsToken */: - case 40 /* GreaterThanGreaterThanToken */: - case 58 /* GreaterThanGreaterThanEqualsToken */: - case 41 /* GreaterThanGreaterThanGreaterThanToken */: - case 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 43 /* BarToken */: - case 61 /* BarEqualsToken */: - case 44 /* CaretToken */: - case 62 /* CaretEqualsToken */: - case 42 /* AmpersandToken */: - case 60 /* AmpersandEqualsToken */: - if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) - leftType = rightType; - if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) - rightType = leftType; - var suggestedOperator; - if ((leftType.flags & 8 /* Boolean */) && (rightType.flags & 8 /* Boolean */) && (suggestedOperator = getSuggestedBooleanOperator(node.operator)) !== undefined) { - error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operator), ts.tokenToString(suggestedOperator)); - } - else { - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); - } - } - return numberType; - case 32 /* PlusToken */: - case 52 /* PlusEqualsToken */: - if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) - leftType = rightType; - if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) - rightType = leftType; - var resultType; - if (leftType.flags & 132 /* NumberLike */ && rightType.flags & 132 /* NumberLike */) { - resultType = numberType; - } - else if (leftType.flags & 258 /* StringLike */ || rightType.flags & 258 /* StringLike */) { - resultType = stringType; - } - else if (leftType.flags & 1 /* Any */ || leftType === unknownType || rightType.flags & 1 /* Any */ || rightType === unknownType) { - resultType = anyType; - } - if (!resultType) { - reportOperatorError(); - return anyType; - } - if (operator === 52 /* PlusEqualsToken */) { - checkAssignmentOperator(resultType); - } - return resultType; - case 27 /* EqualsEqualsToken */: - case 28 /* ExclamationEqualsToken */: - case 29 /* EqualsEqualsEqualsToken */: - case 30 /* ExclamationEqualsEqualsToken */: - case 23 /* LessThanToken */: - case 24 /* GreaterThanToken */: - case 25 /* LessThanEqualsToken */: - case 26 /* GreaterThanEqualsToken */: - if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { - reportOperatorError(); - } - return booleanType; - case 85 /* InstanceOfKeyword */: - return checkInstanceOfExpression(node, leftType, rightType); - case 84 /* InKeyword */: - return checkInExpression(node, leftType, rightType); - case 47 /* AmpersandAmpersandToken */: - return rightType; - case 48 /* BarBarToken */: - return getUnionType([leftType, rightType]); - case 51 /* EqualsToken */: - checkAssignmentOperator(rightType); - return rightType; - case 22 /* CommaToken */: - return rightType; - } - function getSuggestedBooleanOperator(operator) { - switch (operator) { - case 43 /* BarToken */: - case 61 /* BarEqualsToken */: - return 48 /* BarBarToken */; - case 44 /* CaretToken */: - case 62 /* CaretEqualsToken */: - return 30 /* ExclamationEqualsEqualsToken */; - case 42 /* AmpersandToken */: - case 60 /* AmpersandEqualsToken */: - return 47 /* AmpersandAmpersandToken */; - default: - return undefined; - } - } - function checkAssignmentOperator(valueType) { - if (fullTypeCheck && operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { - var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); - if (ok) { - checkTypeAssignableTo(valueType, leftType, node.left, undefined); - } - } - } - function reportOperatorError() { - error(node, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(node.operator), typeToString(leftType), typeToString(rightType)); - } - } - function checkConditionalExpression(node, contextualMapper) { - checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); - return getUnionType([type1, type2]); - } - function checkTemplateExpression(node) { - ts.forEach(node.templateSpans, function (templateSpan) { - checkExpression(templateSpan.expression); - }); - return stringType; - } - function checkExpressionWithContextualType(node, contextualType, contextualMapper) { - var saveContextualType = node.contextualType; - node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); - node.contextualType = saveContextualType; - return result; - } - function checkAndMarkExpression(node, contextualMapper) { - var result = checkExpression(node, contextualMapper); - getNodeLinks(node).flags |= 1 /* TypeChecked */; - return result; - } - function checkObjectLiteralMethod(node, contextualMapper) { - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (contextualMapper && contextualMapper !== identityMapper) { - var signature = getSingleCallSignature(type); - if (signature && signature.typeParameters) { - var contextualType = getContextualType(node); - if (contextualType) { - var contextualSignature = getSingleCallSignature(contextualType); - if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); - } - } - } - } - return type; - } - function checkExpression(node, contextualMapper) { - return checkExpressionOrQualifiedName(node, contextualMapper); - } - function checkExpressionOrQualifiedName(node, contextualMapper) { - var type; - if (node.kind == 120 /* QualifiedName */) { - type = checkQualifiedName(node); - } - else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); - } - if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 143 /* PropertyAccessExpression */ && node.parent.expression === node) || (node.parent.kind === 144 /* ElementAccessExpression */ && node.parent.expression === node) || ((node.kind === 63 /* Identifier */ || node.kind === 120 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); - if (!ok) { - error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); - } - } - return type; - } - function checkExpressionWorker(node, contextualMapper) { - switch (node.kind) { - case 63 /* Identifier */: - return checkIdentifier(node); - case 91 /* ThisKeyword */: - return checkThisExpression(node); - case 89 /* SuperKeyword */: - return checkSuperExpression(node); - case 87 /* NullKeyword */: - return nullType; - case 93 /* TrueKeyword */: - case 78 /* FalseKeyword */: - return booleanType; - case 6 /* NumericLiteral */: - return numberType; - case 159 /* TemplateExpression */: - return checkTemplateExpression(node); - case 7 /* StringLiteral */: - case 9 /* NoSubstitutionTemplateLiteral */: - return stringType; - case 8 /* RegularExpressionLiteral */: - return globalRegExpType; - case 141 /* ArrayLiteralExpression */: - return checkArrayLiteral(node, contextualMapper); - case 142 /* ObjectLiteralExpression */: - return checkObjectLiteral(node, contextualMapper); - case 143 /* PropertyAccessExpression */: - return checkPropertyAccessExpression(node); - case 144 /* ElementAccessExpression */: - return checkIndexedAccess(node); - case 145 /* CallExpression */: - case 146 /* NewExpression */: - return checkCallExpression(node); - case 147 /* TaggedTemplateExpression */: - return checkTaggedTemplateExpression(node); - case 148 /* TypeAssertionExpression */: - return checkTypeAssertion(node); - case 149 /* ParenthesizedExpression */: - return checkExpression(node.expression); - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 153 /* TypeOfExpression */: - return checkTypeOfExpression(node); - case 152 /* DeleteExpression */: - return checkDeleteExpression(node); - case 154 /* VoidExpression */: - return checkVoidExpression(node); - case 155 /* PrefixUnaryExpression */: - return checkPrefixUnaryExpression(node); - case 156 /* PostfixUnaryExpression */: - return checkPostfixUnaryExpression(node); - case 157 /* BinaryExpression */: - return checkBinaryExpression(node, contextualMapper); - case 158 /* ConditionalExpression */: - return checkConditionalExpression(node, contextualMapper); - case 161 /* OmittedExpression */: - return undefinedType; - } - return unknownType; - } - function checkTypeParameter(node) { - checkSourceElement(node.constraint); - if (fullTypeCheck) { - checkTypeParameterHasIllegalReferencesInConstraint(node); - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0); - } - } - function checkParameter(parameterDeclaration) { - checkVariableOrParameterDeclaration(parameterDeclaration); - if (fullTypeCheck) { - checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name); - if (parameterDeclaration.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */) && !(parameterDeclaration.parent.kind === 126 /* Constructor */ && parameterDeclaration.parent.body)) { - error(parameterDeclaration, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); - } - if (parameterDeclaration.dotDotDotToken) { - if (!isArrayType(getTypeOfSymbol(parameterDeclaration.symbol))) { - error(parameterDeclaration, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); - } - } - else { - if (parameterDeclaration.initializer && !parameterDeclaration.parent.body) { - error(parameterDeclaration, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); - } - } - } - function checkReferencesInInitializer(n) { - if (n.kind === 63 /* Identifier */) { - var referencedSymbol = getNodeLinks(n).resolvedSymbol; - if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(parameterDeclaration.parent.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 123 /* Parameter */) { - if (referencedSymbol.valueDeclaration === parameterDeclaration) { - error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(parameterDeclaration.name)); - return; - } - var enclosingOrReferencedParameter = ts.forEach(parameterDeclaration.parent.parameters, function (p) { return p === parameterDeclaration || p === referencedSymbol.valueDeclaration ? p : undefined; }); - if (enclosingOrReferencedParameter === referencedSymbol.valueDeclaration) { - return; - } - } - error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(parameterDeclaration.name), ts.declarationNameToString(n)); - } - } - else { - ts.forEachChild(n, checkReferencesInInitializer); - } - } - if (parameterDeclaration.initializer) { - checkReferencesInInitializer(parameterDeclaration.initializer); - } - } - function checkSignatureDeclaration(node) { - checkTypeParameters(node.typeParameters); - ts.forEach(node.parameters, checkParameter); - if (node.type) { - checkSourceElement(node.type); - } - if (fullTypeCheck) { - checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { - switch (node.kind) { - case 130 /* ConstructSignature */: - error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); - break; - case 129 /* CallSignature */: - error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); - break; - } - } - } - checkSpecializedSignatureDeclaration(node); - } - function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 186 /* InterfaceDeclaration */) { - var nodeSymbol = getSymbolOfNode(node); - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { - return; - } - } - var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { - var seenNumericIndexer = false; - var seenStringIndexer = false; - for (var i = 0, len = indexSymbol.declarations.length; i < len; ++i) { - var declaration = indexSymbol.declarations[i]; - if (declaration.parameters.length == 1 && declaration.parameters[0].type) { - switch (declaration.parameters[0].type.kind) { - case 118 /* StringKeyword */: - if (!seenStringIndexer) { - seenStringIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_string_index_signature); - } - break; - case 116 /* NumberKeyword */: - if (!seenNumericIndexer) { - seenNumericIndexer = true; - } - else { - error(declaration, ts.Diagnostics.Duplicate_number_index_signature); - } - break; - } - } - } - } - } - function checkPropertyDeclaration(node) { - if (fullTypeCheck) { - checkVariableOrParameterOrPropertyInFullTypeCheck(node); - } - } - function checkMethodDeclaration(node) { - checkFunctionLikeDeclaration(node); - } - function checkConstructorDeclaration(node) { - checkSignatureDeclaration(node); - checkSourceElement(node.body); - var symbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(symbol); - } - if (!node.body) { - return; - } - if (!fullTypeCheck) { - return; - } - function isSuperCallExpression(n) { - return n.kind === 145 /* CallExpression */ && n.expression.kind === 89 /* SuperKeyword */; - } - function containsSuperCall(n) { - if (isSuperCallExpression(n)) { - return true; - } - switch (n.kind) { - case 150 /* FunctionExpression */: - case 184 /* FunctionDeclaration */: - case 151 /* ArrowFunction */: - case 142 /* ObjectLiteralExpression */: return false; - default: return ts.forEachChild(n, containsSuperCall); - } - } - function markThisReferencesAsErrors(n) { - if (n.kind === 91 /* ThisKeyword */) { - error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); - } - else if (n.kind !== 150 /* FunctionExpression */ && n.kind !== 184 /* FunctionDeclaration */) { - ts.forEachChild(n, markThisReferencesAsErrors); - } - } - function isInstancePropertyWithInitializer(n) { - return n.kind === 124 /* Property */ && !(n.flags & 128 /* Static */) && !!n.initializer; - } - if (ts.getClassBaseTypeNode(node.parent)) { - if (containsSuperCall(node.body)) { - var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); - if (superCallShouldBeFirst) { - var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 166 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { - error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); - } - else { - markThisReferencesAsErrors(statements[0].expression); - } - } - } - else { - error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call); - } - } - } - function checkAccessorDeclaration(node) { - if (fullTypeCheck) { - if (node.kind === 127 /* GetAccessor */) { - if (!ts.isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); - } - } - if (!ts.hasComputedNameButNotSymbol(node)) { - var otherKind = node.kind === 127 /* GetAccessor */ ? 128 /* SetAccessor */ : 127 /* GetAccessor */; - var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); - if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); - } - var currentAccessorType = getAnnotatedAccessorType(node); - var otherAccessorType = getAnnotatedAccessorType(otherAccessor); - if (currentAccessorType && otherAccessorType) { - if (!isTypeIdenticalTo(currentAccessorType, otherAccessorType)) { - error(node, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - } - } - } - checkAndStoreTypeOfAccessors(getSymbolOfNode(node)); - } - } - checkFunctionLikeDeclaration(node); - } - function checkTypeReference(node) { - var type = getTypeFromTypeReferenceNode(node); - if (type !== unknownType && node.typeArguments) { - var len = node.typeArguments.length; - for (var i = 0; i < len; i++) { - checkSourceElement(node.typeArguments[i]); - var constraint = getConstraintOfTypeParameter(type.target.typeParameters[i]); - if (fullTypeCheck && constraint) { - var typeArgument = type.typeArguments[i]; - checkTypeAssignableTo(typeArgument, constraint, node, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); - } - } - } - } - function checkTypeQuery(node) { - getTypeFromTypeQueryNode(node); - } - function checkTypeLiteral(node) { - ts.forEach(node.members, checkSourceElement); - if (fullTypeCheck) { - var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkArrayType(node) { - checkSourceElement(node.elementType); - } - function checkTupleType(node) { - ts.forEach(node.elementTypes, checkSourceElement); - } - function checkUnionType(node) { - ts.forEach(node.types, checkSourceElement); - } - function isPrivateWithinAmbient(node) { - return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node); - } - function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { - if (!fullTypeCheck) { - return; - } - var signature = getSignatureFromDeclaration(signatureDeclarationNode); - if (!signature.hasStringLiterals) { - return; - } - if (signatureDeclarationNode.body) { - error(signatureDeclarationNode, ts.Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type); - return; - } - var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 186 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 129 /* CallSignature */ || signatureDeclarationNode.kind === 130 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 129 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; - var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); - var containingType = getDeclaredTypeOfSymbol(containingSymbol); - signaturesToCheck = getSignaturesOfType(containingType, signatureKind); - } - else { - signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); - } - for (var i = 0; i < signaturesToCheck.length; i++) { - var otherSignature = signaturesToCheck[i]; - if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { - return; - } - } - error(signatureDeclarationNode, ts.Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); - } - function getEffectiveDeclarationFlags(n, flagsToCheck) { - var flags = n.flags; - if (n.parent.kind !== 186 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { - if (!(flags & 2 /* Ambient */)) { - flags |= 1 /* Export */; - } - flags |= 2 /* Ambient */; - } - return flags & flagsToCheck; - } - function checkFunctionOrConstructorSymbol(symbol) { - if (!fullTypeCheck) { - return; - } - function getCanonicalOverload(overloads, implementation) { - var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent; - return implementationSharesContainerWithFirstOverload ? implementation : overloads[0]; - } - function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) { - var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags; - if (someButNotAllOverloadFlags !== 0) { - var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); - ts.forEach(overloads, function (o) { - var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1 /* Export */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); - } - else if (deviation & 2 /* Ambient */) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); - } - else if (deviation & (32 /* Private */ | 64 /* Protected */)) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); - } - }); - } - } - function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) { - if (someHaveQuestionToken !== allHaveQuestionToken) { - var canonicalHasQuestionToken = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation)); - ts.forEach(overloads, function (o) { - var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken; - if (deviation) { - error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required); - } - }); - } - } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */; - var someNodeFlags = 0; - var allNodeFlags = flagsToCheck; - var someHaveQuestionToken = false; - var allHaveQuestionToken = true; - var hasOverloads = false; - var bodyDeclaration; - var lastSeenNonAmbientDeclaration; - var previousDeclaration; - var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; - function reportImplementationExpectedError(node) { - if (node.name && ts.getFullWidth(node.name) === 0) { - return; - } - var seen = false; - var subsequentNode = ts.forEachChild(node.parent, function (c) { - if (seen) { - return c; - } - else { - seen = c === node; - } - }); - if (subsequentNode) { - if (subsequentNode.kind === node.kind) { - var errorNode = subsequentNode.name || subsequentNode; - if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 125 /* Method */); - ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); - var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; - error(errorNode, diagnostic); - return; - } - else if (subsequentNode.body) { - error(errorNode, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name)); - return; - } - } - } - var errorNode = node.name || node; - if (isConstructor) { - error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); - } - else { - error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); - } - } - var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; - var duplicateFunctionDeclaration = false; - var multipleConstructorImplementation = false; - for (var i = 0; i < declarations.length; i++) { - var node = declarations[i]; - var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 186 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext; - if (inAmbientContextOrInterface) { - previousDeclaration = undefined; - } - if (node.kind === 184 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) { - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - if (node.body && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; - } - else { - duplicateFunctionDeclaration = true; - } - } - else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (node.body) { - if (!bodyDeclaration) { - bodyDeclaration = node; - } - } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } - } - } - if (multipleConstructorImplementation) { - ts.forEach(declarations, function (declaration) { - error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); - }); - } - if (duplicateFunctionDeclaration) { - ts.forEach(declarations, function (declaration) { - error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); - }); - } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { - reportImplementationExpectedError(lastSeenNonAmbientDeclaration); - } - if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); - if (bodyDeclaration) { - var signatures = getSignaturesOfSymbol(symbol); - var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - if (!bodySignature.hasStringLiterals) { - for (var i = 0, len = signatures.length; i < len; ++i) { - if (!signatures[i].hasStringLiterals && !isSignatureAssignableTo(bodySignature, signatures[i])) { - error(signatures[i].declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); - break; - } - } - } - } - } - } - function checkExportsOnMergedDeclarations(node) { - if (!fullTypeCheck) { - return; - } - var symbol; - var symbol = node.localSymbol; - if (!symbol) { - symbol = getSymbolOfNode(node); - if (!(symbol.flags & 29360128 /* Export */)) { - return; - } - } - if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { - return; - } - var exportedDeclarationSpaces = 0; - var nonExportedDeclarationSpaces = 0; - ts.forEach(symbol.declarations, function (d) { - var declarationSpaces = getDeclarationSpaces(d); - if (getEffectiveDeclarationFlags(d, 1 /* Export */)) { - exportedDeclarationSpaces |= declarationSpaces; - } - else { - nonExportedDeclarationSpaces |= declarationSpaces; - } - }); - var commonDeclarationSpace = exportedDeclarationSpaces & nonExportedDeclarationSpaces; - if (commonDeclarationSpace) { - ts.forEach(symbol.declarations, function (d) { - if (getDeclarationSpaces(d) & commonDeclarationSpace) { - error(d.name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(d.name)); - } - }); - } - function getDeclarationSpaces(d) { - switch (d.kind) { - case 186 /* InterfaceDeclaration */: - return 8388608 /* ExportType */; - case 189 /* ModuleDeclaration */: - return d.name.kind === 7 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 16777216 /* ExportNamespace */ | 4194304 /* ExportValue */ : 16777216 /* ExportNamespace */; - case 185 /* ClassDeclaration */: - case 188 /* EnumDeclaration */: - return 8388608 /* ExportType */ | 4194304 /* ExportValue */; - case 191 /* ImportDeclaration */: - var result = 0; - var target = resolveImport(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { - result |= getDeclarationSpaces(d); - }); - return result; - default: - return 4194304 /* ExportValue */; - } - } - } - function checkFunctionDeclaration(node) { - checkFunctionLikeDeclaration(node); - if (fullTypeCheck) { - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - } - } - function checkFunctionLikeDeclaration(node) { - checkSignatureDeclaration(node); - if (!ts.hasComputedNameButNotSymbol(node)) { - var symbol = getSymbolOfNode(node); - var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.getDeclarationOfKind(localSymbol, node.kind); - if (node === firstDeclaration) { - checkFunctionOrConstructorSymbol(localSymbol); - } - if (symbol.parent) { - if (ts.getDeclarationOfKind(symbol, node.kind) === node) { - checkFunctionOrConstructorSymbol(symbol); - } - } - } - checkSourceElement(node.body); - if (node.type && !isAccessor(node.kind)) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); - } - if (fullTypeCheck && compilerOptions.noImplicitAny && !node.body && !node.type) { - if (!isPrivateWithinAmbient(node)) { - var typeName = typeToString(anyType); - if (node.name) { - error(node, ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, ts.declarationNameToString(node.name), typeName); - } - else { - error(node, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeName); - } - } - } - } - function checkBlock(node) { - ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 190 /* ModuleBlock */) { - checkFunctionExpressionBodies(node); - } - } - function checkCollisionWithArgumentsInGeneratedCode(node) { - if (!ts.hasRestParameters(node) || ts.isInAmbientContext(node) || !node.body) { - return; - } - ts.forEach(node.parameters, function (p) { - if (p.name && p.name.text === argumentsSymbol.name) { - error(p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters); - } - }); - } - function checkCollisionWithIndexVariableInGeneratedCode(node, name) { - if (!(name && name.text === "_i")) { - return; - } - if (node.kind === 123 /* Parameter */) { - if (node.parent.body && ts.hasRestParameters(node.parent) && !ts.isInAmbientContext(node)) { - error(node, ts.Diagnostics.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter); - } - return; - } - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol === unknownSymbol) { - return; - } - var current = node; - while (current) { - var definedOnCurrentLevel = ts.forEach(symbol.declarations, function (d) { return d.parent === current ? d : undefined; }); - if (definedOnCurrentLevel) { - return; - } - switch (current.kind) { - case 184 /* FunctionDeclaration */: - case 150 /* FunctionExpression */: - case 125 /* Method */: - case 151 /* ArrowFunction */: - case 126 /* Constructor */: - if (ts.hasRestParameters(current)) { - error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter); - return; - } - break; - } - current = current.parent; - } - } - function needCollisionCheckForIdentifier(node, identifier, name) { - if (!identifier || identifier.text !== name) { - return false; - } - if (node.kind === 124 /* Property */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */) { - return false; - } - if (ts.isInAmbientContext(node)) { - return false; - } - if (node.kind === 123 /* Parameter */ && !node.parent.body) { - return false; - } - return true; - } - function checkCollisionWithCapturedThisVariable(node, name) { - if (needCollisionCheckForIdentifier(node, name, "_this")) { - potentialThisCollisions.push(node); - } - } - function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration = node.kind !== 63 /* Identifier */; - if (isDeclaration) { - error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); - } - return; - } - current = current.parent; - } - } - function checkCollisionWithCapturedSuperVariable(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "_super")) { - return; - } - var enclosingClass = ts.getAncestor(node, 185 /* ClassDeclaration */); - if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { - return; - } - if (ts.getClassBaseTypeNode(enclosingClass)) { - var isDeclaration = node.kind !== 63 /* Identifier */; - if (isDeclaration) { - error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); - } - else { - error(node, ts.Diagnostics.Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference); - } - } - } - function checkCollisionWithRequireExportsInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { - return; - } - if (node.kind === 189 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { - return; - } - var parent = node.kind === 183 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (parent.kind === 201 /* SourceFile */ && ts.isExternalModule(parent)) { - error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); - } - } - function checkCollisionWithConstDeclarations(node) { - if (node.initializer && (node.flags & 6144 /* BlockScoped */) === 0) { - var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, undefined, undefined); - if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 4096 /* Const */) { - error(node, ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0, symbolToString(localDeclarationSymbol)); - } - } - } - } - } - function checkVariableOrParameterOrPropertyInFullTypeCheck(node) { - ts.Debug.assert(fullTypeCheck); - checkSourceElement(node.type); - if (ts.hasComputedNameButNotSymbol(node)) { - return node.initializer ? checkAndMarkExpression(node.initializer) : anyType; - } - var symbol = getSymbolOfNode(node); - var type; - if (symbol.valueDeclaration !== node) { - type = getTypeOfVariableOrParameterOrPropertyDeclaration(node); - } - else { - type = getTypeOfVariableOrParameterOrProperty(symbol); - } - if (node.initializer && !(getNodeLinks(node.initializer).flags & 1 /* TypeChecked */)) { - checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, undefined); - } - return type; - } - function checkVariableOrParameterDeclaration(node) { - if (fullTypeCheck) { - var type = checkVariableOrParameterOrPropertyInFullTypeCheck(node); - checkExportsOnMergedDeclarations(node); - if (node.initializer) { - checkCollisionWithConstDeclarations(node); - } - checkCollisionWithCapturedSuperVariable(node, node.name); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - var symbol = getSymbolOfNode(node); - if (node !== symbol.valueDeclaration) { - var typeOfValueDeclaration = getTypeOfVariableOrParameterOrProperty(symbol); - if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) { - error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.declarationNameToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type)); - } - } - } - } - function checkVariableStatement(node) { - ts.forEach(node.declarations, checkVariableOrParameterDeclaration); - } - function checkExpressionStatement(node) { - checkExpression(node.expression); - } - function checkIfStatement(node) { - checkExpression(node.expression); - checkSourceElement(node.thenStatement); - checkSourceElement(node.elseStatement); - } - function checkDoStatement(node) { - checkSourceElement(node.statement); - checkExpression(node.expression); - } - function checkWhileStatement(node) { - checkExpression(node.expression); - checkSourceElement(node.statement); - } - function checkForStatement(node) { - if (node.declarations) - ts.forEach(node.declarations, checkVariableOrParameterDeclaration); - if (node.initializer) - checkExpression(node.initializer); - if (node.condition) - checkExpression(node.condition); - if (node.iterator) - checkExpression(node.iterator); - checkSourceElement(node.statement); - } - function checkForInStatement(node) { - if (node.declarations) { - if (node.declarations.length >= 1) { - var decl = node.declarations[0]; - checkVariableOrParameterDeclaration(decl); - if (decl.type) { - error(decl, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation); - } - } - } - if (node.variable) { - var exprType = checkExpression(node.variable); - if (exprType !== anyType && exprType !== stringType) { - error(node.variable, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); - } - else { - checkReferenceExpression(node.variable, ts.Diagnostics.Invalid_left_hand_side_in_for_in_statement, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); - } - } - var exprType = checkExpression(node.expression); - if (!(exprType.flags & 1 /* Any */ || isStructuredType(exprType))) { - error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); - } - checkSourceElement(node.statement); - } - function checkBreakOrContinueStatement(node) { - } - function checkReturnStatement(node) { - if (node.expression && !(getNodeLinks(node.expression).flags & 1 /* TypeChecked */)) { - var func = ts.getContainingFunction(node); - if (func) { - if (func.kind === 128 /* SetAccessor */) { - if (node.expression) { - error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); - } - } - else { - var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); - var checkAssignability = func.type || (func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))); - if (checkAssignability) { - checkTypeAssignableTo(checkExpression(node.expression), returnType, node.expression, undefined); - } - else if (func.kind == 126 /* Constructor */) { - if (!isTypeAssignableTo(checkExpression(node.expression), returnType)) { - error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); - } - } - } - } - } - } - function checkWithStatement(node) { - checkExpression(node.expression); - error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); - } - function checkSwitchStatement(node) { - var expressionType = checkExpression(node.expression); - ts.forEach(node.clauses, function (clause) { - if (fullTypeCheck && clause.kind === 194 /* CaseClause */) { - var caseClause = clause; - var caseType = checkExpression(caseClause.expression); - if (!isTypeAssignableTo(expressionType, caseType)) { - checkTypeAssignableTo(caseType, expressionType, caseClause.expression, undefined); - } - } - ts.forEach(clause.statements, checkSourceElement); - }); - } - function checkLabeledStatement(node) { - checkSourceElement(node.statement); - } - function checkThrowStatement(node) { - if (node.expression) { - checkExpression(node.expression); - } - } - function checkTryStatement(node) { - checkBlock(node.tryBlock); - if (node.catchClause) - checkBlock(node.catchClause.block); - if (node.finallyBlock) - checkBlock(node.finallyBlock); - } - function checkIndexConstraints(type) { - function checkIndexConstraintForProperty(prop, propertyType, indexDeclaration, indexType, indexKind) { - if (!indexType) { - return; - } - if (indexKind === 1 /* Number */ && !isNumericName(prop.name)) { - return; - } - var errorNode; - if (prop.parent === type.symbol) { - errorNode = prop.valueDeclaration; - } - else if (indexDeclaration) { - errorNode = indexDeclaration; - } - else if (type.flags & 2048 /* Interface */) { - var someBaseClassHasBothPropertyAndIndexer = ts.forEach(type.baseTypes, function (base) { return getPropertyOfObjectType(base, prop.name) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : type.symbol.declarations[0]; - } - if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { - var errorMessage = indexKind === 0 /* String */ ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2 : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2; - error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType)); - } - } - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); - var stringIndexType = getIndexTypeOfType(type, 0 /* String */); - var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); - if (stringIndexType || numberIndexType) { - ts.forEach(getPropertiesOfObjectType(type), function (prop) { - var propType = getTypeOfSymbol(prop); - checkIndexConstraintForProperty(prop, propType, declaredStringIndexer, stringIndexType, 0 /* String */); - checkIndexConstraintForProperty(prop, propType, declaredNumberIndexer, numberIndexType, 1 /* Number */); - }); - } - var errorNode; - if (stringIndexType && numberIndexType) { - errorNode = declaredNumberIndexer || declaredStringIndexer; - if (!errorNode && (type.flags & 2048 /* Interface */)) { - var someBaseTypeHasBothIndexers = ts.forEach(type.baseTypes, function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; - } - } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { - error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); - } - } - function checkTypeNameIsReserved(name, message) { - switch (name.text) { - case "any": - case "number": - case "boolean": - case "string": - case "void": - error(name, message, name.text); - } - } - function checkTypeParameters(typeParameterDeclarations) { - if (typeParameterDeclarations) { - for (var i = 0; i < typeParameterDeclarations.length; i++) { - var node = typeParameterDeclarations[i]; - checkTypeParameter(node); - if (fullTypeCheck) { - for (var j = 0; j < i; j++) { - if (typeParameterDeclarations[j].symbol === node.symbol) { - error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name)); - } - } - } - } - } - } - function checkClassDeclaration(node) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); - checkTypeParameters(node.typeParameters); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var type = getDeclaredTypeOfSymbol(symbol); - var staticType = getTypeOfSymbol(symbol); - var baseTypeNode = ts.getClassBaseTypeNode(node); - if (baseTypeNode) { - emitExtends = emitExtends || !ts.isInAmbientContext(node); - checkTypeReference(baseTypeNode); - } - if (type.baseTypes.length) { - if (fullTypeCheck) { - var baseType = type.baseTypes[0]; - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); - var staticBaseType = getTypeOfSymbol(baseType.symbol); - checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(node, baseTypeNode.typeName, 107455 /* Value */)) { - error(baseTypeNode, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); - } - checkKindsOfPropertyMemberOverrides(type, baseType); - } - checkExpressionOrQualifiedName(baseTypeNode.typeName); - } - var implementedTypeNodes = ts.getClassImplementedTypeNodes(node); - if (implementedTypeNodes) { - ts.forEach(implementedTypeNodes, function (typeRefNode) { - checkTypeReference(typeRefNode); - if (fullTypeCheck) { - var t = getTypeFromTypeReferenceNode(typeRefNode); - if (t !== unknownType) { - var declaredType = (t.flags & 4096 /* Reference */) ? t.target : t; - if (declaredType.flags & (1024 /* Class */ | 2048 /* Interface */)) { - checkTypeAssignableTo(type, t, node.name, ts.Diagnostics.Class_0_incorrectly_implements_interface_1); - } - else { - error(typeRefNode, ts.Diagnostics.A_class_may_only_implement_another_class_or_interface); - } - } - } - }); - } - ts.forEach(node.members, checkSourceElement); - if (fullTypeCheck) { - checkIndexConstraints(type); - checkTypeForDuplicateIndexSignatures(node); - } - } - function getTargetSymbol(s) { - return s.flags & 67108864 /* Instantiated */ ? getSymbolLinks(s).target : s; - } - function checkKindsOfPropertyMemberOverrides(type, baseType) { - var baseProperties = getPropertiesOfObjectType(baseType); - for (var i = 0, len = baseProperties.length; i < len; ++i) { - var base = getTargetSymbol(baseProperties[i]); - if (base.flags & 536870912 /* Prototype */) { - continue; - } - var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); - if (derived) { - var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { - continue; - } - if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { - continue; - } - if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { - continue; - } - var errorMessage; - if (base.flags & 8192 /* Method */) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; - } - else { - ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & 4 /* Property */) { - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - else { - ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); - } - } - } - function isAccessor(kind) { - return kind === 127 /* GetAccessor */ || kind === 128 /* SetAccessor */; - } - function areTypeParametersIdentical(list1, list2) { - if (!list1 && !list2) { - return true; - } - if (!list1 || !list2 || list1.length !== list2.length) { - return false; - } - for (var i = 0, len = list1.length; i < len; i++) { - var tp1 = list1[i]; - var tp2 = list2[i]; - if (tp1.name.text !== tp2.name.text) { - return false; - } - if (!tp1.constraint && !tp2.constraint) { - continue; - } - if (!tp1.constraint || !tp2.constraint) { - return false; - } - if (!isTypeIdenticalTo(getTypeFromTypeNode(tp1.constraint), getTypeFromTypeNode(tp2.constraint))) { - return false; - } - } - return true; - } - function checkInheritedPropertiesAreIdentical(type, typeNode) { - if (!type.baseTypes.length || type.baseTypes.length === 1) { - return true; - } - var seen = {}; - ts.forEach(type.declaredProperties, function (p) { - seen[p.name] = { prop: p, containingType: type }; - }); - var ok = true; - for (var i = 0, len = type.baseTypes.length; i < len; ++i) { - var base = type.baseTypes[i]; - var properties = getPropertiesOfObjectType(base); - for (var j = 0, proplen = properties.length; j < proplen; ++j) { - var prop = properties[j]; - if (!ts.hasProperty(seen, prop.name)) { - seen[prop.name] = { prop: prop, containingType: base }; - } - else { - var existing = seen[prop.name]; - var isInheritedProperty = existing.containingType !== type; - if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { - ok = false; - var typeName1 = typeToString(existing.containingType); - var typeName2 = typeToString(base); - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_properties_0_of_types_1_and_2_are_not_identical, prop.name, typeName1, typeName2); - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); - addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo, program.getCompilerHost().getNewLine())); - } - } - } - } - return ok; - } - function checkInterfaceDeclaration(node) { - checkTypeParameters(node.typeParameters); - if (fullTypeCheck) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 186 /* InterfaceDeclaration */); - if (symbol.declarations.length > 1) { - if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { - error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); - } - } - if (node === firstInterfaceDecl) { - var type = getDeclaredTypeOfSymbol(symbol); - if (checkInheritedPropertiesAreIdentical(type, node.name)) { - ts.forEach(type.baseTypes, function (baseType) { - checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); - }); - checkIndexConstraints(type); - } - } - } - ts.forEach(ts.getInterfaceBaseTypeNodes(node), checkTypeReference); - ts.forEach(node.members, checkSourceElement); - if (fullTypeCheck) { - checkTypeForDuplicateIndexSignatures(node); - } - } - function checkTypeAliasDeclaration(node) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); - checkSourceElement(node.type); - } - function computeEnumMemberValues(node) { - var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 128 /* EnumValuesComputed */)) { - var enumSymbol = getSymbolOfNode(node); - var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; - var ambient = ts.isInAmbientContext(node); - var enumIsConst = ts.isConst(node); - ts.forEach(node.members, function (member) { - if (isNumericName(member.name.text)) { - error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); - } - var initializer = member.initializer; - if (initializer) { - autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst); - if (autoValue === undefined) { - if (enumIsConst) { - error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); - } - else if (!ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); - } - } - else if (enumIsConst) { - if (isNaN(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); - } - else if (!isFinite(autoValue)) { - error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); - } - } - } - else if (ambient && !enumIsConst) { - autoValue = undefined; - } - if (autoValue !== undefined) { - getNodeLinks(member).enumMemberValue = autoValue++; - } - }); - nodeLinks.flags |= 128 /* EnumValuesComputed */; - } - function getConstantValueForEnumMemberInitializer(initializer, enumIsConst) { - return evalConstant(initializer); - function evalConstant(e) { - switch (e.kind) { - case 155 /* PrefixUnaryExpression */: - var value = evalConstant(e.operand); - if (value === undefined) { - return undefined; - } - switch (e.operator) { - case 32 /* PlusToken */: return value; - case 33 /* MinusToken */: return -value; - case 46 /* TildeToken */: return enumIsConst ? ~value : undefined; - } - return undefined; - case 157 /* BinaryExpression */: - if (!enumIsConst) { - return undefined; - } - var left = evalConstant(e.left); - if (left === undefined) { - return undefined; - } - var right = evalConstant(e.right); - if (right === undefined) { - return undefined; - } - switch (e.operator) { - case 43 /* BarToken */: return left | right; - case 42 /* AmpersandToken */: return left & right; - case 40 /* GreaterThanGreaterThanToken */: return left >> right; - case 41 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 39 /* LessThanLessThanToken */: return left << right; - case 44 /* CaretToken */: return left ^ right; - case 34 /* AsteriskToken */: return left * right; - case 35 /* SlashToken */: return left / right; - case 32 /* PlusToken */: return left + right; - case 33 /* MinusToken */: return left - right; - case 36 /* PercentToken */: return left % right; - } - return undefined; - case 6 /* NumericLiteral */: - return +e.text; - case 149 /* ParenthesizedExpression */: - return enumIsConst ? evalConstant(e.expression) : undefined; - case 63 /* Identifier */: - case 144 /* ElementAccessExpression */: - case 143 /* PropertyAccessExpression */: - if (!enumIsConst) { - return undefined; - } - var member = initializer.parent; - var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); - var enumType; - var propertyName; - if (e.kind === 63 /* Identifier */) { - enumType = currentType; - propertyName = e.text; - } - else { - if (e.kind === 144 /* ElementAccessExpression */) { - if (e.argumentExpression === undefined || e.argumentExpression.kind !== 7 /* StringLiteral */) { - return undefined; - } - var enumType = getTypeOfNode(e.expression); - propertyName = e.argumentExpression.text; - } - else { - var enumType = getTypeOfNode(e.expression); - propertyName = e.name.text; - } - if (enumType !== currentType) { - return undefined; - } - } - if (propertyName === undefined) { - return undefined; - } - var property = getPropertyOfObjectType(enumType, propertyName); - if (!property || !(property.flags & 8 /* EnumMember */)) { - return undefined; - } - var propertyDecl = property.valueDeclaration; - if (member === propertyDecl) { - return undefined; - } - if (!isDefinedBefore(propertyDecl, member)) { - return undefined; - } - return getNodeLinks(propertyDecl).enumMemberValue; - } - } - } - } - function checkEnumDeclaration(node) { - if (!fullTypeCheck) { - return; - } - checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - computeEnumMemberValues(node); - var enumSymbol = getSymbolOfNode(node); - var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); - if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { - var enumIsConst = ts.isConst(node); - ts.forEach(enumSymbol.declarations, function (decl) { - if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { - error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); - } - }); - } - var seenEnumMissingInitialInitializer = false; - ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 188 /* EnumDeclaration */) { - return false; - } - var enumDeclaration = declaration; - if (!enumDeclaration.members.length) { - return false; - } - var firstEnumMember = enumDeclaration.members[0]; - if (!firstEnumMember.initializer) { - if (seenEnumMissingInitialInitializer) { - error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element); - } - else { - seenEnumMissingInitialInitializer = true; - } - } - }); - } - } - function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { - var declarations = symbol.declarations; - for (var i = 0; i < declarations.length; i++) { - var declaration = declarations[i]; - if ((declaration.kind === 185 /* ClassDeclaration */ || (declaration.kind === 184 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { - return declaration; - } - } - return undefined; - } - function checkModuleDeclaration(node) { - if (fullTypeCheck) { - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - checkExportsOnMergedDeclarations(node); - var symbol = getSymbolOfNode(node); - if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) { - var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); - if (classOrFunc) { - if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(classOrFunc)) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged); - } - else if (node.pos < classOrFunc.pos) { - error(node.name, ts.Diagnostics.A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); - } - } - } - if (node.name.kind === 7 /* StringLiteral */) { - if (!isGlobalSourceFile(node.parent)) { - error(node.name, ts.Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules); - } - if (isExternalModuleNameRelative(node.name.text)) { - error(node.name, ts.Diagnostics.Ambient_external_module_declaration_cannot_specify_relative_module_name); - } - } - } - checkSourceElement(node.body); - } - function getFirstIdentifier(node) { - while (node.kind === 120 /* QualifiedName */) { - node = node.left; - } - return node; - } - function checkImportDeclaration(node) { - checkCollisionWithCapturedThisVariable(node, node.name); - checkCollisionWithRequireExportsInGeneratedCode(node, node.name); - var symbol = getSymbolOfNode(node); - var target; - if (ts.isInternalModuleImportDeclaration(node)) { - target = resolveImport(symbol); - if (target !== unknownSymbol) { - if (target.flags & 107455 /* Value */) { - var moduleName = getFirstIdentifier(node.moduleReference); - if (resolveEntityName(node, moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */) { - checkExpressionOrQualifiedName(node.moduleReference); - } - else { - error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); - } - } - if (target.flags & 3152352 /* Type */) { - checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); - } - } - } - else { - if (node.parent.kind === 201 /* SourceFile */) { - target = resolveImport(symbol); - } - else if (node.parent.kind === 190 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { - if (ts.getExternalModuleImportDeclarationExpression(node).kind === 7 /* StringLiteral */) { - if (isExternalModuleNameRelative(ts.getExternalModuleImportDeclarationExpression(node).text)) { - error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); - target = unknownSymbol; - } - else { - target = resolveImport(symbol); - } - } - else { - target = unknownSymbol; - } - } - else { - target = unknownSymbol; - } - } - if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | (symbol.flags & 3152352 /* Type */ ? 3152352 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); - if (target.flags & excludedMeanings) { - error(node, ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0, symbolToString(symbol)); - } - } - } - function checkExportAssignment(node) { - var container = node.parent; - if (container.kind !== 201 /* SourceFile */) { - container = container.parent; - } - checkTypeOfExportAssignmentSymbol(getSymbolOfNode(container)); - } - function checkSourceElement(node) { - if (!node) - return; - switch (node.kind) { - case 122 /* TypeParameter */: - return checkTypeParameter(node); - case 123 /* Parameter */: - return checkParameter(node); - case 124 /* Property */: - return checkPropertyDeclaration(node); - case 133 /* FunctionType */: - case 134 /* ConstructorType */: - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - return checkSignatureDeclaration(node); - case 125 /* Method */: - return checkMethodDeclaration(node); - case 126 /* Constructor */: - return checkConstructorDeclaration(node); - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - return checkAccessorDeclaration(node); - case 132 /* TypeReference */: - return checkTypeReference(node); - case 135 /* TypeQuery */: - return checkTypeQuery(node); - case 136 /* TypeLiteral */: - return checkTypeLiteral(node); - case 137 /* ArrayType */: - return checkArrayType(node); - case 138 /* TupleType */: - return checkTupleType(node); - case 139 /* UnionType */: - return checkUnionType(node); - case 140 /* ParenthesizedType */: - return checkSourceElement(node.type); - case 184 /* FunctionDeclaration */: - return checkFunctionDeclaration(node); - case 163 /* Block */: - case 190 /* ModuleBlock */: - return checkBlock(node); - case 164 /* VariableStatement */: - return checkVariableStatement(node); - case 166 /* ExpressionStatement */: - return checkExpressionStatement(node); - case 167 /* IfStatement */: - return checkIfStatement(node); - case 168 /* DoStatement */: - return checkDoStatement(node); - case 169 /* WhileStatement */: - return checkWhileStatement(node); - case 170 /* ForStatement */: - return checkForStatement(node); - case 171 /* ForInStatement */: - return checkForInStatement(node); - case 172 /* ContinueStatement */: - case 173 /* BreakStatement */: - return checkBreakOrContinueStatement(node); - case 174 /* ReturnStatement */: - return checkReturnStatement(node); - case 175 /* WithStatement */: - return checkWithStatement(node); - case 176 /* SwitchStatement */: - return checkSwitchStatement(node); - case 177 /* LabeledStatement */: - return checkLabeledStatement(node); - case 178 /* ThrowStatement */: - return checkThrowStatement(node); - case 179 /* TryStatement */: - return checkTryStatement(node); - case 183 /* VariableDeclaration */: - return ts.Debug.fail("Checker encountered variable declaration"); - case 185 /* ClassDeclaration */: - return checkClassDeclaration(node); - case 186 /* InterfaceDeclaration */: - return checkInterfaceDeclaration(node); - case 187 /* TypeAliasDeclaration */: - return checkTypeAliasDeclaration(node); - case 188 /* EnumDeclaration */: - return checkEnumDeclaration(node); - case 189 /* ModuleDeclaration */: - return checkModuleDeclaration(node); - case 191 /* ImportDeclaration */: - return checkImportDeclaration(node); - case 192 /* ExportAssignment */: - return checkExportAssignment(node); - } - } - function checkFunctionExpressionBodies(node) { - switch (node.kind) { - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - ts.forEach(node.parameters, checkFunctionExpressionBodies); - checkFunctionExpressionOrObjectLiteralMethodBody(node); - break; - case 125 /* Method */: - ts.forEach(node.parameters, checkFunctionExpressionBodies); - if (ts.isObjectLiteralMethod(node)) { - checkFunctionExpressionOrObjectLiteralMethodBody(node); - } - break; - case 126 /* Constructor */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - case 184 /* FunctionDeclaration */: - ts.forEach(node.parameters, checkFunctionExpressionBodies); - break; - case 175 /* WithStatement */: - checkFunctionExpressionBodies(node.expression); - break; - case 123 /* Parameter */: - case 124 /* Property */: - case 141 /* ArrayLiteralExpression */: - case 142 /* ObjectLiteralExpression */: - case 198 /* PropertyAssignment */: - case 143 /* PropertyAccessExpression */: - case 144 /* ElementAccessExpression */: - case 145 /* CallExpression */: - case 146 /* NewExpression */: - case 147 /* TaggedTemplateExpression */: - case 159 /* TemplateExpression */: - case 162 /* TemplateSpan */: - case 148 /* TypeAssertionExpression */: - case 149 /* ParenthesizedExpression */: - case 153 /* TypeOfExpression */: - case 154 /* VoidExpression */: - case 152 /* DeleteExpression */: - case 155 /* PrefixUnaryExpression */: - case 156 /* PostfixUnaryExpression */: - case 157 /* BinaryExpression */: - case 158 /* ConditionalExpression */: - case 163 /* Block */: - case 190 /* ModuleBlock */: - case 164 /* VariableStatement */: - case 166 /* ExpressionStatement */: - case 167 /* IfStatement */: - case 168 /* DoStatement */: - case 169 /* WhileStatement */: - case 170 /* ForStatement */: - case 171 /* ForInStatement */: - case 172 /* ContinueStatement */: - case 173 /* BreakStatement */: - case 174 /* ReturnStatement */: - case 176 /* SwitchStatement */: - case 194 /* CaseClause */: - case 195 /* DefaultClause */: - case 177 /* LabeledStatement */: - case 178 /* ThrowStatement */: - case 179 /* TryStatement */: - case 180 /* TryBlock */: - case 197 /* CatchClause */: - case 181 /* FinallyBlock */: - case 183 /* VariableDeclaration */: - case 185 /* ClassDeclaration */: - case 188 /* EnumDeclaration */: - case 200 /* EnumMember */: - case 201 /* SourceFile */: - ts.forEachChild(node, checkFunctionExpressionBodies); - break; - } - } - function checkSourceFile(node) { - var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { - emitExtends = false; - potentialThisCollisions.length = 0; - ts.forEach(node.statements, checkSourceElement); - checkFunctionExpressionBodies(node); - if (ts.isExternalModule(node)) { - var symbol = getExportAssignmentSymbol(node.symbol); - if (symbol && symbol.flags & 33554432 /* Import */) { - getSymbolLinks(symbol).referenced = true; - } - } - if (potentialThisCollisions.length) { - ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope); - potentialThisCollisions.length = 0; - } - if (emitExtends) { - links.flags |= 8 /* EmitExtends */; - } - links.flags |= 1 /* TypeChecked */; - } - } - function getSortedDiagnostics() { - ts.Debug.assert(fullTypeCheck, "diagnostics are available only in the full typecheck mode"); - if (diagnosticsModified) { - diagnostics.sort(ts.compareDiagnostics); - diagnostics = ts.deduplicateSortedDiagnostics(diagnostics); - diagnosticsModified = false; - } - return diagnostics; - } - function getDiagnostics(sourceFile) { - if (sourceFile) { - checkSourceFile(sourceFile); - return ts.filter(getSortedDiagnostics(), function (d) { return d.file === sourceFile; }); - } - ts.forEach(program.getSourceFiles(), checkSourceFile); - return getSortedDiagnostics(); - } - function getDeclarationDiagnostics(targetSourceFile) { - var resolver = createResolver(); - checkSourceFile(targetSourceFile); - return ts.getDeclarationDiagnostics(program, resolver, targetSourceFile); - } - function getGlobalDiagnostics() { - return ts.filter(getSortedDiagnostics(), function (d) { return !d.file; }); - } - function isInsideWithStatementBody(node) { - if (node) { - while (node.parent) { - if (node.parent.kind === 175 /* WithStatement */ && node.parent.statement === node) { - return true; - } - node = node.parent; - } - } - return false; - } - function getSymbolsInScope(location, meaning) { - var symbols = {}; - var memberFlags = 0; - function copySymbol(symbol, meaning) { - if (symbol.flags & meaning) { - var id = symbol.name; - if (!isReservedMemberName(id) && !ts.hasProperty(symbols, id)) { - symbols[id] = symbol; - } - } - } - function copySymbols(source, meaning) { - if (meaning) { - for (var id in source) { - if (ts.hasProperty(source, id)) { - copySymbol(source[id], meaning); - } - } - } - } - if (isInsideWithStatementBody(location)) { - return []; - } - while (location) { - if (location.locals && !isGlobalSourceFile(location)) { - copySymbols(location.locals, meaning); - } - switch (location.kind) { - case 201 /* SourceFile */: - if (!ts.isExternalModule(location)) - break; - case 189 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 35653619 /* ModuleMember */); - break; - case 188 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); - break; - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - if (!(memberFlags & 128 /* Static */)) { - copySymbols(getSymbolOfNode(location).members, meaning & 3152352 /* Type */); - } - break; - case 150 /* FunctionExpression */: - if (location.name) { - copySymbol(location.symbol, meaning); - } - break; - case 197 /* CatchClause */: - if (location.name.text) { - copySymbol(location.symbol, meaning); - } - break; - } - memberFlags = location.flags; - location = location.parent; - } - copySymbols(globals, meaning); - return ts.mapToArray(symbols); - } - function isTypeDeclarationName(name) { - return name.kind == 63 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; - } - function isTypeDeclaration(node) { - switch (node.kind) { - case 122 /* TypeParameter */: - case 185 /* ClassDeclaration */: - case 186 /* InterfaceDeclaration */: - case 187 /* TypeAliasDeclaration */: - case 188 /* EnumDeclaration */: - return true; - } - } - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 120 /* QualifiedName */) - node = node.parent; - return node.parent && node.parent.kind === 132 /* TypeReference */; - } - function isTypeNode(node) { - if (132 /* FirstTypeNode */ <= node.kind && node.kind <= 140 /* LastTypeNode */) { - return true; - } - switch (node.kind) { - case 109 /* AnyKeyword */: - case 116 /* NumberKeyword */: - case 118 /* StringKeyword */: - case 110 /* BooleanKeyword */: - return true; - case 97 /* VoidKeyword */: - return node.parent.kind !== 154 /* VoidExpression */; - case 7 /* StringLiteral */: - return node.parent.kind === 123 /* Parameter */; - case 63 /* Identifier */: - if (node.parent.kind === 120 /* QualifiedName */ && node.parent.right === node) { - node = node.parent; - } - case 120 /* QualifiedName */: - ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 120 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); - var parent = node.parent; - if (parent.kind === 135 /* TypeQuery */) { - return false; - } - if (132 /* FirstTypeNode */ <= parent.kind && parent.kind <= 140 /* LastTypeNode */) { - return true; - } - switch (parent.kind) { - case 122 /* TypeParameter */: - return node === parent.constraint; - case 124 /* Property */: - case 123 /* Parameter */: - case 183 /* VariableDeclaration */: - return node === parent.type; - case 184 /* FunctionDeclaration */: - case 150 /* FunctionExpression */: - case 151 /* ArrowFunction */: - case 126 /* Constructor */: - case 125 /* Method */: - case 127 /* GetAccessor */: - case 128 /* SetAccessor */: - return node === parent.type; - case 129 /* CallSignature */: - case 130 /* ConstructSignature */: - case 131 /* IndexSignature */: - return node === parent.type; - case 148 /* TypeAssertionExpression */: - return node === parent.type; - case 145 /* CallExpression */: - case 146 /* NewExpression */: - return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; - case 147 /* TaggedTemplateExpression */: - return false; - } - } - return false; - } - function isInRightSideOfImportOrExportAssignment(node) { - while (node.parent.kind === 120 /* QualifiedName */) { - node = node.parent; - } - if (node.parent.kind === 191 /* ImportDeclaration */) { - return node.parent.moduleReference === node; - } - if (node.parent.kind === 192 /* ExportAssignment */) { - return node.parent.exportName === node; - } - return false; - } - function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 120 /* QualifiedName */ && node.parent.right === node) || (node.parent.kind === 143 /* PropertyAccessExpression */ && node.parent.name === node); - } - function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { - if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) { - return getSymbolOfNode(entityName.parent); - } - if (entityName.parent.kind === 192 /* ExportAssignment */) { - return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */ | 33554432 /* Import */); - } - if (entityName.kind !== 143 /* PropertyAccessExpression */) { - if (isInRightSideOfImportOrExportAssignment(entityName)) { - return getSymbolOfPartOfRightHandSideOfImport(entityName); - } - } - if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; - } - if (ts.isExpression(entityName)) { - if (ts.getFullWidth(entityName) === 0) { - return undefined; - } - if (entityName.kind === 63 /* Identifier */) { - var meaning = 107455 /* Value */ | 33554432 /* Import */; - return resolveEntityName(entityName, entityName, meaning); - } - else if (entityName.kind === 143 /* PropertyAccessExpression */) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkPropertyAccessExpression(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - else if (entityName.kind === 120 /* QualifiedName */) { - var symbol = getNodeLinks(entityName).resolvedSymbol; - if (!symbol) { - checkQualifiedName(entityName); - } - return getNodeLinks(entityName).resolvedSymbol; - } - } - else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 132 /* TypeReference */ ? 3152352 /* Type */ : 1536 /* Namespace */; - meaning |= 33554432 /* Import */; - return resolveEntityName(entityName, entityName, meaning); - } - return undefined; - } - function getSymbolInfo(node) { - if (isInsideWithStatementBody(node)) { - return undefined; - } - if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { - return getSymbolOfNode(node.parent); - } - if (node.kind === 63 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 192 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImport(node); - } - switch (node.kind) { - case 63 /* Identifier */: - case 143 /* PropertyAccessExpression */: - case 120 /* QualifiedName */: - return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 91 /* ThisKeyword */: - case 89 /* SuperKeyword */: - var type = checkExpression(node); - return type.symbol; - case 111 /* ConstructorKeyword */: - var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 126 /* Constructor */) { - return constructorDeclaration.parent.symbol; - } - return undefined; - case 7 /* StringLiteral */: - if (ts.isExternalModuleImportDeclaration(node.parent.parent) && ts.getExternalModuleImportDeclarationExpression(node.parent.parent) === node) { - var importSymbol = getSymbolOfNode(node.parent.parent); - var moduleType = getTypeOfSymbol(importSymbol); - return moduleType ? moduleType.symbol : undefined; - } - case 6 /* NumericLiteral */: - if (node.parent.kind == 144 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { - var objectType = checkExpression(node.parent.expression); - if (objectType === unknownType) - return undefined; - var apparentType = getApparentType(objectType); - if (apparentType === unknownType) - return undefined; - return getPropertyOfType(apparentType, node.text); - } - break; - } - return undefined; - } - function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 199 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location, location.name, 107455 /* Value */); - } - return undefined; - } - function getTypeOfNode(node) { - if (isInsideWithStatementBody(node)) { - return unknownType; - } - if (ts.isExpression(node)) { - return getTypeOfExpression(node); - } - if (isTypeNode(node)) { - return getTypeFromTypeNode(node); - } - if (isTypeDeclaration(node)) { - var symbol = getSymbolOfNode(node); - return getDeclaredTypeOfSymbol(symbol); - } - if (isTypeDeclarationName(node)) { - var symbol = getSymbolInfo(node); - return symbol && getDeclaredTypeOfSymbol(symbol); - } - if (ts.isDeclaration(node)) { - var symbol = getSymbolOfNode(node); - return getTypeOfSymbol(symbol); - } - if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { - var symbol = getSymbolInfo(node); - return symbol && getTypeOfSymbol(symbol); - } - if (isInRightSideOfImportOrExportAssignment(node)) { - var symbol = getSymbolInfo(node); - var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); - } - return unknownType; - } - function getTypeOfExpression(expr) { - if (isRightSideOfQualifiedNameOrPropertyAccess(expr)) { - expr = expr.parent; - } - return checkExpression(expr); - } - function getAugmentedPropertiesOfType(type) { - var type = getApparentType(type); - var propsByName = createSymbolTable(getPropertiesOfType(type)); - if (getSignaturesOfType(type, 0 /* Call */).length || getSignaturesOfType(type, 1 /* Construct */).length) { - ts.forEach(getPropertiesOfType(globalFunctionType), function (p) { - if (!ts.hasProperty(propsByName, p.name)) { - propsByName[p.name] = p; - } - }); - } - return getNamedMembers(propsByName); - } - function getRootSymbols(symbol) { - if (symbol.flags & 1073741824 /* UnionProperty */) { - var symbols = []; - var name = symbol.name; - ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { - symbols.push(getPropertyOfType(t, name)); - }); - return symbols; - } - else if (symbol.flags & 268435456 /* Transient */) { - var target = getSymbolLinks(symbol).target; - if (target) { - return [target]; - } - } - return [symbol]; - } - function isExternalModuleSymbol(symbol) { - return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 201 /* SourceFile */; - } - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } - function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name)) { - var symbolWithRelevantName = node.locals[name]; - if (symbolWithRelevantName.flags & (107455 /* Value */ | 4194304 /* ExportValue */)) { - return false; - } - if (symbolWithRelevantName.flags & 33554432 /* Import */) { - var importDeclarationWithRelevantName = ts.getDeclarationOfKind(symbolWithRelevantName, 191 /* ImportDeclaration */); - if (isReferencedImportDeclaration(importDeclarationWithRelevantName)) { - return false; - } - } - } - } - return true; - } - function getLocalNameOfContainer(container) { - var links = getNodeLinks(container); - if (!links.localModuleName) { - var prefix = ""; - var name = ts.unescapeIdentifier(container.name.text); - while (!isUniqueLocalName(ts.escapeIdentifier(prefix + name), container)) { - prefix += "_"; - } - links.localModuleName = prefix + ts.getTextOfNode(container.name); - } - return links.localModuleName; - } - function getLocalNameForSymbol(symbol, location) { - var node = location; - while (node) { - if ((node.kind === 189 /* ModuleDeclaration */ || node.kind === 188 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { - return getLocalNameOfContainer(node); - } - node = node.parent; - } - ts.Debug.fail("getLocalNameForSymbol failed"); - } - function getExpressionNamePrefix(node) { - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol) { - var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & 944 /* ExportHasLocal */)) { - symbol = exportSymbol; - } - if (symbol.parent) { - return isExternalModuleSymbol(symbol.parent) ? "exports" : getLocalNameForSymbol(getParentOfSymbol(symbol), node.parent); - } - } - } - function getExportAssignmentName(node) { - var symbol = getExportAssignmentSymbol(getSymbolOfNode(node)); - return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol) : undefined; - } - function isTopLevelValueImportWithEntityName(node) { - if (node.parent.kind !== 201 /* SourceFile */ || !ts.isInternalModuleImportDeclaration(node)) { - return false; - } - return isImportResolvedToValue(getSymbolOfNode(node)); - } - function hasSemanticErrors(sourceFile) { - return getDiagnostics(sourceFile).length > 0 || getGlobalDiagnostics().length > 0; - } - function isEmitBlocked(sourceFile) { - return program.getDiagnostics(sourceFile).length !== 0 || hasEarlyErrors(sourceFile) || (compilerOptions.noEmitOnError && getDiagnostics(sourceFile).length !== 0); - } - function hasEarlyErrors(sourceFile) { - return ts.forEach(getDiagnostics(sourceFile), function (d) { return d.isEarly; }); - } - function isImportResolvedToValue(symbol) { - var target = resolveImport(symbol); - return target !== unknownSymbol && target.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target); - } - function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; - } - function isReferencedImportDeclaration(node) { - var symbol = getSymbolOfNode(node); - if (getSymbolLinks(symbol).referenced) { - return true; - } - if (node.flags & 1 /* Export */) { - return isImportResolvedToValue(symbol); - } - return false; - } - function isImplementationOfOverload(node) { - if (node.body) { - var symbol = getSymbolOfNode(node); - var signaturesOfSymbol = getSignaturesOfSymbol(symbol); - return signaturesOfSymbol.length > 1 || (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node); - } - return false; - } - function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; - } - function getEnumMemberValue(node) { - computeEnumMemberValues(node.parent); - return getNodeLinks(node).enumMemberValue; - } - function getConstantValue(node) { - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { - var declaration = symbol.valueDeclaration; - var constantValue; - if (declaration.kind === 200 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { - return constantValue; - } - } - return undefined; - } - function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { - var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* CallSignature */ | 262144 /* ConstructSignature */)) ? getTypeOfSymbol(symbol) : unknownType; - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - } - function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { - var signature = getSignatureFromDeclaration(signatureDeclaration); - getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); - } - function createResolver() { - return { - getProgram: function () { return program; }, - getLocalNameOfContainer: getLocalNameOfContainer, - getExpressionNamePrefix: getExpressionNamePrefix, - getExportAssignmentName: getExportAssignmentName, - isReferencedImportDeclaration: isReferencedImportDeclaration, - getNodeCheckFlags: getNodeCheckFlags, - getEnumMemberValue: getEnumMemberValue, - isTopLevelValueImportWithEntityName: isTopLevelValueImportWithEntityName, - hasSemanticErrors: hasSemanticErrors, - isEmitBlocked: isEmitBlocked, - isDeclarationVisible: isDeclarationVisible, - isImplementationOfOverload: isImplementationOfOverload, - writeTypeOfDeclaration: writeTypeOfDeclaration, - writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, - isSymbolAccessible: isSymbolAccessible, - isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue - }; - } - function invokeEmitter(targetSourceFile) { - var resolver = createResolver(); - return ts.emitFiles(resolver, targetSourceFile); - } - function initializeTypeChecker() { - ts.forEach(program.getSourceFiles(), function (file) { - ts.bindSourceFile(file); - ts.forEach(file.semanticDiagnostics, addDiagnostic); - }); - ts.forEach(program.getSourceFiles(), function (file) { - if (!ts.isExternalModule(file)) { - extendSymbolTable(globals, file.locals); - } - }); - getSymbolLinks(undefinedSymbol).type = undefinedType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); - getSymbolLinks(unknownSymbol).type = unknownType; - globals[undefinedSymbol.name] = undefinedSymbol; - globalArraySymbol = getGlobalSymbol("Array"); - globalArrayType = getTypeOfGlobalSymbol(globalArraySymbol, 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - globalTemplateStringsArrayType = compilerOptions.target >= 2 /* ES6 */ ? getGlobalType("TemplateStringsArray") : unknownType; - } - initializeTypeChecker(); - return checker; - } - ts.createTypeChecker = createTypeChecker; -})(ts || (ts = {})); -var ts; -(function (ts) { - ts.optionDeclarations = [ - { - name: "charset", - type: "string" - }, - { - name: "codepage", - type: "number" - }, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file - }, - { - name: "diagnostics", - type: "boolean" - }, - { - name: "emitBOM", - type: "boolean" - }, - { - name: "help", - shortName: "h", - type: "boolean", - description: ts.Diagnostics.Print_this_message - }, - { - name: "locale", - type: "string" - }, - { - name: "mapRoot", - type: "string", - description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "module", - shortName: "m", - type: { - "commonjs": 1 /* CommonJS */, - "amd": 2 /* AMD */ - }, - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_or_amd, - paramType: ts.Diagnostics.KIND, - error: ts.Diagnostics.Argument_for_module_option_must_be_commonjs_or_amd - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_type_checking_errors_were_reported - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Warn_on_expressions_and_declarations_with_an_implied_any_type - }, - { - name: "noLib", - type: "boolean" - }, - { - name: "noLibCheck", - type: "boolean" - }, - { - name: "noResolve", - type: "boolean" - }, - { - name: "out", - type: "string", - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE - }, - { - name: "outDir", - type: "string", - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file - }, - { - name: "sourceRoot", - type: "string", - description: ts.Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures - }, - { - name: "target", - shortName: "t", - type: { "es3": 0 /* ES3 */, "es5": 1 /* ES5 */, "es6": 2 /* ES6 */ }, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, - paramType: ts.Diagnostics.VERSION, - error: ts.Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6 - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files - } - ]; - var shortOptionNames = {}; - var optionNameMap = {}; - ts.forEach(ts.optionDeclarations, function (option) { - optionNameMap[option.name.toLowerCase()] = option; - if (option.shortName) { - shortOptionNames[option.shortName] = option.name; - } - }); - function parseCommandLine(commandLine) { - var options = { - target: 0 /* ES3 */, - module: 0 /* None */ - }; - var filenames = []; - var errors = []; - parseStrings(commandLine); - return { - options: options, - filenames: filenames, - errors: errors - }; - function parseStrings(args) { - var i = 0; - while (i < args.length) { - var s = args[i++]; - if (s.charCodeAt(0) === 64 /* at */) { - parseResponseFile(s.slice(1)); - } - else if (s.charCodeAt(0) === 45 /* minus */) { - s = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); - if (ts.hasProperty(shortOptionNames, s)) { - s = shortOptionNames[s]; - } - if (ts.hasProperty(optionNameMap, s)) { - var opt = optionNameMap[s]; - if (!args[i] && opt.type !== "boolean") { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_expects_an_argument, opt.name)); - } - switch (opt.type) { - case "number": - options[opt.name] = parseInt(args[i++]); - break; - case "boolean": - options[opt.name] = true; - break; - case "string": - options[opt.name] = args[i++] || ""; - break; - default: - var map = opt.type; - var key = (args[i++] || "").toLowerCase(); - if (ts.hasProperty(map, key)) { - options[opt.name] = map[key]; - } - else { - errors.push(ts.createCompilerDiagnostic(opt.error)); - } - } - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_compiler_option_0, s)); - } - } - else { - filenames.push(s); - } - } - } - function parseResponseFile(filename) { - var text = ts.sys.readFile(filename); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, filename)); - return; - } - var args = []; - var pos = 0; - while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) - pos++; - if (pos >= text.length) - break; - var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { - pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) - pos++; - if (pos < text.length) { - args.push(text.substring(start + 1, pos)); - pos++; - } - else { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, filename)); - } - } - else { - while (text.charCodeAt(pos) > 32 /* space */) - pos++; - args.push(text.substring(start, pos)); - } - } - parseStrings(args); - } - } - ts.parseCommandLine = parseCommandLine; -})(ts || (ts = {})); -var ts; -(function (ts) { - var version = "1.4.0.0"; - function validateLocaleAndSetLanguage(locale, errors) { - var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); - if (!matchResult) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, 'en', 'ja-jp')); - return false; - } - var language = matchResult[1]; - var territory = matchResult[3]; - if (!trySetLanguageAndTerritory(language, territory, errors) && !trySetLanguageAndTerritory(language, undefined, errors)) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_locale_0, locale)); - return false; - } - return true; - } - function trySetLanguageAndTerritory(language, territory, errors) { - var compilerFilePath = ts.normalizePath(ts.sys.getExecutingFilePath()); - var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); - var filePath = ts.combinePaths(containingDirectoryPath, language); - if (territory) { - filePath = filePath + "-" + territory; - } - filePath = ts.sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); - if (!ts.sys.fileExists(filePath)) { - return false; - } - try { - var fileContents = ts.sys.readFile(filePath); - } - catch (e) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); - return false; - } - try { - ts.localizedDiagnosticMessages = JSON.parse(fileContents); - } - catch (e) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); - return false; - } - return true; - } - function countLines(program) { - var count = 0; - ts.forEach(program.getSourceFiles(), function (file) { - count += file.getLineAndCharacterFromPosition(file.end).line; - }); - return count; - } - function getDiagnosticText(message) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); - return diagnostic.messageText; - } - function reportDiagnostic(diagnostic) { - var output = ""; - if (diagnostic.file) { - var loc = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); - output += diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): "; - } - var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + ts.sys.newLine; - ts.sys.write(output); - } - function reportDiagnostics(diagnostics) { - for (var i = 0; i < diagnostics.length; i++) { - reportDiagnostic(diagnostics[i]); - } - } - function padLeft(s, length) { - while (s.length < length) { - s = " " + s; - } - return s; - } - function padRight(s, length) { - while (s.length < length) { - s = s + " "; - } - return s; - } - function reportStatisticalValue(name, value) { - ts.sys.write(padRight(name + ":", 12) + padLeft(value.toString(), 10) + ts.sys.newLine); - } - function reportCountStatistic(name, count) { - reportStatisticalValue(name, "" + count); - } - function reportTimeStatistic(name, time) { - reportStatisticalValue(name, (time / 1000).toFixed(2) + "s"); - } - function executeCommandLine(args) { - var commandLine = ts.parseCommandLine(args); - var compilerOptions = commandLine.options; - if (compilerOptions.locale) { - if (typeof JSON === "undefined") { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); - return ts.sys.exit(1); - } - validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); - } - if (commandLine.errors.length > 0) { - reportDiagnostics(commandLine.errors); - return ts.sys.exit(5 /* CompilerOptionsErrors */); - } - if (compilerOptions.version) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, version)); - return ts.sys.exit(0 /* Succeeded */); - } - if (compilerOptions.help) { - printVersion(); - printHelp(); - return ts.sys.exit(0 /* Succeeded */); - } - if (commandLine.filenames.length === 0) { - printVersion(); - printHelp(); - return ts.sys.exit(5 /* CompilerOptionsErrors */); - } - var defaultCompilerHost = ts.createCompilerHost(compilerOptions); - if (compilerOptions.watch) { - if (!ts.sys.watchFile) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); - return ts.sys.exit(5 /* CompilerOptionsErrors */); - } - watchProgram(commandLine, defaultCompilerHost); - } - else { - var result = compile(commandLine, defaultCompilerHost).exitStatus; - return ts.sys.exit(result); - } - } - ts.executeCommandLine = executeCommandLine; - function watchProgram(commandLine, compilerHost) { - var watchers = {}; - var updatedFiles = {}; - var program = compile(commandLine, compilerHost).program; - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); - addWatchers(program); - return; - function addWatchers(program) { - ts.forEach(program.getSourceFiles(), function (f) { - var filename = getCanonicalName(f.filename); - watchers[filename] = ts.sys.watchFile(filename, fileUpdated); - }); - } - function removeWatchers(program) { - ts.forEach(program.getSourceFiles(), function (f) { - var filename = getCanonicalName(f.filename); - if (ts.hasProperty(watchers, filename)) { - watchers[filename].close(); - } - }); - watchers = {}; - } - function fileUpdated(filename) { - var firstNotification = ts.isEmpty(updatedFiles); - updatedFiles[getCanonicalName(filename)] = true; - if (firstNotification) { - setTimeout(function () { - var changedFiles = updatedFiles; - updatedFiles = {}; - recompile(changedFiles); - }, 250); - } - } - function recompile(changedFiles) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.File_change_detected_Compiling)); - removeWatchers(program); - var oldSourceFiles = ts.arrayToMap(ts.filter(program.getSourceFiles(), function (file) { return !ts.hasProperty(changedFiles, getCanonicalName(file.filename)); }), function (file) { return getCanonicalName(file.filename); }); - var newCompilerHost = ts.clone(compilerHost); - newCompilerHost.getSourceFile = function (fileName, languageVersion, onError) { - fileName = getCanonicalName(fileName); - var sourceFile = ts.lookUp(oldSourceFiles, fileName); - if (sourceFile) { - return sourceFile; - } - return compilerHost.getSourceFile(fileName, languageVersion, onError); - }; - program = compile(commandLine, newCompilerHost).program; - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Compilation_complete_Watching_for_file_changes)); - addWatchers(program); - } - function getCanonicalName(fileName) { - return compilerHost.getCanonicalFileName(fileName); - } - } - function compile(commandLine, compilerHost) { - var parseStart = new Date().getTime(); - var compilerOptions = commandLine.options; - var program = ts.createProgram(commandLine.filenames, compilerOptions, compilerHost); - var bindStart = new Date().getTime(); - var errors = program.getDiagnostics(); - var exitStatus; - if (errors.length) { - var checkStart = bindStart; - var emitStart = bindStart; - var reportStart = bindStart; - exitStatus = 1 /* AllOutputGenerationSkipped */; - } - else { - var checker = program.getTypeChecker(true); - var checkStart = new Date().getTime(); - errors = checker.getDiagnostics(); - if (checker.isEmitBlocked()) { - exitStatus = 1 /* AllOutputGenerationSkipped */; - } - else { - var emitStart = new Date().getTime(); - var emitOutput = checker.emitFiles(); - var emitErrors = emitOutput.diagnostics; - exitStatus = emitOutput.emitResultStatus; - var reportStart = new Date().getTime(); - errors = ts.concatenate(errors, emitErrors); - } - } - reportDiagnostics(errors); - if (commandLine.options.diagnostics) { - var memoryUsed = ts.sys.getMemoryUsage ? ts.sys.getMemoryUsage() : -1; - reportCountStatistic("Files", program.getSourceFiles().length); - reportCountStatistic("Lines", countLines(program)); - reportCountStatistic("Nodes", checker ? checker.getNodeCount() : 0); - reportCountStatistic("Identifiers", checker ? checker.getIdentifierCount() : 0); - reportCountStatistic("Symbols", checker ? checker.getSymbolCount() : 0); - reportCountStatistic("Types", checker ? checker.getTypeCount() : 0); - if (memoryUsed >= 0) { - reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K"); - } - reportTimeStatistic("Parse time", bindStart - parseStart); - reportTimeStatistic("Bind time", checkStart - bindStart); - reportTimeStatistic("Check time", emitStart - checkStart); - reportTimeStatistic("Emit time", reportStart - emitStart); - reportTimeStatistic("Total time", reportStart - parseStart); - } - return { program: program, exitStatus: exitStatus }; - } - function printVersion() { - ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, version) + ts.sys.newLine); - } - function printHelp() { - var output = ""; - var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; - var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; - var marginLength = Math.max(syntaxLength, examplesLength); - var syntax = makePadding(marginLength - syntaxLength); - syntax += "tsc [" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + " ...]"; - output += getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax); - output += ts.sys.newLine + ts.sys.newLine; - var padding = makePadding(marginLength); - output += getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine; - output += padding + "tsc --out file.js file.ts" + ts.sys.newLine; - output += padding + "tsc @args.txt" + ts.sys.newLine; - output += ts.sys.newLine; - output += getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine; - var optsList = ts.optionDeclarations.slice(); - optsList.sort(function (a, b) { return ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()); }); - var marginLength = 0; - var usageColumn = []; - var descriptionColumn = []; - for (var i = 0; i < optsList.length; i++) { - var option = optsList[i]; - if (!option.description) { - continue; - } - var usageText = " "; - if (option.shortName) { - usageText += "-" + option.shortName; - usageText += getParamType(option); - usageText += ", "; - } - usageText += "--" + option.name; - usageText += getParamType(option); - usageColumn.push(usageText); - descriptionColumn.push(getDiagnosticText(option.description)); - marginLength = Math.max(usageText.length, marginLength); - } - var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; - usageColumn.push(usageText); - descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); - marginLength = Math.max(usageText.length, marginLength); - for (var i = 0; i < usageColumn.length; i++) { - var usage = usageColumn[i]; - var description = descriptionColumn[i]; - output += usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine; - } - ts.sys.write(output); - return; - function getParamType(option) { - if (option.paramType !== undefined) { - return " " + getDiagnosticText(option.paramType); - } - return ""; - } - function makePadding(paddingLength) { - return Array(paddingLength + 1).join(" "); - } - } -})(ts || (ts = {})); -ts.executeCommandLine(ts.sys.args); diff --git a/org.kevoree.modeling.java2typescript/pom.xml b/org.kevoree.modeling.java2typescript/pom.xml deleted file mode 100644 index adde1e1..0000000 --- a/org.kevoree.modeling.java2typescript/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - 4.0.0 - - org.kevoree.modeling - org.kevoree.modeling.java2typescript - Kevoree :: Modeling :: Java2TypeScript - - - org.kevoree.modeling.java2typescript.root - org.kevoree.modeling - 28-SNAPSHOT - ../pom.xml - - - - - org.kevoree.modeling.idea - org.kevoree.modeling.idea.dsl - ${kmf.plugin.version} - - - junit - junit - 4.11 - test - - - - \ No newline at end of file diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/FlatJUnitGenerator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/FlatJUnitGenerator.java deleted file mode 100644 index 84e0225..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/FlatJUnitGenerator.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.kevoree.modeling.java2typescript; - -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.psi.*; -import org.jetbrains.annotations.NotNull; -import org.kevoree.modeling.java2typescript.translators.ClassTranslator; - -import java.io.File; -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.FileVisitor; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.attribute.BasicFileAttributes; - -/** - * Created by gregory.nain on 03/12/14. - */ -public class FlatJUnitGenerator { - - public void generate(File sourceDir, File targetDir ) { - try { - - - StringBuilder sb = new StringBuilder(); - sb.append("package gentest;\n\n"); - sb.append("public class FlatJUnitTest {\n\n"); - sb.append("public void run() {\n"); - - JavaAnalyzer javaAnalyzer = new JavaAnalyzer(); - PsiDirectory parsedDir = javaAnalyzer.analyze(sourceDir); - parsedDir.acceptChildren(new PsiElementVisitor() { - @Override - public void visitElement(PsiElement element) { - if (element instanceof PsiClass) { - sb.append(generateTestSuite((PsiClass) element)); - } else { - element.acceptChildren(this); - } - } - }); - - - sb.append("}\n"); - sb.append("}"); - - targetDir.mkdirs(); - File generatedTS = new File(targetDir, "FlatJUnitTest.java"); - FileUtil.writeToFile(generatedTS, sb.toString().getBytes()); - - } catch (IOException e) { - e.printStackTrace(); - } - - } - - private String instanciateClass(PsiClass clazz) { - - return "try {\n" + clazz.getQualifiedName() + " p_" + clazz.getName().toLowerCase() + " = new " + clazz.getQualifiedName() + "();\n"; - } - - - private String generateTestSuite(PsiClass clazz) { - StringBuilder sb = new StringBuilder(); - boolean classInstanciated = false; - for(PsiMethod method : clazz.getAllMethods()) { - PsiAnnotation testAnnot = method.getModifierList().findAnnotation("Test"); - if(testAnnot != null) { - if(!classInstanciated) { - sb.append(instanciateClass(clazz)); - classInstanciated = true; - } - sb.append("p_").append(clazz.getName().toLowerCase()).append(".").append(method.getName()).append("();\n"); - } - } - if(classInstanciated) { - sb.append("}catch(Exception e){\n e.printStackTrace();\n}\n"); - } - - return sb.toString(); - } - - - public static void main(String[] args) { - FlatJUnitGenerator generator = new FlatJUnitGenerator(); - generator.generate(new File("/Users/gregory.nain/Sources/KevoreeRepos/kevoree-modeling-framework/org.kevoree.modeling.microframework/src/test/java"), new File("/Users/gregory.nain/Sources/KevoreeRepos/kevoree-modeling-framework/org.kevoree.modeling.microframework.typescript/src/test/java")); - } - - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/JavaAnalyzer.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/JavaAnalyzer.java deleted file mode 100644 index 6c1d8ce..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/JavaAnalyzer.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.kevoree.modeling.java2typescript; - -import com.intellij.core.JavaCoreApplicationEnvironment; -import com.intellij.core.JavaCoreProjectEnvironment; -import com.intellij.openapi.Disposable; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.*; - -import java.io.File; -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.FileVisitor; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.attribute.BasicFileAttributes; - -/** - * Created by duke on 11/6/14. - */ -public class JavaAnalyzer { - - private JavaCoreProjectEnvironment environment; - - public JavaAnalyzer() { - environment = new JavaCoreProjectEnvironment(new Disposable() { - @Override - public void dispose() { - } - }, new JavaCoreApplicationEnvironment(new Disposable() { - @Override - public void dispose() { - } - })); - } - - public void addClasspath(String filePath) { - environment.addJarToClassPath(new File(filePath)); - } - - public PsiDirectory analyze(File srcDir) { - PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(environment.getProject()); - VirtualFile root_vf = environment.getEnvironment().getLocalFileSystem().findFileByIoFile(srcDir); - environment.addSourcesToClasspath(root_vf); - try { - Files.walkFileTree(srcDir.toPath(), new FileVisitor() { - public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - VirtualFile vf = environment.getEnvironment().getLocalFileSystem().findFileByIoFile(file.toFile()); - environment.addSourcesToClasspath(vf); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - return FileVisitResult.CONTINUE; - } - }); - } catch (IOException e) { - e.printStackTrace(); - } - PsiDirectory rootDirectory = PsiManager.getInstance(environment.getProject()).findDirectory(root_vf); - return rootDirectory; - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/SourceTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/SourceTranslator.java deleted file mode 100755 index a8b760b..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/SourceTranslator.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.kevoree.modeling.java2typescript; - -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.psi.*; -import org.kevoree.modeling.java2typescript.translators.ClassTranslator; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class SourceTranslator { - //private static final String baseDir = "/Users/duke/Documents/dev/dukeboard/kevoree-modeling-framework/org.kevoree.modeling.microframework/src/main/java"; - //private static final String baseDir = "/Users/duke/Documents/dev/dukeboard/kevoree-modeling-framework/org.kevoree.modeling.microframework.typescript/target/sources"; - //private static final String baseDir = "/Users/duke/IdeaProjects/kmf_mini/src/gen/java"; - private static final String baseDir = "/Users/gregory.nain/Sources/KevoreeRepos/kevoree-modeling-framework/org.kevoree.modeling.microframework/src/main/java"; - - public static void main(String[] args) throws IOException { - SourceTranslator sourceTranslator = new SourceTranslator(); - sourceTranslator.getAnalyzer().addClasspath("/Users/gregory.nain/.m2/repository/org/kevoree/modeling/org.kevoree.modeling.microframework/4.0.0-SNAPSHOT/org.kevoree.modeling.microframework-4.0.0-SNAPSHOT.jar"); - sourceTranslator.getAnalyzer().addClasspath("/Users/gregory.nain/.m2/repository/junit/junit/4.11/junit-4.11.jar"); - sourceTranslator.translateSources(baseDir, "target", "out"); - } - - private JavaAnalyzer analyzer; - - public JavaAnalyzer getAnalyzer() { - return analyzer; - } - - public SourceTranslator() { - analyzer = new JavaAnalyzer(); - } - - private static final String JAVA_D_TS = "java.d.ts"; - private static final String JAVA_JS = "java.js"; - - public void processPsiDirectory(boolean isRoot, PsiDirectory currentDir, TranslationContext ctx) { - if (!isRoot) { - ctx.print("export module "); - } else { - ctx.print("module "); - } - ctx.append(currentDir.getName()); - ctx.append(" {"); - ctx.append("\n"); - ctx.increaseIdent(); - List toTranslate = new ArrayList(); - currentDir.acceptChildren(new PsiElementVisitor() { - @Override - public void visitElement(PsiElement element) { - if (element instanceof PsiJavaFile) { - element.acceptChildren(this); - } else if (element instanceof PsiClass) { - if (!((PsiClass) element).getName().startsWith("NoJs_")) { - toTranslate.add((PsiClass) element); - } - } - } - }); - Collections.sort(toTranslate, new Comparator() { - @Override - public int compare(PsiClass o1, PsiClass o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - for (PsiClass clazz : toTranslate) { - ClassTranslator.translate(clazz, ctx); - } - - List subDirectories = new ArrayList(); - currentDir.acceptChildren(new PsiElementVisitor() { - @Override - public void visitElement(PsiElement element) { - if (element instanceof PsiDirectory) { - subDirectories.add((PsiDirectory) element); - } else { - element.acceptChildren(this); - } - } - }); - Collections.sort(subDirectories, new Comparator() { - @Override - public int compare(PsiDirectory o1, PsiDirectory o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - for (PsiDirectory subDir : subDirectories) { - processPsiDirectory(false, subDir, ctx); - } - - ctx.decreaseIdent(); - ctx.print("}"); - ctx.append("\n"); - } - - public void translateSources(String sourcePath, String outputPath, String name) throws IOException { - File sourceFolder = new File(sourcePath); - File targetFolder = new File(outputPath); - if (sourceFolder.exists()) { - if (sourceFolder.isFile()) { - throw new IllegalArgumentException("Source path is not a directory"); - } - } else { - sourceFolder.mkdirs(); - } - if (targetFolder.exists()) { - if (targetFolder.isFile()) { - throw new IllegalArgumentException("Target path is not a directory"); - } - } else { - targetFolder.mkdirs(); - } - //copy default library - File javaDTS = new File(targetFolder, JAVA_D_TS); - File javaJS = new File(targetFolder, JAVA_JS); - Files.copy(this.getClass().getClassLoader().getResourceAsStream(JAVA_D_TS), javaDTS.toPath(), StandardCopyOption.REPLACE_EXISTING); - Files.copy(this.getClass().getClassLoader().getResourceAsStream(JAVA_JS), javaJS.toPath(), StandardCopyOption.REPLACE_EXISTING); - - TranslationContext ctx = new TranslationContext(); - PsiDirectory root = analyzer.analyze(sourceFolder); - List subDirectories = new ArrayList(); - root.acceptChildren(new PsiElementVisitor() { - @Override - public void visitElement(PsiElement element) { - if (element instanceof PsiDirectory) { - subDirectories.add((PsiDirectory) element); - } else { - element.acceptChildren(this); - } - } - }); - Collections.sort(subDirectories, new Comparator() { - @Override - public int compare(PsiDirectory o1, PsiDirectory o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - for (PsiDirectory subDir : subDirectories) { - processPsiDirectory(true, subDir, ctx); - } - - File generatedTS = new File(targetFolder, name + ".ts"); - FileUtil.writeToFile(generatedTS, ctx.toString().getBytes()); - System.out.println("Transpile Java2TypeScript ended to " + generatedTS.getAbsolutePath()); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/TranslationContext.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/TranslationContext.java deleted file mode 100755 index 37dcd4d..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/TranslationContext.java +++ /dev/null @@ -1,59 +0,0 @@ - -package org.kevoree.modeling.java2typescript; - -public class TranslationContext { - - private StringBuilder sb = new StringBuilder(); - private static final int identSize = 4; - private int ident = 0; - - public void increaseIdent() { - ident += identSize; - } - - public void decreaseIdent() { - ident -= identSize; - if (ident < 0) { - throw new IllegalStateException("Decrease ident was called more times than increase"); - } - } - - public TranslationContext print(String str) { - ident(); - sb.append(str); - return this; - } - - public TranslationContext print(char str) { - ident(); - sb.append(str); - return this; - } - - public TranslationContext ident() { - for (int i = 0; i < ident; i++) { - sb.append(' '); - } - return this; - } - - public TranslationContext append(String str) { - sb.append(str); - return this; - } - - public TranslationContext append(char c) { - sb.append(c); - return this; - } - - public String getText() { - return sb.toString(); - } - - @Override - public String toString() { - return getText(); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/TypeHelper.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/TypeHelper.java deleted file mode 100755 index 17ff296..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/TypeHelper.java +++ /dev/null @@ -1,209 +0,0 @@ - -package org.kevoree.modeling.java2typescript; - -import com.google.common.collect.ImmutableSet; -import com.intellij.psi.*; -import com.intellij.psi.impl.source.PsiClassReferenceType; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Set; - -public class TypeHelper { - - public static String printType(PsiType element, TranslationContext ctx) { - return printType(element, ctx, true, false); - } - - public static String printType(PsiType element, TranslationContext ctx, boolean withGenericParams, boolean explicitType) { - String result = element.getPresentableText(); - if (objects.contains(result)) { - return "any"; - } else if (primitiveNumbers.contains(result) || objectNumbers.contains(result)) { - return "number"; - } else if (strings.contains(result)) { - return "string"; - } else if (booleans.contains(result)) { - return "boolean"; - } - - if (element instanceof PsiPrimitiveType) { - if (result == null || result.equals("null")) { - System.err.println("TypeHelper::printType -> Result null with elem:" + element.toString()); - } - return result; - } else if (element instanceof PsiArrayType) { - PsiArrayType typedElement = (PsiArrayType) element; - String partialResult = printType(typedElement.getComponentType(), ctx); - - if(typedElement.getComponentType() instanceof PsiClassReferenceType) { - PsiClass resolvedClass = ((PsiClassReferenceType)typedElement.getComponentType()).resolve(); - if (resolvedClass != null) { - if (isCallbackClass(resolvedClass) && !explicitType) { - //'{ (p: KEvent): void; }[]' is not assignable to type '(p: KEvent) => void[]'. - result = "{" + partialResult.replace("=>", ":") + ";}[]"; - return result; - } - } - } - result = partialResult + "[]"; - return result; - } else if (element instanceof PsiClassReferenceType) { - PsiClass resolvedClass = ((PsiClassReferenceType) element).resolve(); - if (resolvedClass != null) { - if (isCallbackClass(resolvedClass) && !explicitType) { - PsiMethod method = resolvedClass.getAllMethods()[0]; - PsiParameter[] parameters = method.getParameterList().getParameters(); - String[] methodParameters = new String[parameters.length]; - for (int i = 0; i < methodParameters.length; i++) { - PsiType parameterType = parameters[i].getType(); - for (int j = 0; j < resolvedClass.getTypeParameters().length; j++) { - if (resolvedClass.getTypeParameters()[j].getName().equals(parameterType.getPresentableText())) { - if (((PsiClassReferenceType) element).getParameters().length <= j) { - parameterType = null; - } else { - parameterType = ((PsiClassReferenceType) element).getParameters()[j]; - } - } - } - if (parameterType == null) { - methodParameters[i] = parameters[i].getName() + " : any"; - } else { - methodParameters[i] = parameters[i].getName() + " : " + printType(parameterType, ctx); - } - - } - result = "(" + String.join(", ", methodParameters) + ") => " + printType(method.getReturnType(), ctx); - return result; - } else { - String qualifiedName = resolvedClass.getQualifiedName(); - if (qualifiedName != null) { - result = resolvedClass.getQualifiedName(); - } - if (resolvedClass.getTypeParameters().length > 0) { - String[] generics = new String[resolvedClass.getTypeParameters().length]; - Arrays.fill(generics, "any"); - if (withGenericParams) { - result += "<" + String.join(", ", generics) + ">"; - } - } - } - } else { - String tryJavaUtil = javaTypes.get(((PsiClassReferenceType) element).getClassName()); - if (tryJavaUtil != null) { - result = tryJavaUtil; - } - if (((PsiClassReferenceType) element).getParameterCount() > 0) { - String[] generics = new String[((PsiClassReferenceType) element).getParameterCount()]; - PsiType[] genericTypes = ((PsiClassReferenceType) element).getParameters(); - for (int i = 0; i < genericTypes.length; i++) { - generics[i] = printType(genericTypes[i], ctx); - } - if (withGenericParams) { - result += "<" + String.join(", ", generics) + ">"; - } - } - } - } else { - System.err.println("TypeHelper: InstanceOf:" + element.getClass()); - } - - if (result == null || result.equals("null")) { - System.err.println("TypeHelper::printType -> Result null with elem:" + element.toString()); - } - - return result; - } - - public static boolean isCallbackClass(PsiClass clazz) { - if(clazz == null){ - return false; - } - return clazz.isInterface() && clazz.getAllMethods().length == 1; - } - - public static String primitiveStaticCall(String clazz) { - if(clazz.equals("String")) { - return "StringUtils"; - } - String result = javaTypes.get(clazz); - if (result != null) { - return result; - } - return clazz; - } - - - public static final HashMap javaTypes = new HashMap(); - - static { - javaTypes.put("Arrays", "java.util.Arrays"); - javaTypes.put("Collections", "java.util.Collections"); - javaTypes.put("Map", "java.util.Map"); - javaTypes.put("HashMap", "java.util.HashMap"); - javaTypes.put("List", "java.util.List"); - javaTypes.put("Set", "java.util.Set"); - javaTypes.put("HashSet", "java.util.HashSet"); - javaTypes.put("ArrayList", "java.util.ArrayList"); - javaTypes.put("LinkedList", "java.util.LinkedList"); - javaTypes.put("Random", "java.util.Random"); - - javaTypes.put("Long", "java.lang.Long"); - javaTypes.put("Double", "java.lang.Double"); - javaTypes.put("Float", "java.lang.Float"); - javaTypes.put("Integer", "java.lang.Integer"); - javaTypes.put("Short", "java.lang.Short"); - javaTypes.put("Boolean", "java.lang.Boolean"); - javaTypes.put("StringBuilder", "java.lang.StringBuilder"); - - javaTypes.put("Throwable", "java.lang.Throwable"); - javaTypes.put("Exception", "java.lang.Exception"); - javaTypes.put("Runnable", "java.lang.Runnable"); - javaTypes.put("RuntimeException", "java.lang.RuntimeException"); - javaTypes.put("IndexOutOfBoundsException", "java.lang.IndexOutOfBoundsException"); - javaTypes.put("WeakReference","java.lang.ref.WeakReference"); - } - - public static final Set primitiveNumbers = ImmutableSet.of("byte", "short", "int", "long", "float", "double"); - - public static final Set objectNumbers = ImmutableSet.of( - Byte.class.getName(), - Byte.class.getSimpleName(), - Short.class.getName(), - Short.class.getSimpleName(), - Integer.class.getName(), - Integer.class.getSimpleName(), - Long.class.getName(), - Long.class.getSimpleName(), - Float.class.getName(), - Float.class.getSimpleName(), - Double.class.getName(), - Double.class.getSimpleName(), - BigInteger.class.getName(), - BigInteger.class.getSimpleName(), - BigDecimal.class.getName(), - BigDecimal.class.getSimpleName() - ); - - public static final Set strings = ImmutableSet.of( - "char", - Character.class.getName(), - Character.class.getSimpleName(), - String.class.getName(), - String.class.getSimpleName() - ); - - public static final Set booleans = ImmutableSet.of( - "boolean", - Boolean.class.getName(), - Boolean.class.getSimpleName() - ); - - public static final Set objects = ImmutableSet.of( - Object.class.getName(), - Object.class.getSimpleName() - ); - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/AnonymousClassTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/AnonymousClassTranslator.java deleted file mode 100755 index fff6a58..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/AnonymousClassTranslator.java +++ /dev/null @@ -1,76 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators; - -import com.google.common.base.*; -import com.intellij.psi.*; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; - -import java.util.*; - -public class AnonymousClassTranslator { - - private static final Joiner joiner = Joiner.on(", "); - - public static void translate(PsiAnonymousClass element, TranslationContext ctx) { - - if (TypeHelper.isCallbackClass(element.getBaseClassType().resolve())) { - PsiMethod method = element.getAllMethods()[0]; - PsiParameter[] parameters = method.getParameterList().getParameters(); - String[] methodParameters = new String[parameters.length]; - for (int i = 0; i < methodParameters.length; i++) { - methodParameters[i] = parameters[i].getName() + " : " + TypeHelper.printType(parameters[i].getTypeElement().getType(), ctx); - } - // ctx.append("function(){\n"); - ctx.append(" (" + String.join(", ", methodParameters) + ") => {\n"); - if (method.getBody() != null) { - ctx.increaseIdent(); - CodeBlockTranslator.translate(method.getBody(), ctx); - ctx.decreaseIdent(); - } - ctx.print("}"); - //ctx.print("}()\n"); - } else { - ctx.append("{"); - ctx.increaseIdent(); - printClassMembers(element, ctx); - ctx.decreaseIdent(); - ctx.print("}"); - } - } - - private static void printClassMembers(PsiClass element, TranslationContext ctx) { - PsiMethod[] methods = element.getMethods(); - for (int i = 0; i < methods.length; i++) { - PsiMethod method = methods[i]; - ctx.append(method.getName()); - ctx.append(":function("); - printParameterList(method, ctx); - ctx.append("){\n"); - if (method.getBody() != null) { - CodeBlockTranslator.translate(method.getBody(), ctx); - } - ctx.append("}"); - if (i < methods.length - 1) { - ctx.append(", "); - } - } - } - - private static void printParameterList(PsiMethod element, TranslationContext ctx) { - List params = new ArrayList(); - for (PsiParameter parameter : element.getParameterList().getParameters()) { - StringBuilder paramSB = new StringBuilder(); - paramSB.setLength(0); - if (parameter.isVarArgs()) { - paramSB.append("..."); - } - paramSB.append(parameter.getName()); - paramSB.append(": "); - paramSB.append(TypeHelper.printType(parameter.getType(), ctx)); - params.add(paramSB.toString()); - } - ctx.append(joiner.join(params)); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/CodeBlockTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/CodeBlockTranslator.java deleted file mode 100644 index b608784..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/CodeBlockTranslator.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators; - -import com.intellij.psi.PsiCodeBlock; -import com.intellij.psi.PsiExpression; -import com.intellij.psi.PsiStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.statement.StatementTranslator; - -/** - * Created by duke on 11/6/14. - */ -public class CodeBlockTranslator { - - public static void translate(PsiCodeBlock block, TranslationContext ctx) { - for (PsiStatement statement : block.getStatements()) { - StatementTranslator.translate(statement, ctx); - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/FieldTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/FieldTranslator.java deleted file mode 100755 index efb1d92..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/FieldTranslator.java +++ /dev/null @@ -1,89 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators; - -import com.intellij.psi.*; -import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.psi.javadoc.PsiDocTag; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class FieldTranslator { - - public static void translate(PsiField element, TranslationContext ctx) { - //Check for native code - boolean nativeActivated = false; - boolean ignored = false; - PsiDocComment comment = element.getDocComment(); - if(comment != null) { - PsiDocTag[] tags = comment.getTags(); - if(tags != null) { - for(PsiDocTag tag : tags) { - if (tag.getName().equals(NativeTsTranslator.TAG) && tag.getValueElement()!=null && tag.getValueElement().getText().equals(NativeTsTranslator.TAG_VAL_TS)) { - nativeActivated = true; - } - if (tag.getName().equals(NativeTsTranslator.TAG_IGNORE) && tag.getValueElement()!=null && tag.getValueElement().getText().equals(NativeTsTranslator.TAG_VAL_TS)) { - ignored = true; - } - } - } - } - if(ignored){ - return; - } - if(!nativeActivated) { - if (element instanceof PsiEnumConstant) { - translateEnumConstant((PsiEnumConstant) element, ctx); - } else { - translateClassField(element, ctx); - } - } else { - NativeTsTranslator.translate(comment, ctx); - } - } - - private static void translateEnumConstant(PsiEnumConstant element, TranslationContext ctx) { - String enumName = ((PsiClass) element.getParent()).getName(); - ctx.print("public static ").append(element.getName()).append(": ").append(enumName); - ctx.append(" = new ").append(enumName); - ctx.append('('); - if (element.getArgumentList() != null) { - PsiExpression[] arguments = element.getArgumentList().getExpressions(); - for (int i = 0; i < arguments.length; i++) { - ExpressionTranslator.translate(arguments[i], ctx); - if (i != arguments.length - 1) { - ctx.append(", "); - } - } - } - ctx.append(");\n"); - } - - private static void translateClassField(PsiField element, TranslationContext ctx) { - PsiModifierList modifierList = element.getModifierList(); - if (modifierList != null && modifierList.hasModifierProperty("private")) { - ctx.print("private "); - } else { - ctx.print("public "); - } - if (modifierList != null && modifierList.hasModifierProperty("static")) { - ctx.append("static "); - } - ctx.append(element.getName()).append(": "); - ctx.append(TypeHelper.printType(element.getType(), ctx)); - if (element.hasInitializer()) { - ctx.append(" = "); - ExpressionTranslator.translate(element.getInitializer(), ctx); - ctx.append(";\n"); - } else { - /* - if (TypeHelper.isPrimitiveField(element)) { - ctx.append(" = 0"); - } else { - ctx.append(" = null"); - }*/ - ctx.append(";\n"); - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/JavaTokenTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/JavaTokenTranslator.java deleted file mode 100755 index 5aa8f1f..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/JavaTokenTranslator.java +++ /dev/null @@ -1,16 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators; - -import com.intellij.psi.PsiJavaToken; -import com.intellij.psi.impl.source.tree.ElementType; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class JavaTokenTranslator { - - public static void translate(PsiJavaToken element, TranslationContext ctx) { - if (ElementType.OPERATION_BIT_SET.contains(element.getTokenType())) { - ctx.append(element.getText()); - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/MethodTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/MethodTranslator.java deleted file mode 100644 index 7e0fbf1..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/MethodTranslator.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators; - -import com.intellij.psi.*; -import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.psi.javadoc.PsiDocTag; -import com.intellij.psi.javadoc.PsiDocTagValue; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by duke on 11/6/14. - */ -public class MethodTranslator { - - public static void translate(PsiMethod method, TranslationContext ctx) { - - boolean nativeActivated = false; - boolean ignore = false; - //Check for native code - PsiDocComment comment = method.getDocComment(); - if(comment != null) { - PsiDocTag[] tags = comment.getTags(); - if(tags != null) { - for(PsiDocTag tag : tags) { - if (tag.getName().equals(NativeTsTranslator.TAG) && tag.getValueElement()!=null && tag.getValueElement().getText().equals(NativeTsTranslator.TAG_VAL_TS)) { - nativeActivated = true; - } - if (tag.getName().equals(NativeTsTranslator.TAG_IGNORE) && tag.getValueElement()!=null && tag.getValueElement().getText().equals(NativeTsTranslator.TAG_VAL_TS)) { - ignore = true; - } - } - } - } - if(ignore){ - return; - } - PsiModifierList modifierList = method.getModifierList(); - if (method.isConstructor()) { - ctx.print("constructor"); - } else { - if (method.getContainingClass() != null && method.getContainingClass().isInterface()) { - ctx.print(""); - } else { - if (modifierList.hasModifierProperty("private")) { - ctx.print("private "); - } else { - ctx.print("public "); - } - } - if (modifierList.hasModifierProperty("static")) { - ctx.append("static "); - } - ctx.append(method.getName()); - PsiTypeParameter[] typeParameters = method.getTypeParameters(); - if (typeParameters.length > 0) { - ctx.append('<'); - for (int i = 0; i < typeParameters.length; i++) { - PsiTypeParameter p = typeParameters[i]; - ctx.append(p.getName()); - PsiClassType[] extentions = p.getExtendsList().getReferencedTypes(); - if (extentions.length > 0) { - ctx.append(" extends "); - for (PsiClassType ext : extentions) { - ctx.append(TypeHelper.printType(ext, ctx)); - } - } - if (i != typeParameters.length - 1) { - ctx.append(", "); - } - } - ctx.append("> "); - } - } - ctx.append('('); - List params = new ArrayList(); - StringBuilder paramSB = new StringBuilder(); - for (PsiParameter parameter : method.getParameterList().getParameters()) { - paramSB.setLength(0); - if (parameter.isVarArgs()) { - paramSB.append("..."); - } - paramSB.append(parameter.getName()); - paramSB.append(": "); - paramSB.append(TypeHelper.printType(parameter.getType(), ctx)); - params.add(paramSB.toString()); - } - ctx.append(String.join(", ", params)); - ctx.append(')'); - if (!method.isConstructor()) { - ctx.append(": "); - ctx.append(TypeHelper.printType(method.getReturnType(), ctx)); - } - PsiClass containingClass = (PsiClass) method.getParent(); - if (!containingClass.isInterface()) { - ctx.append(" {\n"); - ctx.increaseIdent(); - if(!nativeActivated) { - if (modifierList.hasModifierProperty("abstract") || method.getBody() == null) { - ctx.print("throw \"Abstract method\";\n"); - } else { - CodeBlockTranslator.translate(method.getBody(), ctx); - } - } else { - NativeTsTranslator.translate(comment, ctx); - } - ctx.decreaseIdent(); - ctx.print("}\n"); - } else { - ctx.append(";\n"); - } - ctx.append("\n"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/NativeTsTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/NativeTsTranslator.java deleted file mode 100644 index 59aa9dc..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/NativeTsTranslator.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators; - -import com.intellij.psi.javadoc.*; -import org.kevoree.modeling.java2typescript.TranslationContext; - -/** - * Created by gregory.nain on 08/01/15. - */ - -public class NativeTsTranslator { - - public static final String TAG = "native"; - - public static final String TAG_IGNORE = "ignore"; - - public static final String TAG_VAL_TS = "ts"; - - public static void translate(PsiDocComment comment, TranslationContext ctx) { - PsiDocTag[] tags = comment.getTags(); - for (PsiDocTag tag : tags) { - if (tag.getName().equals(NativeTsTranslator.TAG) && tag.getValueElement()!=null && tag.getValueElement().getText().equals(NativeTsTranslator.TAG_VAL_TS)) { - String value = tag.getText(); - String[] lines = value.split("\n"); - for (String line : lines) { - String trimmedLine = line.trim(); - if (trimmedLine.length() > 0 && !trimmedLine.contains("@"+TAG) && !trimmedLine.contains("@"+TAG_IGNORE)) { - if(trimmedLine.charAt(0) == '*'){ - trimmedLine = trimmedLine.substring(1); - } - ctx.print(trimmedLine).append("\n"); - } - } - } - } - } -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ArrayAccessExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ArrayAccessExpressionTranslator.java deleted file mode 100755 index 2a3961c..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ArrayAccessExpressionTranslator.java +++ /dev/null @@ -1,16 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiArrayAccessExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class ArrayAccessExpressionTranslator { - - public static void translate(PsiArrayAccessExpression element, TranslationContext ctx) { - ExpressionTranslator.translate(element.getArrayExpression(), ctx); - ctx.append('['); - ExpressionTranslator.translate(element.getIndexExpression(), ctx); - ctx.append(']'); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ArrayInitializerExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ArrayInitializerExpressionTranslator.java deleted file mode 100755 index 459c5fc..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ArrayInitializerExpressionTranslator.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiArrayInitializerExpression; -import com.intellij.psi.PsiExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class ArrayInitializerExpressionTranslator { - - public static void translate(PsiArrayInitializerExpression element, TranslationContext ctx) { - ctx.append("["); - PsiExpression[] initializers = element.getInitializers(); - if (initializers.length > 0) { - for (int i = 0; i < initializers.length; i++) { - ExpressionTranslator.translate(initializers[i], ctx); - if (i != initializers.length - 1) { - ctx.append(", "); - } - } - } - ctx.append("]"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/AssignmentExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/AssignmentExpressionTranslator.java deleted file mode 100755 index fcc0c11..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/AssignmentExpressionTranslator.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiAssignmentExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.JavaTokenTranslator; - -public class AssignmentExpressionTranslator { - - public static void translate(PsiAssignmentExpression element, TranslationContext ctx) { - ExpressionTranslator.translate(element.getLExpression(), ctx); - ctx.append(' '); - JavaTokenTranslator.translate(element.getOperationSign(), ctx); - ctx.append(' '); - ExpressionTranslator.translate(element.getRExpression(), ctx); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/BinaryExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/BinaryExpressionTranslator.java deleted file mode 100755 index 6f879a7..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/BinaryExpressionTranslator.java +++ /dev/null @@ -1,18 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiBinaryExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.JavaTokenTranslator; - -public class BinaryExpressionTranslator { - - public static void translate(PsiBinaryExpression element, TranslationContext ctx) { - ExpressionTranslator.translate(element.getLOperand(), ctx); - ctx.append(' '); - JavaTokenTranslator.translate(element.getOperationSign(), ctx); - ctx.append(' '); - ExpressionTranslator.translate(element.getROperand(), ctx); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ClassObjectAccessExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ClassObjectAccessExpressionTranslator.java deleted file mode 100755 index 9ae04e2..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ClassObjectAccessExpressionTranslator.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiClassObjectAccessExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; - -public class ClassObjectAccessExpressionTranslator { - - public static void translate(PsiClassObjectAccessExpression element, TranslationContext ctx) { - ctx.append(TypeHelper.printType(element.getOperand().getType(), ctx)); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ConditionalExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ConditionalExpressionTranslator.java deleted file mode 100755 index 57f3307..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ConditionalExpressionTranslator.java +++ /dev/null @@ -1,17 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiConditionalExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class ConditionalExpressionTranslator { - - public static void translate(PsiConditionalExpression element, TranslationContext ctx) { - ExpressionTranslator.translate(element.getCondition(), ctx); - ctx.append(" ? "); - ExpressionTranslator.translate(element.getThenExpression(), ctx); - ctx.append(" : "); - ExpressionTranslator.translate(element.getElseExpression(), ctx); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/InstanceOfExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/InstanceOfExpressionTranslator.java deleted file mode 100755 index 6138011..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/InstanceOfExpressionTranslator.java +++ /dev/null @@ -1,15 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiInstanceOfExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; - -public class InstanceOfExpressionTranslator { - - public static void translate(PsiInstanceOfExpression element, TranslationContext ctx) { - ExpressionTranslator.translate(element.getOperand(), ctx); - ctx.append(" instanceof ").append(TypeHelper.printType(element.getCheckType().getType(), ctx,false,false)); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/LiteralTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/LiteralTranslator.java deleted file mode 100755 index 5bcdbbf..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/LiteralTranslator.java +++ /dev/null @@ -1,18 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiLiteralExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class LiteralTranslator { - - public static void translate(PsiLiteralExpression element, TranslationContext ctx) { - String trimmed = element.getText().trim(); - if( !trimmed.toLowerCase().equals("null") && (trimmed.toLowerCase().endsWith("l") || trimmed.toLowerCase().endsWith("d"))) { - ctx.append(trimmed.substring(0, trimmed.length()-1)); - } else { - ctx.append(trimmed); - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/MethodCallExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/MethodCallExpressionTranslator.java deleted file mode 100755 index a5741e5..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/MethodCallExpressionTranslator.java +++ /dev/null @@ -1,25 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.*; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; - -public class MethodCallExpressionTranslator { - - public static void translate(PsiMethodCallExpression element, TranslationContext ctx) { - ReferenceExpressionTranslator.translate(element.getMethodExpression(), ctx); - if (!element.getMethodExpression().toString().endsWith(".length")) { - ctx.append('('); - PsiExpression[] arguments = element.getArgumentList().getExpressions(); - for (int i = 0; i < arguments.length; i++) { - ExpressionTranslator.translate(arguments[i], ctx); - if (i != arguments.length - 1) { - ctx.append(", "); - } - } - ctx.append(")"); - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/NewExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/NewExpressionTranslator.java deleted file mode 100755 index 7fa91fd..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/NewExpressionTranslator.java +++ /dev/null @@ -1,74 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.*; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; -import org.kevoree.modeling.java2typescript.translators.AnonymousClassTranslator; - -public class NewExpressionTranslator { - - public static void translate(PsiNewExpression element, TranslationContext ctx) { - PsiAnonymousClass anonymousClass = element.getAnonymousClass(); - if (anonymousClass != null) { - AnonymousClassTranslator.translate(anonymousClass, ctx); - } else { - boolean arrayDefinition = false; - PsiJavaCodeReferenceElement classReference = element.getClassReference(); - String className; - if (classReference != null) { - //PsiElement resolved = classReference.resolve(); - className = TypeHelper.printType(element.getType(), ctx); - } else { - className = TypeHelper.printType(element.getType().getDeepComponentType(), ctx); - arrayDefinition = true; - } - - PsiExpression[] arrayDimensions = element.getArrayDimensions(); - PsiArrayInitializerExpression arrayInitializer = element.getArrayInitializer(); - if (arrayDimensions.length > 0) { - arrayDefinition = true; - } - if (arrayInitializer != null) { - arrayDefinition = true; - } - if (!arrayDefinition) { - if (anonymousClass == null) { - ctx.append("new ").append(className).append('('); - if (element.getArgumentList() != null) { - PsiExpression[] arguments = element.getArgumentList().getExpressions(); - for (int i = 0; i < arguments.length; i++) { - ExpressionTranslator.translate(arguments[i], ctx); - if (i != arguments.length - 1) { - ctx.append(", "); - } - } - } - ctx.append(')'); - } - } else { - if (arrayInitializer != null) { - ctx.append("["); - PsiExpression[] arrayInitializers = arrayInitializer.getInitializers(); - for (int i = 0; i < arrayInitializers.length; i++) { - ExpressionTranslator.translate(arrayInitializers[i], ctx); - if (i != arrayInitializers.length - 1) { - ctx.append(", "); - } - } - ctx.append("]"); - } else { - int dimensionCount = arrayDimensions.length; - for (int i = 0; i < dimensionCount; i++) { - ctx.append("new Array("); - } - for (int i = 0; i < dimensionCount; i++) { - ctx.append(")"); - } - } - } - } - } -} - - diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ParenthesizedExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ParenthesizedExpressionTranslator.java deleted file mode 100755 index c66336b..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ParenthesizedExpressionTranslator.java +++ /dev/null @@ -1,15 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiParenthesizedExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class ParenthesizedExpressionTranslator { - - public static void translate(PsiParenthesizedExpression element, TranslationContext ctx) { - ctx.append('('); - ExpressionTranslator.translate(element.getExpression(), ctx); - ctx.append(')'); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/PolyadicExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/PolyadicExpressionTranslator.java deleted file mode 100755 index 0e2233c..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/PolyadicExpressionTranslator.java +++ /dev/null @@ -1,23 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiExpression; -import com.intellij.psi.PsiJavaToken; -import com.intellij.psi.PsiPolyadicExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.JavaTokenTranslator; - -public class PolyadicExpressionTranslator { - - public static void translate(PsiPolyadicExpression element, TranslationContext ctx) { - for (PsiExpression expression : element.getOperands()) { - PsiJavaToken token = element.getTokenBeforeOperand(expression); - if (token != null) { - ctx.append(' '); - JavaTokenTranslator.translate(token, ctx); - ctx.append(' '); - } - ExpressionTranslator.translate(expression, ctx); - } - } -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/PostfixExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/PostfixExpressionTranslator.java deleted file mode 100644 index 90f36c1..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/PostfixExpressionTranslator.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiPostfixExpression; -import com.intellij.psi.PsiPrefixExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.JavaTokenTranslator; - -/** - * Created by duke on 11/6/14. - */ -public class PostfixExpressionTranslator { - - public static void translate(PsiPostfixExpression element, TranslationContext ctx) { - ExpressionTranslator.translate(element.getOperand(), ctx); - JavaTokenTranslator.translate(element.getOperationSign(), ctx); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/PrefixExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/PrefixExpressionTranslator.java deleted file mode 100644 index fce6992..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/PrefixExpressionTranslator.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiPrefixExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.JavaTokenTranslator; - -/** - * Created by duke on 11/6/14. - */ -public class PrefixExpressionTranslator { - - public static void translate(PsiPrefixExpression element, TranslationContext ctx) { - JavaTokenTranslator.translate(element.getOperationSign(), ctx); - ExpressionTranslator.translate(element.getOperand(), ctx); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ReferenceExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ReferenceExpressionTranslator.java deleted file mode 100755 index d1dbe49..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ReferenceExpressionTranslator.java +++ /dev/null @@ -1,55 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.*; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; - -public class ReferenceExpressionTranslator { - - public static void translate(PsiReferenceExpression element, TranslationContext ctx) { - PsiElement resolution = element.resolve(); - if (element.getQualifierExpression() != null) { - ExpressionTranslator.translate(element.getQualifierExpression(), ctx); - if (resolution instanceof PsiMethod) { - PsiMethod method = (PsiMethod) resolution; - if (!TypeHelper.isCallbackClass(method.getContainingClass())) { - ctx.append('.'); - } - } else { - ctx.append('.'); - } - } else { - if (resolution != null) { - String qualifier = "this"; - if (resolution instanceof PsiField) { - PsiField field = (PsiField) resolution; - if (field.getModifierList() != null && field.getModifierList().hasModifierProperty("static")) { - qualifier = field.getContainingClass().getName(); - } - ctx.append(qualifier).append('.'); - } else if (resolution instanceof PsiMethod) { - PsiMethod method = (PsiMethod) resolution; - if (method.getModifierList().hasModifierProperty("static")) { - qualifier = method.getContainingClass().getQualifiedName(); - } - if (!element.getReferenceName().equals("super")) { - ctx.append(qualifier).append('.'); - } - } else if (resolution instanceof PsiClass) { - PsiClass resolClazz = (PsiClass) resolution; - ctx.append(resolClazz.getQualifiedName().substring(0, resolClazz.getQualifiedName().lastIndexOf(".") + 1)); - } - } - } - if (resolution instanceof PsiMethod) { - PsiMethod method = (PsiMethod) resolution; - if (!TypeHelper.isCallbackClass(method.getContainingClass())) { - ctx.append(element.getReferenceName()); - } - } else { - ctx.append(TypeHelper.primitiveStaticCall(element.getReferenceName())); - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/SuperExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/SuperExpressionTranslator.java deleted file mode 100755 index 5cc2c65..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/SuperExpressionTranslator.java +++ /dev/null @@ -1,13 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiSuperExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class SuperExpressionTranslator { - - public static void translate(PsiSuperExpression element, TranslationContext ctx) { - ctx.append("super"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ThisExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ThisExpressionTranslator.java deleted file mode 100755 index 608861b..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ThisExpressionTranslator.java +++ /dev/null @@ -1,13 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiThisExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class ThisExpressionTranslator { - - public static void translate(PsiThisExpression element, TranslationContext ctx) { - ctx.append("this"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/TypeCastExpressionTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/TypeCastExpressionTranslator.java deleted file mode 100755 index 869e323..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/TypeCastExpressionTranslator.java +++ /dev/null @@ -1,15 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.expression; - -import com.intellij.psi.PsiTypeCastExpression; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; - -public class TypeCastExpressionTranslator { - - public static void translate(PsiTypeCastExpression element, TranslationContext ctx) { - ctx.append('<').append(TypeHelper.printType(element.getType(), ctx, true, false)).append('>'); - ExpressionTranslator.translate(element.getOperand(), ctx); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/BreakStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/BreakStatementTranslator.java deleted file mode 100755 index 06f869b..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/BreakStatementTranslator.java +++ /dev/null @@ -1,18 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiBreakStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class BreakStatementTranslator { - - public static void translate(PsiBreakStatement element, TranslationContext ctx) { - ctx.print("break"); - if (element.getLabelIdentifier() != null) { - ctx.append(' '); - ctx.append(element.getLabelIdentifier().getText().trim()); - } - ctx.append(";\n"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ContinueStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ContinueStatementTranslator.java deleted file mode 100755 index 4cbc1f1..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ContinueStatementTranslator.java +++ /dev/null @@ -1,18 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiContinueStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; - -public class ContinueStatementTranslator { - - public static void translate(PsiContinueStatement element, TranslationContext ctx) { - ctx.print("continue"); - if (element.getLabelIdentifier() != null) { - ctx.append(' '); - ctx.append(element.getLabelIdentifier().getText().trim()); - } - ctx.append(";\n"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/DeclarationStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/DeclarationStatementTranslator.java deleted file mode 100644 index 20ac175..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/DeclarationStatementTranslator.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiDeclarationStatement; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiLocalVariable; -import com.intellij.psi.PsiStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; - -/** - * Created by duke on 11/6/14. - */ -public class DeclarationStatementTranslator { - - public static void translate(PsiDeclarationStatement stmt, TranslationContext ctx) { - for (PsiElement element1 : stmt.getDeclaredElements()) { - if (element1 instanceof PsiStatement) { - StatementTranslator.translate((PsiStatement) element1, ctx); - } else if (element1 instanceof PsiLocalVariable) { - LocalVariableTranslator.translate((PsiLocalVariable) element1, ctx); - } else { - System.err.println("Not managed " + element1); - } - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/DoWhileStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/DoWhileStatementTranslator.java deleted file mode 100755 index 173ed7a..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/DoWhileStatementTranslator.java +++ /dev/null @@ -1,19 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiDoWhileStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class DoWhileStatementTranslator { - - public static void translate(PsiDoWhileStatement element, TranslationContext ctx) { - ctx.print("do {\n"); - ctx.increaseIdent(); - StatementTranslator.translate(element.getBody(), ctx); - ctx.decreaseIdent(); - ctx.print("} while ("); - ExpressionTranslator.translate(element.getCondition(),ctx); - ctx.append(")\n"); - } -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ExpressionStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ExpressionStatementTranslator.java deleted file mode 100755 index 7353e67..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ExpressionStatementTranslator.java +++ /dev/null @@ -1,26 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.*; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class ExpressionStatementTranslator { - - public static void translate(PsiExpressionStatement element, TranslationContext ctx) { - - boolean loopDeclaration = false; - PsiElement parent = element.getParent(); - if (parent instanceof PsiLoopStatement && !((PsiLoopStatement)parent).getBody().equals(element)) { - loopDeclaration = true; - } - if (!loopDeclaration) { - ctx.print(""); - } - ExpressionTranslator.translate(element.getExpression(),ctx); - if (!loopDeclaration) { - ctx.append(";\n"); - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ForEachStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ForEachStatementTranslator.java deleted file mode 100755 index d80947a..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ForEachStatementTranslator.java +++ /dev/null @@ -1,30 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiForeachStatement; -import com.intellij.psi.PsiParameter; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class ForEachStatementTranslator { - - public static void translate(PsiForeachStatement element, TranslationContext ctx) { - ctx.print("//TODO resolve for-each cycle\n"); - PsiParameter parameter = element.getIterationParameter(); - ctx.print("var "); - ctx.append(parameter.getName()); - ctx.append(": "); - ctx.append(TypeHelper.printType(parameter.getType(), ctx)); - ctx.append(";\n"); - ctx.print("for ("); - ctx.append(parameter.getName()); - ctx.append(" in "); - ExpressionTranslator.translate(element.getIteratedValue(), ctx); - ctx.append(") {\n"); - ctx.increaseIdent(); - StatementTranslator.translate(element.getBody(), ctx); - ctx.decreaseIdent(); - ctx.print("}\n"); - } -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ForStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ForStatementTranslator.java deleted file mode 100755 index cd337c1..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ForStatementTranslator.java +++ /dev/null @@ -1,30 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiForStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class ForStatementTranslator { - - public static void translate(PsiForStatement element, TranslationContext ctx) { - ctx.print("for ("); - if (element.getInitialization() != null) { - StatementTranslator.translate(element.getInitialization(), ctx); - } - ctx.append("; "); - if (element.getCondition() != null) { - ExpressionTranslator.translate(element.getCondition(), ctx); - } - ctx.append("; "); - if (element.getUpdate() != null) { - StatementTranslator.translate(element.getUpdate(), ctx); - } - ctx.append(") {\n"); - ctx.increaseIdent(); - StatementTranslator.translate(element.getBody(), ctx); - ctx.decreaseIdent(); - ctx.print("}\n"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/IfStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/IfStatementTranslator.java deleted file mode 100755 index ee9dcd0..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/IfStatementTranslator.java +++ /dev/null @@ -1,28 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiIfStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class IfStatementTranslator { - - public static void translate(PsiIfStatement element, TranslationContext ctx) { - ctx.print("if ("); - ExpressionTranslator.translate(element.getCondition(), ctx); - ctx.append(") {\n"); - ctx.increaseIdent(); - StatementTranslator.translate(element.getThenBranch(), ctx); - ctx.decreaseIdent(); - if (element.getElseElement() != null) { - ctx.print("} else {\n"); - ctx.increaseIdent(); - StatementTranslator.translate(element.getElseBranch(), ctx); - ctx.decreaseIdent(); - ctx.print("}\n"); - } else { - ctx.print("}\n"); - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/LocalVariableTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/LocalVariableTranslator.java deleted file mode 100755 index 0ac4711..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/LocalVariableTranslator.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.*; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class LocalVariableTranslator { - - public static void translate(PsiLocalVariable element, TranslationContext ctx) { - boolean loopDeclaration = false; - PsiElement parent = element.getParent(); - if (parent instanceof PsiDeclarationStatement) { - parent = parent.getParent(); - if (parent instanceof PsiLoopStatement) { - loopDeclaration = true; - } - } - if (loopDeclaration) { - ctx.append("var "); - } else { - ctx.print("var "); - } - ctx.append(element.getName()); - ctx.append(": "); - ctx.append(TypeHelper.printType(element.getType(), ctx)); - if (element.hasInitializer()) { - ctx.append(" = "); - ExpressionTranslator.translate(element.getInitializer(), ctx); - } - if (!loopDeclaration) { - ctx.append(";"); - ctx.append("\n"); - } - } -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ReturnStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ReturnStatementTranslator.java deleted file mode 100755 index a68a1d4..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ReturnStatementTranslator.java +++ /dev/null @@ -1,19 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiReturnStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class ReturnStatementTranslator { - - public static void translate(PsiReturnStatement element, TranslationContext ctx) { - ctx.print("return"); - if (element.getReturnValue() != null) { - ctx.append(' '); - ExpressionTranslator.translate(element.getReturnValue(),ctx); - } - ctx.append(";\n"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/SwitchLabelStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/SwitchLabelStatementTranslator.java deleted file mode 100755 index 29c3b46..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/SwitchLabelStatementTranslator.java +++ /dev/null @@ -1,20 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiSwitchLabelStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class SwitchLabelStatementTranslator { - - public static void translate(PsiSwitchLabelStatement element, TranslationContext ctx) { - if (element.isDefaultCase()) { - ctx.print("default: \n"); - } else { - ctx.print("case "); - ExpressionTranslator.translate(element.getCaseValue(), ctx); - ctx.append(": \n"); - } - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/SwitchStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/SwitchStatementTranslator.java deleted file mode 100755 index 52de55a..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/SwitchStatementTranslator.java +++ /dev/null @@ -1,21 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiSwitchStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.CodeBlockTranslator; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class SwitchStatementTranslator { - - public static void translate(PsiSwitchStatement element, TranslationContext ctx) { - ctx.print("switch ("); - ExpressionTranslator.translate(element.getExpression(), ctx); - ctx.append(") {\n"); - ctx.increaseIdent(); - CodeBlockTranslator.translate(element.getBody(), ctx); - ctx.decreaseIdent(); - ctx.print("}\n"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ThrowStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ThrowStatementTranslator.java deleted file mode 100755 index 6fcece8..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/ThrowStatementTranslator.java +++ /dev/null @@ -1,16 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiThrowStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class ThrowStatementTranslator { - - public static void translate(PsiThrowStatement element, TranslationContext ctx) { - ctx.print("throw "); - ExpressionTranslator.translate(element.getException(), ctx); - ctx.append(";\n"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/WhileStatementTranslator.java b/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/WhileStatementTranslator.java deleted file mode 100755 index f57205c..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/WhileStatementTranslator.java +++ /dev/null @@ -1,20 +0,0 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; - -import com.intellij.psi.PsiWhileStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.expression.ExpressionTranslator; - -public class WhileStatementTranslator { - - public static void translate(PsiWhileStatement element, TranslationContext ctx) { - ctx.print("while ("); - ExpressionTranslator.translate(element.getCondition(), ctx); - ctx.append("){\n"); - ctx.increaseIdent(); - StatementTranslator.translate(element.getBody(), ctx); - ctx.decreaseIdent(); - ctx.print("}\n"); - } - -} diff --git a/org.kevoree.modeling.java2typescript/src/main/resources/java.d.ts b/org.kevoree.modeling.java2typescript/src/main/resources/java.d.ts deleted file mode 100644 index 36d34f6..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/resources/java.d.ts +++ /dev/null @@ -1,167 +0,0 @@ -declare class System { - static gc(): void; - static out: { - println(obj?: any): void; - print(obj: any): void; - }; - static err: { - println(obj?: any): void; - print(obj: any): void; - }; - static arraycopy(src: Number[], srcPos: number, dest: Number[], destPos: number, numElements: number): void; -} -interface Number { - equals: (other: Number) => boolean; - longValue(): number; - floatValue(): number; - intValue(): number; - shortValue(): number; -} -interface String { - equals: (other: String) => boolean; - startsWith: (other: String) => boolean; - endsWith: (other: String) => boolean; - matches: (regEx: String) => boolean; - isEmpty: () => boolean; - hashCode: () => number; -} -declare class StringUtils { - static copyValueOf(data: string[], offset: number, count: number): string; -} -interface Boolean { - equals: (other: String) => boolean; -} -declare module java { - module lang { - class Double { - static parseDouble(val: string): number; - } - class Float { - static parseFloat(val: string): number; - } - class Integer { - static parseInt(val: string): number; - } - class Long { - static parseLong(val: string): number; - } - class Boolean { - static parseBoolean(val: string): boolean; - } - class Short { - static MIN_VALUE: number; - static MAX_VALUE: number; - static parseShort(val: string): number; - } - class Throwable { - private message; - private error; - constructor(message: string); - printStackTrace(): void; - } - class Exception extends Throwable { - } - class RuntimeException extends Exception { - } - class IndexOutOfBoundsException extends Exception { - } - interface Runnable { - run(): void; - } - class StringBuilder { - buffer: string; - length: number; - append(val: any): StringBuilder; - toString(): string; - } - module ref { - class WeakReference { - } - } - } - module util { - class Random { - nextInt(max: number): number; - nextDouble(): number; - } - class Arrays { - static fill(data: Number[], begin: number, nbElem: number, param: number): void; - } - class Collections { - static reverse(p: List): void; - static sort(p: List): void; - } - interface Collection { - add(val: T): void; - addAll(vals: Collection): any; - remove(val: T): any; - clear(): any; - isEmpty(): boolean; - size(): number; - contains(val: T): boolean; - toArray(a: Array): T[]; - } - class XArray { - constructor(); - pop(): any; - push(val: any): number; - splice(newS: any, arrL: any): void; - length: number; - indexOf(val: any): number; - shift(): any; - sort(): void; - } - class List extends XArray implements Collection { - addAll(vals: Collection): void; - clear(): void; - poll(): T; - remove(val: T): void; - toArray(a: Array): T[]; - size(): number; - add(val: T): void; - get(index: number): T; - contains(val: T): boolean; - isEmpty(): boolean; - } - class ArrayList extends List { - } - class LinkedList extends List { - } - class Map { - get(key: K): V; - put(key: K, value: V): V; - containsKey(key: K): boolean; - remove(key: K): V; - keySet(): Set; - isEmpty(): boolean; - values(): Set; - clear(): void; - } - class HashMap extends Map { - } - class Set implements Collection { - add(val: T): void; - clear(): void; - contains(val: T): boolean; - addAll(vals: Collection): void; - remove(val: T): void; - size(): number; - isEmpty(): boolean; - toArray(a: Array): T[]; - } - class HashSet extends Set { - } - } -} -declare module org { - module junit { - class Assert { - static assertNotNull(p: any): void; - static assertNull(p: any): void; - static assertEquals(p: any, p2: any): void; - static assertNotEquals(p: any, p2: any): void; - static assertTrue(b: boolean): void; - static assertFalse(b: boolean): void; - } - } -} diff --git a/org.kevoree.modeling.java2typescript/src/main/resources/java.js b/org.kevoree.modeling.java2typescript/src/main/resources/java.js deleted file mode 100644 index 54979da..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/resources/java.js +++ /dev/null @@ -1,495 +0,0 @@ -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var System = (function () { - function System() { - } - System.gc = function () { - }; - System.arraycopy = function (src, srcPos, dest, destPos, numElements) { - for (var i = 0; i < numElements; i++) { - dest[destPos + i] = src[srcPos + i]; - } - }; - System.out = { - println: function (obj) { - console.log(obj); - }, - print: function (obj) { - console.log(obj); - } - }; - System.err = { - println: function (obj) { - console.log(obj); - }, - print: function (obj) { - console.log(obj); - } - }; - return System; -})(); -Number.prototype.equals = function (other) { - return this == other; -}; -var StringUtils = (function () { - function StringUtils() { - } - StringUtils.copyValueOf = function (data, offset, count) { - var result = ""; - for (var i = offset; i < offset + count; i++) { - result += data[i]; - } - return result; - }; - return StringUtils; -})(); -String.prototype.matches = function (regEx) { - if (regEx == null) { - return false; - } - else { - var m = this.match(regEx); - return m != null && m.length > 0; - } -}; -String.prototype.isEmpty = function () { - return this.length == 0; -}; -String.prototype.equals = function (other) { - return this == other; -}; -String.prototype.hashCode = function () { - var hash = 0, i, chr, len; - if (this.length == 0) - return hash; - for (i = 0, len = this.length; i < len; i++) { - chr = this.charCodeAt(i); - hash = ((hash << 5) - hash) + chr; - hash |= 0; // Convert to 32bit integer - } - return hash; -}; -String.prototype.startsWith = function (other) { - return this.slice(0, other.length) == other; -}; -String.prototype.endsWith = function (other) { - return this.slice(-other.length) == other; -}; -Boolean.prototype.equals = function (other) { - return this == other; -}; -var java; -(function (java) { - var lang; - (function (lang) { - var Double = (function () { - function Double() { - } - Double.parseDouble = function (val) { - return +val; - }; - return Double; - })(); - lang.Double = Double; - var Float = (function () { - function Float() { - } - Float.parseFloat = function (val) { - return +val; - }; - return Float; - })(); - lang.Float = Float; - var Integer = (function () { - function Integer() { - } - Integer.parseInt = function (val) { - return +val; - }; - return Integer; - })(); - lang.Integer = Integer; - var Long = (function () { - function Long() { - } - Long.parseLong = function (val) { - return +val; - }; - return Long; - })(); - lang.Long = Long; - var Boolean = (function () { - function Boolean() { - } - Boolean.parseBoolean = function (val) { - return val == "true"; - }; - return Boolean; - })(); - lang.Boolean = Boolean; - var Short = (function () { - function Short() { - } - Short.parseShort = function (val) { - return +val; - }; - Short.MIN_VALUE = -0x8000; - Short.MAX_VALUE = 0x7FFF; - return Short; - })(); - lang.Short = Short; - var Throwable = (function () { - function Throwable(message) { - this.message = message; - this.error = new Error(message); - } - Throwable.prototype.printStackTrace = function () { - console.error(this.error['stack']); - }; - return Throwable; - })(); - lang.Throwable = Throwable; - var Exception = (function (_super) { - __extends(Exception, _super); - function Exception() { - _super.apply(this, arguments); - } - return Exception; - })(Throwable); - lang.Exception = Exception; - var RuntimeException = (function (_super) { - __extends(RuntimeException, _super); - function RuntimeException() { - _super.apply(this, arguments); - } - return RuntimeException; - })(Exception); - lang.RuntimeException = RuntimeException; - var IndexOutOfBoundsException = (function (_super) { - __extends(IndexOutOfBoundsException, _super); - function IndexOutOfBoundsException() { - _super.apply(this, arguments); - } - return IndexOutOfBoundsException; - })(Exception); - lang.IndexOutOfBoundsException = IndexOutOfBoundsException; - var StringBuilder = (function () { - function StringBuilder() { - this.buffer = ""; - this.length = 0; - } - StringBuilder.prototype.append = function (val) { - this.buffer = this.buffer + val; - length = this.buffer.length; - return this; - }; - StringBuilder.prototype.toString = function () { - return this.buffer; - }; - return StringBuilder; - })(); - lang.StringBuilder = StringBuilder; - var ref; - (function (ref) { - var WeakReference = (function () { - function WeakReference() { - } - return WeakReference; - })(); - ref.WeakReference = WeakReference; - })(ref = lang.ref || (lang.ref = {})); - })(lang = java.lang || (java.lang = {})); - var util; - (function (util) { - var Random = (function () { - function Random() { - } - Random.prototype.nextInt = function (max) { - return Math.random() * max; - }; - Random.prototype.nextDouble = function () { - return Math.random(); - }; - return Random; - })(); - util.Random = Random; - var Arrays = (function () { - function Arrays() { - } - Arrays.fill = function (data, begin, nbElem, param) { - var max = begin + nbElem; - for (var i = begin; i < max; i++) { - data[i] = param; - } - }; - return Arrays; - })(); - util.Arrays = Arrays; - var Collections = (function () { - function Collections() { - } - Collections.reverse = function (p) { - var temp = new List(); - for (var i = 0; i < p.size(); i++) { - temp.add(p.get(i)); - } - p.clear(); - for (var i = temp.size() - 1; i >= 0; i--) { - p.add(temp.get(i)); - } - }; - Collections.sort = function (p) { - p.sort(); - }; - return Collections; - })(); - util.Collections = Collections; - var XArray = (function () { - function XArray() { - Array.apply(this, arguments); - return new Array(); - } - XArray.prototype.pop = function () { - return ""; - }; - XArray.prototype.push = function (val) { - return 0; - }; - XArray.prototype.splice = function (newS, arrL) { - }; - XArray.prototype.indexOf = function (val) { - return 0; - }; - XArray.prototype.shift = function () { - return ""; - }; - XArray.prototype.sort = function () { - }; - return XArray; - })(); - util.XArray = XArray; - XArray["prototype"] = new Array(); - var List = (function (_super) { - __extends(List, _super); - function List() { - _super.apply(this, arguments); - } - List.prototype.addAll = function (vals) { - var tempArray = vals.toArray(null); - for (var i = 0; i < tempArray.length; i++) { - this.push(tempArray[i]); - } - }; - List.prototype.clear = function () { - this.length = 0; - }; - List.prototype.poll = function () { - return this.shift(); - }; - List.prototype.remove = function (val) { - }; - List.prototype.toArray = function (a) { - return this; - }; - List.prototype.size = function () { - return this.length; - }; - List.prototype.add = function (val) { - this.push(val); - }; - List.prototype.get = function (index) { - return this[index]; - }; - List.prototype.contains = function (val) { - return this.indexOf(val) != -1; - }; - List.prototype.isEmpty = function () { - return this.length == 0; - }; - return List; - })(XArray); - util.List = List; - var ArrayList = (function (_super) { - __extends(ArrayList, _super); - function ArrayList() { - _super.apply(this, arguments); - } - return ArrayList; - })(List); - util.ArrayList = ArrayList; - var LinkedList = (function (_super) { - __extends(LinkedList, _super); - function LinkedList() { - _super.apply(this, arguments); - } - return LinkedList; - })(List); - util.LinkedList = LinkedList; - var Map = (function () { - function Map() { - } - Map.prototype.get = function (key) { - return this[key]; - }; - Map.prototype.put = function (key, value) { - var previous_val = this[key]; - this[key] = value; - return previous_val; - }; - Map.prototype.containsKey = function (key) { - return this.hasOwnProperty(key); - }; - Map.prototype.remove = function (key) { - var tmp = this[key]; - delete this[key]; - return tmp; - }; - Map.prototype.keySet = function () { - var result = new HashSet(); - for (var p in this) { - if (this.hasOwnProperty(p)) { - result.add(p); - } - } - return result; - }; - Map.prototype.isEmpty = function () { - return Object.keys(this).length == 0; - }; - Map.prototype.values = function () { - var result = new HashSet(); - for (var p in this) { - if (this.hasOwnProperty(p)) { - result.add(this[p]); - } - } - return result; - }; - Map.prototype.clear = function () { - for (var p in this) { - if (this.hasOwnProperty(p)) { - delete this[p]; - } - } - }; - return Map; - })(); - util.Map = Map; - var HashMap = (function (_super) { - __extends(HashMap, _super); - function HashMap() { - _super.apply(this, arguments); - } - return HashMap; - })(Map); - util.HashMap = HashMap; - var Set = (function () { - function Set() { - } - Set.prototype.add = function (val) { - this[val] = val; - }; - Set.prototype.clear = function () { - for (var p in this) { - if (this.hasOwnProperty(p)) { - delete this[p]; - } - } - }; - Set.prototype.contains = function (val) { - return this.hasOwnProperty(val); - }; - Set.prototype.addAll = function (vals) { - var tempArray = vals.toArray(null); - for (var i = 0; i < tempArray.length; i++) { - this[tempArray[i]] = tempArray[i]; - } - }; - Set.prototype.remove = function (val) { - delete this[val]; - }; - Set.prototype.size = function () { - return Object.keys(this).length; - }; - Set.prototype.isEmpty = function () { - return this.size() == 0; - }; - Set.prototype.toArray = function (a) { - for (var ik in this) { - a.push(this[ik]); - } - return a; - }; - return Set; - })(); - util.Set = Set; - var HashSet = (function (_super) { - __extends(HashSet, _super); - function HashSet() { - _super.apply(this, arguments); - } - return HashSet; - })(Set); - util.HashSet = HashSet; - })(util = java.util || (java.util = {})); -})(java || (java = {})); -var org; -(function (org) { - var junit; - (function (junit) { - var Assert = (function () { - function Assert() { - } - Assert.assertNotNull = function (p) { - if (p == null) { - throw "Assert Error " + p + " must not be null"; - } - }; - Assert.assertNull = function (p) { - if (p != null) { - throw "Assert Error " + p + " must be null"; - } - }; - Assert.assertEquals = function (p, p2) { - if (p.equals !== undefined) { - if (!p.equals(p2)) { - throw "Assert Error \n" + p + "\n must be equal to \n" + p2 + "\n"; - } - } - else { - if (p != p2) { - throw "Assert Error \n" + p + "\n must be equal to \n" + p2 + "\n"; - } - } - }; - Assert.assertNotEquals = function (p, p2) { - if (p.equals !== undefined) { - if (p.equals(p2)) { - throw "Assert Error \n" + p + "\n must not be equal to \n" + p2 + "\n"; - } - } - else { - if (p == p2) { - throw "Assert Error \n" + p + "\n must not be equal to \n" + p2 + "\n"; - } - } - }; - Assert.assertTrue = function (b) { - if (!b) { - throw "Assert Error " + b + " must be true"; - } - }; - Assert.assertFalse = function (b) { - if (b) { - throw "Assert Error " + b + " must be false"; - } - }; - return Assert; - })(); - junit.Assert = Assert; - })(junit = org.junit || (org.junit = {})); -})(org || (org = {})); diff --git a/org.kevoree.modeling.java2typescript/src/main/resources/java.js.map b/org.kevoree.modeling.java2typescript/src/main/resources/java.js.map deleted file mode 100644 index b87bf31..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/resources/java.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"java.js","sourceRoot":"","sources":["java.ts"],"names":["System","System.constructor","System.gc","System.arraycopy","System.println","System.print","StringUtils","StringUtils.constructor","StringUtils.copyValueOf","java","java.lang","java.lang.Double","java.lang.Double.constructor","java.lang.Double.parseDouble","java.lang.Float","java.lang.Float.constructor","java.lang.Float.parseFloat","java.lang.Integer","java.lang.Integer.constructor","java.lang.Integer.parseInt","java.lang.Long","java.lang.Long.constructor","java.lang.Long.parseLong","java.lang.Boolean","java.lang.Boolean.constructor","java.lang.Boolean.parseBoolean","java.lang.Short","java.lang.Short.constructor","java.lang.Short.parseShort","java.lang.Throwable","java.lang.Throwable.constructor","java.lang.Throwable.printStackTrace","java.lang.Exception","java.lang.Exception.constructor","java.lang.RuntimeException","java.lang.RuntimeException.constructor","java.lang.IndexOutOfBoundsException","java.lang.IndexOutOfBoundsException.constructor","java.lang.StringBuilder","java.lang.StringBuilder.constructor","java.lang.StringBuilder.append","java.lang.StringBuilder.toString","java.lang.ref","java.lang.ref.WeakReference","java.lang.ref.WeakReference.constructor","java.util","java.util.Random","java.util.Random.constructor","java.util.Random.nextInt","java.util.Random.nextDouble","java.util.Arrays","java.util.Arrays.constructor","java.util.Arrays.fill","java.util.Collections","java.util.Collections.constructor","java.util.Collections.reverse","java.util.Collections.sort","java.util.XArray","java.util.XArray.constructor","java.util.XArray.pop","java.util.XArray.push","java.util.XArray.splice","java.util.XArray.indexOf","java.util.XArray.shift","java.util.XArray.sort","java.util.List","java.util.List.constructor","java.util.List.addAll","java.util.List.clear","java.util.List.poll","java.util.List.remove","java.util.List.toArray","java.util.List.size","java.util.List.add","java.util.List.get","java.util.List.contains","java.util.List.isEmpty","java.util.ArrayList","java.util.ArrayList.constructor","java.util.LinkedList","java.util.LinkedList.constructor","java.util.Map","java.util.Map.constructor","java.util.Map.get","java.util.Map.put","java.util.Map.containsKey","java.util.Map.remove","java.util.Map.keySet","java.util.Map.isEmpty","java.util.Map.values","java.util.Map.clear","java.util.HashMap","java.util.HashMap.constructor","java.util.Set","java.util.Set.constructor","java.util.Set.add","java.util.Set.clear","java.util.Set.contains","java.util.Set.addAll","java.util.Set.remove","java.util.Set.size","java.util.Set.isEmpty","java.util.Set.toArray","java.util.HashSet","java.util.HashSet.constructor","org","org.junit","org.junit.Assert","org.junit.Assert.constructor","org.junit.Assert.assertNotNull","org.junit.Assert.assertNull","org.junit.Assert.assertEquals","org.junit.Assert.assertNotEquals","org.junit.Assert.assertTrue","org.junit.Assert.assertFalse"],"mappings":";;;;;;AAAA,IAAM,MAAM;IAAZA,SAAMA,MAAMA;IA4BZC,CAACA;IA1BUD,SAAEA,GAATA;IACAE,CAACA;IAoBMF,gBAASA,GAAhBA,UAAiBA,GAAYA,EAAEA,MAAaA,EAAEA,IAAaA,EAAEA,OAAcA,EAAEA,WAAkBA;QAC3FG,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,WAAWA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;YACnCA,IAAIA,CAACA,OAAOA,GAAGA,CAACA,CAACA,GAAGA,GAAGA,CAACA,MAAMA,GAAGA,CAACA,CAACA,CAACA;QACxCA,CAACA;IACLA,CAACA;IAtBMH,UAAGA,GAAGA;QACTA,OAAOA,YAACA,GAAQA;YACZI,OAAOA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;QACrBA,CAACA;QACDJ,KAAKA,YAACA,GAAOA;YACTK,OAAOA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;QACrBA,CAACA;KACJL,CAACA;IAEKA,UAAGA,GAAGA;QACTA,OAAOA,YAACA,GAAQA;YACZI,OAAOA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;QACrBA,CAACA;QACDJ,KAAKA,YAACA,GAAOA;YACTK,OAAOA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;QACrBA,CAACA;KACJL,CAACA;IAONA,aAACA;AAADA,CAACA,AA5BD,IA4BC;AAUD,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,KAAK;IACrC,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC;AACzB,CAAC,CAAC;AAYF,IAAM,WAAW;IAAjBM,SAAMA,WAAWA;IAQjBC,CAACA;IAPUD,uBAAWA,GAAlBA,UAAmBA,IAAaA,EAAEA,MAAaA,EAAEA,KAAYA;QACzDE,IAAIA,MAAMA,GAAUA,EAAEA,CAACA;QACvBA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,MAAMA,EAAEA,CAACA,GAAGA,MAAMA,GAAGA,KAAKA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;YAC3CA,MAAMA,IAAIA,IAAIA,CAACA,CAACA,CAACA,CAACA;QACtBA,CAACA;QACDA,MAAMA,CAACA,MAAMA,CAACA;IAClBA,CAACA;IACLF,kBAACA;AAADA,CAACA,AARD,IAQC;AAED,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,KAAK;IACtC,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC;QAChB,MAAM,CAAC,KAAK,CAAC;IACjB,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,OAAO,GAAG;IACvB,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,KAAK;IACrC,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG;IACxB,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC;IAC1B,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QAAC,MAAM,CAAC,IAAI,CAAC;IAClC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;QAClC,IAAI,IAAI,CAAC,EAAE,2BAA2B;QAA5B,JACd,CAAC;IACD,MAAM,CAAC,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,UAAU,GAAG,UAAU,KAAK;IACzC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,SAAS,CAAC,QAAQ,GAAG,UAAU,KAAK;IACvC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;AAC9C,CAAC,CAAC;AAKF,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,KAAK;IACtC,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC;AACzB,CAAC,CAAC;AAEF,IAAO,IAAI,CAwVV;AAxVD,WAAO,IAAI,EAAC,CAAC;IAETG,IAAcA,IAAIA,CA+FjBA;IA/FDA,WAAcA,IAAIA,EAACA,CAACA;QAEhBC,IAAaA,MAAMA;YAAnBC,SAAaA,MAAMA;YAInBC,CAACA;YAHiBD,kBAAWA,GAAzBA,UAA0BA,GAAUA;gBAChCE,MAAMA,CAACA,CAACA,GAAGA,CAACA;YAChBA,CAACA;YACLF,aAACA;QAADA,CAACA,AAJDD,IAICA;QAJYA,WAAMA,GAANA,MAIZA,CAAAA;QAEDA,IAAaA,KAAKA;YAAlBI,SAAaA,KAAKA;YAIlBC,CAACA;YAHiBD,gBAAUA,GAAxBA,UAAyBA,GAAUA;gBAC/BE,MAAMA,CAACA,CAACA,GAAGA,CAACA;YAChBA,CAACA;YACLF,YAACA;QAADA,CAACA,AAJDJ,IAICA;QAJYA,UAAKA,GAALA,KAIZA,CAAAA;QAEDA,IAAaA,OAAOA;YAApBO,SAAaA,OAAOA;YAIpBC,CAACA;YAHiBD,gBAAQA,GAAtBA,UAAuBA,GAAUA;gBAC7BE,MAAMA,CAACA,CAACA,GAAGA,CAACA;YAChBA,CAACA;YACLF,cAACA;QAADA,CAACA,AAJDP,IAICA;QAJYA,YAAOA,GAAPA,OAIZA,CAAAA;QAEDA,IAAaA,IAAIA;YAAjBU,SAAaA,IAAIA;YAIjBC,CAACA;YAHiBD,cAASA,GAAvBA,UAAwBA,GAAUA;gBAC9BE,MAAMA,CAACA,CAACA,GAAGA,CAACA;YAChBA,CAACA;YACLF,WAACA;QAADA,CAACA,AAJDV,IAICA;QAJYA,SAAIA,GAAJA,IAIZA,CAAAA;QAEDA,IAAaA,OAAOA;YAApBa,SAAaA,OAAOA;YAIpBC,CAACA;YAHiBD,oBAAYA,GAA1BA,UAA2BA,GAAUA;gBAClCE,MAAMA,CAACA,GAAGA,IAAIA,MAAMA,CAACA;YACxBA,CAACA;YACLF,cAACA;QAADA,CAACA,AAJDb,IAICA;QAJYA,YAAOA,GAAPA,OAIZA,CAAAA;QAEDA,IAAaA,KAAKA;YAAlBgB,SAAaA,KAAKA;YAOlBC,CAACA;YAHiBD,gBAAUA,GAAxBA,UAAyBA,GAAUA;gBAC/BE,MAAMA,CAACA,CAACA,GAAGA,CAACA;YAChBA,CAACA;YALaF,eAASA,GAAGA,CAACA,MAAMA,CAACA;YACpBA,eAASA,GAAGA,MAAMA,CAACA;YAKrCA,YAACA;QAADA,CAACA,AAPDhB,IAOCA;QAPYA,UAAKA,GAALA,KAOZA,CAAAA;QAEDA,IAAaA,SAASA;YAKlBmB,SALSA,SAASA,CAKNA,OAAcA;gBACtBC,IAAIA,CAACA,OAAOA,GAAGA,OAAOA,CAACA;gBACvBA,IAAIA,CAACA,KAAKA,GAAGA,IAAIA,KAAKA,CAACA,OAAOA,CAACA,CAACA;YACpCA,CAACA;YAEDD,mCAAeA,GAAfA;gBACIE,OAAOA,CAACA,KAAKA,CAACA,IAAIA,CAACA,KAAKA,CAACA,OAAOA,CAACA,CAACA,CAACA;YACvCA,CAACA;YACLF,gBAACA;QAADA,CAACA,AAbDnB,IAaCA;QAbYA,cAASA,GAATA,SAaZA,CAAAA;QAGDA,IAAaA,SAASA;YAASsB,UAAlBA,SAASA,UAAkBA;YAAxCA,SAAaA,SAASA;gBAASC,8BAASA;YACxCA,CAACA;YAADD,gBAACA;QAADA,CAACA,AADDtB,EAA+BA,SAASA,EACvCA;QADYA,cAASA,GAATA,SACZA,CAAAA;QAEDA,IAAaA,gBAAgBA;YAASwB,UAAzBA,gBAAgBA,UAAkBA;YAA/CA,SAAaA,gBAAgBA;gBAASC,8BAASA;YAC/CA,CAACA;YAADD,uBAACA;QAADA,CAACA,AADDxB,EAAsCA,SAASA,EAC9CA;QADYA,qBAAgBA,GAAhBA,gBACZA,CAAAA;QAEDA,IAAaA,yBAAyBA;YAAS0B,UAAlCA,yBAAyBA,UAAkBA;YAAxDA,SAAaA,yBAAyBA;gBAASC,8BAASA;YACxDA,CAACA;YAADD,gCAACA;QAADA,CAACA,AADD1B,EAA+CA,SAASA,EACvDA;QADYA,8BAAyBA,GAAzBA,yBACZA,CAAAA;QAMDA,IAAaA,aAAaA;YAA1B4B,SAAaA,aAAaA;gBAEtBC,WAAMA,GAAGA,EAAEA,CAACA;gBAELA,WAAMA,GAAGA,CAACA,CAACA;YAYtBA,CAACA;YAVGD,8BAAMA,GAANA,UAAOA,GAAOA;gBACVE,IAAIA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,MAAMA,GAAGA,GAAGA,CAACA;gBAChCA,MAAMA,GAAGA,IAAIA,CAACA,MAAMA,CAACA,MAAMA,CAACA;gBAC5BA,MAAMA,CAACA,IAAIA,CAACA;YAChBA,CAACA;YAEDF,gCAAQA,GAARA;gBACIG,MAAMA,CAACA,IAAIA,CAACA,MAAMA,CAACA;YACvBA,CAACA;YAELH,oBAACA;QAADA,CAACA,AAhBD5B,IAgBCA;QAhBYA,kBAAaA,GAAbA,aAgBZA,CAAAA;QAEDA,IAAcA,GAAGA,CAKhBA;QALDA,WAAcA,GAAGA,EAACA,CAACA;YAEfgC,IAAaA,aAAaA;gBAA1BC,SAAaA,aAAaA;gBAC1BC,CAACA;gBAADD,oBAACA;YAADA,CAACA,AADDD,IACCA;YADYA,iBAAaA,GAAbA,aACZA,CAAAA;QAELA,CAACA,EALahC,GAAGA,GAAHA,QAAGA,KAAHA,QAAGA,QAKhBA;IAELA,CAACA,EA/FaD,IAAIA,GAAJA,SAAIA,KAAJA,SAAIA,QA+FjBA;IAEDA,IAAcA,IAAIA,CAmPjBA;IAnPDA,WAAcA,IAAIA,EAACA,CAACA;QAEhBoC,IAAaA,MAAMA;YAAnBC,SAAaA,MAAMA;YAQnBC,CAACA;YAPUD,wBAAOA,GAAdA,UAAeA,GAAUA;gBACrBE,MAAMA,CAACA,IAAIA,CAACA,MAAMA,EAAEA,GAAGA,GAAGA,CAACA;YAC/BA,CAACA;YAEMF,2BAAUA,GAAjBA;gBACIG,MAAMA,CAACA,IAAIA,CAACA,MAAMA,EAAEA,CAACA;YACzBA,CAACA;YACLH,aAACA;QAADA,CAACA,AARDD,IAQCA;QARYA,WAAMA,GAANA,MAQZA,CAAAA;QAEDA,IAAaA,MAAMA;YAAnBK,SAAaA,MAAMA;YAOnBC,CAACA;YANUD,WAAIA,GAAXA,UAAYA,IAAaA,EAAEA,KAAYA,EAAEA,MAAaA,EAAEA,KAAYA;gBAChEE,IAAIA,GAAGA,GAAGA,KAAKA,GAAGA,MAAMA,CAACA;gBACzBA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,KAAKA,EAAEA,CAACA,GAAGA,GAAGA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;oBAC/BA,IAAIA,CAACA,CAACA,CAACA,GAAGA,KAAKA,CAACA;gBACpBA,CAACA;YACLA,CAACA;YACLF,aAACA;QAADA,CAACA,AAPDL,IAOCA;QAPYA,WAAMA,GAANA,MAOZA,CAAAA;QAEDA,IAAaA,WAAWA;YAAxBQ,SAAaA,WAAWA;YAiBxBC,CAACA;YAfiBD,mBAAOA,GAArBA,UAAyBA,CAASA;gBAC9BE,IAAIA,IAAIA,GAAGA,IAAIA,IAAIA,EAAKA,CAACA;gBACzBA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,CAACA,CAACA,IAAIA,EAAEA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;oBAChCA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;gBACvBA,CAACA;gBACDA,CAACA,CAACA,KAAKA,EAAEA,CAACA;gBACVA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,CAACA,IAAIA,EAAEA,GAAGA,CAACA,EAAEA,CAACA,IAAIA,CAACA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;oBACxCA,CAACA,CAACA,GAAGA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;gBACvBA,CAACA;YACLA,CAACA;YAEaF,gBAAIA,GAAlBA,UAAsBA,CAASA;gBAC3BG,CAACA,CAACA,IAAIA,EAAEA,CAACA;YACbA,CAACA;YAELH,kBAACA;QAADA,CAACA,AAjBDR,IAiBCA;QAjBYA,gBAAWA,GAAXA,WAiBZA,CAAAA;QAaDA,IAAaA,MAAMA;YACfY,SADSA,MAAMA;gBAEXC,KAAKA,CAACA,KAAKA,CAACA,IAAIA,EAAEA,SAASA,CAACA,CAACA;gBAC7BA,MAAMA,CAACA,IAAIA,KAAKA,EAAEA,CAACA;YACvBA,CAACA;YAEDD,oBAAGA,GAAHA;gBACIE,MAAMA,CAACA,EAAEA,CAAAA;YACbA,CAACA;YAEDF,qBAAIA,GAAJA,UAAKA,GAAGA;gBACJG,MAAMA,CAACA,CAACA,CAACA;YACbA,CAACA;YAEDH,uBAAMA,GAANA,UAAOA,IAAIA,EAAEA,IAAIA;YACjBI,CAACA;YAIDJ,wBAAOA,GAAPA,UAAQA,GAAGA;gBACPK,MAAMA,CAACA,CAACA,CAAAA;YACZA,CAACA;YAEDL,sBAAKA,GAALA;gBACIM,MAAMA,CAACA,EAAEA,CAACA;YACdA,CAACA;YAEDN,qBAAIA,GAAJA;YACAO,CAACA;YAELP,aAACA;QAADA,CAACA,AA9BDZ,IA8BCA;QA9BYA,WAAMA,GAANA,MA8BZA,CAAAA;QACDA,MAAMA,CAACA,WAAWA,CAACA,GAAGA,IAAIA,KAAKA,EAAEA,CAACA;QAElCA,IAAaA,IAAIA;YAAYoB,UAAhBA,IAAIA,UAAkBA;YAAnCA,SAAaA,IAAIA;gBAAYC,8BAAMA;YA4CnCA,CAACA;YA1CGD,qBAAMA,GAANA,UAAOA,IAAkBA;gBACrBE,IAAIA,SAASA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,IAAIA,CAACA,CAACA;gBACnCA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,SAASA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;oBACxCA,IAAIA,CAACA,IAAIA,CAACA,SAASA,CAACA,CAACA,CAACA,CAACA,CAACA;gBAC5BA,CAACA;YACLA,CAACA;YAEDF,oBAAKA,GAALA;gBACIG,IAAIA,CAACA,MAAMA,GAAGA,CAACA,CAACA;YACpBA,CAACA;YAEDH,mBAAIA,GAAJA;gBACII,MAAMA,CAACA,IAAIA,CAACA,KAAKA,EAAEA,CAACA;YACxBA,CAACA;YAEDJ,qBAAMA,GAANA,UAAOA,GAAKA;YAEZK,CAACA;YAEDL,sBAAOA,GAAPA,UAAQA,CAAUA;gBACdM,MAAMA,CAAWA,IAAIA,CAACA;YAC1BA,CAACA;YAEDN,mBAAIA,GAAJA;gBACIO,MAAMA,CAACA,IAAIA,CAACA,MAAMA,CAACA;YACvBA,CAACA;YAEDP,kBAAGA,GAAHA,UAAIA,GAAKA;gBACLQ,IAAIA,CAACA,IAAIA,CAACA,GAAGA,CAACA,CAACA;YACnBA,CAACA;YAEDR,kBAAGA,GAAHA,UAAIA,KAAYA;gBACZS,MAAMA,CAACA,IAAIA,CAACA,KAAKA,CAACA,CAACA;YACvBA,CAACA;YAEDT,uBAAQA,GAARA,UAASA,GAAKA;gBACVU,MAAMA,CAACA,IAAIA,CAACA,OAAOA,CAACA,GAAGA,CAACA,IAAIA,CAACA,CAACA,CAACA;YACnCA,CAACA;YAEDV,sBAAOA,GAAPA;gBACIW,MAAMA,CAACA,IAAIA,CAACA,MAAMA,IAAIA,CAACA,CAACA;YAC5BA,CAACA;YACLX,WAACA;QAADA,CAACA,AA5CDpB,EAA6BA,MAAMA,EA4ClCA;QA5CYA,SAAIA,GAAJA,IA4CZA,CAAAA;QAEDA,IAAaA,SAASA;YAAYgC,UAArBA,SAASA,UAAmBA;YAAzCA,SAAaA,SAASA;gBAAYC,8BAAOA;YACzCA,CAACA;YAADD,gBAACA;QAADA,CAACA,AADDhC,EAAkCA,IAAIA,EACrCA;QADYA,cAASA,GAATA,SACZA,CAAAA;QAEDA,IAAaA,UAAUA;YAAYkC,UAAtBA,UAAUA,UAAmBA;YAA1CA,SAAaA,UAAUA;gBAAYC,8BAAOA;YAC1CA,CAACA;YAADD,iBAACA;QAADA,CAACA,AADDlC,EAAmCA,IAAIA,EACtCA;QADYA,eAAUA,GAAVA,UACZA,CAAAA;QAEDA,IAAaA,GAAGA;YAAhBoC,SAAaA,GAAGA;YAsDhBC,CAACA;YApDGD,iBAAGA,GAAHA,UAAIA,GAAKA;gBACLE,MAAMA,CAACA,IAAIA,CAAMA,GAAGA,CAACA,CAACA;YAC1BA,CAACA;YAEDF,iBAAGA,GAAHA,UAAIA,GAAKA,EAAEA,KAAOA;gBACdG,IAAIA,YAAYA,GAAGA,IAAIA,CAAMA,GAAGA,CAACA,CAACA;gBAClCA,IAAIA,CAAMA,GAAGA,CAACA,GAAGA,KAAKA,CAACA;gBACvBA,MAAMA,CAACA,YAAYA,CAACA;YACxBA,CAACA;YAEDH,yBAAWA,GAAXA,UAAYA,GAAKA;gBACbI,MAAMA,CAACA,IAAIA,CAACA,cAAcA,CAAMA,GAAGA,CAACA,CAACA;YACzCA,CAACA;YAEDJ,oBAAMA,GAANA,UAAOA,GAAKA;gBACRK,IAAIA,GAAGA,GAAGA,IAAIA,CAAMA,GAAGA,CAACA,CAACA;gBACzBA,OAAOA,IAAIA,CAAMA,GAAGA,CAACA,CAACA;gBACtBA,MAAMA,CAACA,GAAGA,CAACA;YACfA,CAACA;YAEDL,oBAAMA,GAANA;gBACIM,IAAIA,MAAMA,GAAGA,IAAIA,OAAOA,EAAKA,CAACA;gBAC9BA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,IAAIA,CAACA,CAACA,CAACA;oBACjBA,EAAEA,CAACA,CAACA,IAAIA,CAACA,cAAcA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;wBACzBA,MAAMA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA;oBAClBA,CAACA;gBACLA,CAACA;gBACDA,MAAMA,CAACA,MAAMA,CAACA;YAClBA,CAACA;YAEDN,qBAAOA,GAAPA;gBACIO,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA,MAAMA,IAAIA,CAACA,CAACA;YACzCA,CAACA;YAEDP,oBAAMA,GAANA;gBACIQ,IAAIA,MAAMA,GAAGA,IAAIA,OAAOA,EAAKA,CAACA;gBAC9BA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,IAAIA,CAACA,CAACA,CAACA;oBACjBA,EAAEA,CAACA,CAACA,IAAIA,CAACA,cAAcA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;wBACzBA,MAAMA,CAACA,GAAGA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA,CAACA;oBACxBA,CAACA;gBACLA,CAACA;gBACDA,MAAMA,CAACA,MAAMA,CAACA;YAClBA,CAACA;YAEDR,mBAAKA,GAALA;gBACIS,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,IAAIA,CAACA,CAACA,CAACA;oBACjBA,EAAEA,CAACA,CAACA,IAAIA,CAACA,cAAcA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;wBACzBA,OAAOA,IAAIA,CAACA,CAACA,CAACA,CAACA;oBACnBA,CAACA;gBACLA,CAACA;YACLA,CAACA;YAELT,UAACA;QAADA,CAACA,AAtDDpC,IAsDCA;QAtDYA,QAAGA,GAAHA,GAsDZA,CAAAA;QAEDA,IAAaA,OAAOA;YAAe8C,UAAtBA,OAAOA,UAAuBA;YAA3CA,SAAaA,OAAOA;gBAAeC,8BAAQA;YAC3CA,CAACA;YAADD,cAACA;QAADA,CAACA,AADD9C,EAAmCA,GAAGA,EACrCA;QADYA,YAAOA,GAAPA,OACZA,CAAAA;QAEDA,IAAaA,GAAGA;YAAhBgD,SAAaA,GAAGA;YA2ChBC,CAACA;YAzCGD,iBAAGA,GAAHA,UAAIA,GAAKA;gBACLE,IAAIA,CAAMA,GAAGA,CAACA,GAAGA,GAAGA,CAACA;YACzBA,CAACA;YAEDF,mBAAKA,GAALA;gBACIG,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,IAAIA,CAACA,CAACA,CAACA;oBACjBA,EAAEA,CAACA,CAACA,IAAIA,CAACA,cAAcA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;wBACzBA,OAAOA,IAAIA,CAACA,CAACA,CAACA,CAACA;oBACnBA,CAACA;gBACLA,CAACA;YACLA,CAACA;YAEDH,sBAAQA,GAARA,UAASA,GAAKA;gBACVI,MAAMA,CAACA,IAAIA,CAACA,cAAcA,CAAMA,GAAGA,CAACA,CAACA;YACzCA,CAACA;YAEDJ,oBAAMA,GAANA,UAAOA,IAAkBA;gBACrBK,IAAIA,SAASA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,IAAIA,CAACA,CAACA;gBACnCA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,SAASA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;oBACxCA,IAAIA,CAAMA,SAASA,CAACA,CAACA,CAACA,CAACA,GAAGA,SAASA,CAACA,CAACA,CAACA,CAACA;gBAC3CA,CAACA;YACLA,CAACA;YAEDL,oBAAMA,GAANA,UAAOA,GAAKA;gBACRM,OAAOA,IAAIA,CAAMA,GAAGA,CAACA,CAACA;YAC1BA,CAACA;YAEDN,kBAAIA,GAAJA;gBACIO,MAAMA,CAACA,MAAMA,CAACA,IAAIA,CAACA,IAAIA,CAACA,CAACA,MAAMA,CAACA;YACpCA,CAACA;YAEDP,qBAAOA,GAAPA;gBACIQ,MAAMA,CAACA,IAAIA,CAACA,IAAIA,EAAEA,IAAIA,CAACA,CAACA;YAC5BA,CAACA;YAEDR,qBAAOA,GAAPA,UAAQA,CAAUA;gBACdS,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,IAAIA,IAAIA,CAACA,CAACA,CAACA;oBAClBA,CAACA,CAACA,IAAIA,CAACA,IAAIA,CAACA,EAAEA,CAACA,CAACA,CAACA;gBACrBA,CAACA;gBACDA,MAAMA,CAACA,CAACA,CAACA;YACbA,CAACA;YACLT,UAACA;QAADA,CAACA,AA3CDhD,IA2CCA;QA3CYA,QAAGA,GAAHA,GA2CZA,CAAAA;QAEDA,IAAaA,OAAOA;YAAY0D,UAAnBA,OAAOA,UAAkBA;YAAtCA,SAAaA,OAAOA;gBAAYC,8BAAMA;YAEtCA,CAACA;YAADD,cAACA;QAADA,CAACA,AAFD1D,EAAgCA,GAAGA,EAElCA;QAFYA,YAAOA,GAAPA,OAEZA,CAAAA;IACLA,CAACA,EAnPapC,IAAIA,GAAJA,SAAIA,KAAJA,SAAIA,QAmPjBA;AAELA,CAACA,EAxVM,IAAI,KAAJ,IAAI,QAwVV;AAED,IAAO,GAAG,CAuDT;AAvDD,WAAO,GAAG,EAAC,CAAC;IAERgG,IAAcA,KAAKA,CAoDlBA;IApDDA,WAAcA,KAAKA,EAACA,CAACA;QAEjBC,IAAaA,MAAMA;YAAnBC,SAAaA,MAAMA;YAiDnBC,CAACA;YAhDiBD,oBAAaA,GAA3BA,UAA4BA,CAAKA;gBAC7BE,EAAEA,CAACA,CAACA,CAACA,IAAIA,IAAIA,CAACA,CAACA,CAACA;oBACZA,MAAMA,eAAeA,GAAGA,CAACA,GAAGA,mBAAmBA,CAACA;gBACpDA,CAACA;YACLA,CAACA;YAEaF,iBAAUA,GAAxBA,UAAyBA,CAAKA;gBAC1BG,EAAEA,CAACA,CAACA,CAACA,IAAIA,IAAIA,CAACA,CAACA,CAACA;oBACZA,MAAMA,eAAeA,GAAGA,CAACA,GAAGA,eAAeA,CAACA;gBAChDA,CAACA;YACLA,CAACA;YAEaH,mBAAYA,GAA1BA,UAA2BA,CAAKA,EAAEA,EAAMA;gBACpCI,EAAEA,CAACA,CAACA,CAACA,CAACA,MAAMA,KAAKA,SAASA,CAACA,CAACA,CAACA;oBACzBA,EAAEA,CAACA,CAACA,CAACA,CAACA,CAACA,MAAMA,CAACA,EAAEA,CAACA,CAACA,CAACA,CAACA;wBAChBA,MAAMA,iBAAiBA,GAAGA,CAACA,GAAGA,wBAAwBA,GAAGA,EAAEA,GAAGA,IAAIA,CAACA;oBACvEA,CAACA;gBACLA,CAACA;gBAACA,IAAIA,CAACA,CAACA;oBACJA,EAAEA,CAACA,CAACA,CAACA,IAAIA,EAAEA,CAACA,CAACA,CAACA;wBACVA,MAAMA,iBAAiBA,GAAGA,CAACA,GAAGA,wBAAwBA,GAAGA,EAAEA,GAAGA,IAAIA,CAACA;oBACvEA,CAACA;gBACLA,CAACA;YACLA,CAACA;YAEaJ,sBAAeA,GAA7BA,UAA8BA,CAAKA,EAAEA,EAAMA;gBACvCK,EAAEA,CAACA,CAACA,CAACA,CAACA,MAAMA,KAAKA,SAASA,CAACA,CAACA,CAACA;oBACzBA,EAAEA,CAACA,CAACA,CAACA,CAACA,MAAMA,CAACA,EAAEA,CAACA,CAACA,CAACA,CAACA;wBACfA,MAAMA,iBAAiBA,GAAGA,CAACA,GAAGA,4BAA4BA,GAAGA,EAAEA,GAAGA,IAAIA,CAACA;oBAC3EA,CAACA;gBACLA,CAACA;gBAACA,IAAIA,CAACA,CAACA;oBACJA,EAAEA,CAACA,CAACA,CAACA,IAAIA,EAAEA,CAACA,CAACA,CAACA;wBACVA,MAAMA,iBAAiBA,GAAGA,CAACA,GAAGA,4BAA4BA,GAAGA,EAAEA,GAAGA,IAAIA,CAACA;oBAC3EA,CAACA;gBACLA,CAACA;YACLA,CAACA;YAEaL,iBAAUA,GAAxBA,UAAyBA,CAASA;gBAC9BM,EAAEA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;oBACLA,MAAMA,eAAeA,GAAGA,CAACA,GAAGA,eAAeA,CAACA;gBAChDA,CAACA;YACLA,CAACA;YAEaN,kBAAWA,GAAzBA,UAA0BA,CAASA;gBAC/BO,EAAEA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;oBACJA,MAAMA,eAAeA,GAAGA,CAACA,GAAGA,gBAAgBA,CAACA;gBACjDA,CAACA;YACLA,CAACA;YAELP,aAACA;QAADA,CAACA,AAjDDD,IAiDCA;QAjDYA,YAAMA,GAANA,MAiDZA,CAAAA;IACLA,CAACA,EApDaD,KAAKA,GAALA,SAAKA,KAALA,SAAKA,QAoDlBA;AACLA,CAACA,EAvDM,GAAG,KAAH,GAAG,QAuDT"} \ No newline at end of file diff --git a/org.kevoree.modeling.java2typescript/src/main/resources/java.ts b/org.kevoree.modeling.java2typescript/src/main/resources/java.ts deleted file mode 100644 index dc0d27e..0000000 --- a/org.kevoree.modeling.java2typescript/src/main/resources/java.ts +++ /dev/null @@ -1,508 +0,0 @@ -class System { - - static gc() { - } - - static out = { - println(obj?:any) { - console.log(obj); - }, - print(obj:any) { - console.log(obj); - } - }; - - static err = { - println(obj?:any) { - console.log(obj); - }, - print(obj:any) { - console.log(obj); - } - }; - - static arraycopy(src:Number[], srcPos:number, dest:Number[], destPos:number, numElements:number):void { - for (var i = 0; i < numElements; i++) { - dest[destPos + i] = src[srcPos + i]; - } - } -} - -interface Number { - equals : (other:Number) => boolean; - longValue() : number; - floatValue() : number; - intValue() : number; - shortValue() : number; -} - -Number.prototype.equals = function (other) { - return this == other; -}; - -interface String { - equals : (other:String) => boolean; - startsWith : (other:String) => boolean; - endsWith : (other:String) => boolean; - matches : (regEx:String) => boolean; - //getBytes : () => number[]; - isEmpty : () => boolean; - hashCode : () => number; -} - -class StringUtils { - static copyValueOf(data:string[], offset:number, count:number):string { - var result:string = ""; - for (var i = offset; i < offset + count; i++) { - result += data[i]; - } - return result; - } -} - -String.prototype.matches = function (regEx) { - if (regEx == null) { - return false; - } else { - var m = this.match(regEx); - return m != null && m.length > 0; - } -}; - -String.prototype.isEmpty = function () { - return this.length == 0; -}; - -String.prototype.equals = function (other) { - return this == other; -}; - -String.prototype.hashCode = function () { - var hash = 0, i, chr, len; - if (this.length == 0) return hash; - for (i = 0, len = this.length; i < len; i++) { - chr = this.charCodeAt(i); - hash = ((hash << 5) - hash) + chr; - hash |= 0; // Convert to 32bit integer - } - return hash; -}; - -String.prototype.startsWith = function (other) { - return this.slice(0, other.length) == other; -}; - -String.prototype.endsWith = function (other) { - return this.slice(-other.length) == other; -}; - -interface Boolean { - equals : (other:String) => boolean; -} -Boolean.prototype.equals = function (other) { - return this == other; -}; - -module java { - - export module lang { - - export class Double { - public static parseDouble(val:string):number { - return +val; - } - } - - export class Float { - public static parseFloat(val:string):number { - return +val; - } - } - - export class Integer { - public static parseInt(val:string):number { - return +val; - } - } - - export class Long { - public static parseLong(val:string):number { - return +val; - } - } - - export class Boolean { - public static parseBoolean(val:string):boolean{ - return val == "true"; - } - } - - export class Short { - public static MIN_VALUE = -0x8000; - public static MAX_VALUE = 0x7FFF; - - public static parseShort(val:string):number { - return +val; - } - } - - export class Throwable { - - private message:string; - private error:Error; - - constructor(message:string) { - this.message = message; - this.error = new Error(message); - } - - printStackTrace() { - console.error(this.error['stack']); - } - } - - - export class Exception extends Throwable { - } - - export class RuntimeException extends Exception { - } - - export class IndexOutOfBoundsException extends Exception { - } - - export interface Runnable { - run():void; - } - - export class StringBuilder { - - buffer = ""; - - public length = 0; - - append(val:any):StringBuilder { - this.buffer = this.buffer + val; - length = this.buffer.length; - return this; - } - - toString():string { - return this.buffer; - } - - } - - export module ref { - - export class WeakReference { - } - - } - - } - - export module util { - - export class Random { - public nextInt(max:number):number { - return Math.random() * max; - } - - public nextDouble():number { - return Math.random(); - } - } - - export class Arrays { - static fill(data:Number[], begin:number, nbElem:number, param:number):void { - var max = begin + nbElem; - for (var i = begin; i < max; i++) { - data[i] = param; - } - } - } - - export class Collections { - - public static reverse(p:List):void { - var temp = new List(); - for (var i = 0; i < p.size(); i++) { - temp.add(p.get(i)); - } - p.clear(); - for (var i = temp.size() - 1; i >= 0; i--) { - p.add(temp.get(i)); - } - } - - public static sort(p:List):void { - p.sort(); - } - - } - - export interface Collection { - add(val:T):void - addAll(vals:Collection) - remove(val:T) - clear() - isEmpty():boolean - size():number - contains(val:T):boolean - toArray(a:Array):T[] - } - - export class XArray { - constructor() { - Array.apply(this, arguments); - return new Array(); - } - - pop():any { - return "" - } - - push(val):number { - return 0; - } - - splice(newS, arrL) { - } - - length:number; - - indexOf(val):number { - return 0 - } - - shift():any { - return ""; - } - - sort() { - } - - } - XArray["prototype"] = new Array(); - - export class List extends XArray implements Collection { - - addAll(vals:Collection) { - var tempArray = vals.toArray(null); - for (var i = 0; i < tempArray.length; i++) { - this.push(tempArray[i]); - } - } - - clear() { - this.length = 0; - } - - poll():T { - return this.shift(); - } - - remove(val:T) { - - } - - toArray(a:Array):T[] { - return this; - } - - size():number { - return this.length; - } - - add(val:T):void { - this.push(val); - } - - get(index:number):T { - return this[index]; - } - - contains(val:T):boolean { - return this.indexOf(val) != -1; - } - - isEmpty():boolean { - return this.length == 0; - } - } - - export class ArrayList extends List { - } - - export class LinkedList extends List { - } - - export class Map { - - get(key:K):V { - return this[key]; - } - - put(key:K, value:V):V { - var previous_val = this[key]; - this[key] = value; - return previous_val; - } - - containsKey(key:K):boolean { - return this.hasOwnProperty(key); - } - - remove(key:K):V { - var tmp = this[key]; - delete this[key]; - return tmp; - } - - keySet():Set { - var result = new HashSet(); - for (var p in this) { - if (this.hasOwnProperty(p)) { - result.add(p); - } - } - return result; - } - - isEmpty():boolean { - return Object.keys(this).length == 0; - } - - values():Set { - var result = new HashSet(); - for (var p in this) { - if (this.hasOwnProperty(p)) { - result.add(this[p]); - } - } - return result; - } - - clear():void { - for (var p in this) { - if (this.hasOwnProperty(p)) { - delete this[p]; - } - } - } - - } - - export class HashMap extends Map { - } - - export class Set implements Collection { - - add(val:T) { - this[val] = val; - } - - clear() { - for (var p in this) { - if (this.hasOwnProperty(p)) { - delete this[p]; - } - } - } - - contains(val:T):boolean { - return this.hasOwnProperty(val); - } - - addAll(vals:Collection) { - var tempArray = vals.toArray(null); - for (var i = 0; i < tempArray.length; i++) { - this[tempArray[i]] = tempArray[i]; - } - } - - remove(val:T) { - delete this[val]; - } - - size():number { - return Object.keys(this).length; - } - - isEmpty():boolean { - return this.size() == 0; - } - - toArray(a:Array):T[] { - for (var ik in this) { - a.push(this[ik]); - } - return a; - } - } - - export class HashSet extends Set { - - } - } - -} - -module org { - - export module junit { - - export class Assert { - public static assertNotNull(p:any):void { - if (p == null) { - throw "Assert Error " + p + " must not be null"; - } - } - - public static assertNull(p:any):void { - if (p != null) { - throw "Assert Error " + p + " must be null"; - } - } - - public static assertEquals(p:any, p2:any):void { - if (p.equals !== undefined) { - if (!p.equals(p2)) { - throw "Assert Error \n" + p + "\n must be equal to \n" + p2 + "\n"; - } - } else { - if (p != p2) { - throw "Assert Error \n" + p + "\n must be equal to \n" + p2 + "\n"; - } - } - } - - public static assertNotEquals(p:any, p2:any):void { - if (p.equals !== undefined) { - if (p.equals(p2)) { - throw "Assert Error \n" + p + "\n must not be equal to \n" + p2 + "\n"; - } - } else { - if (p == p2) { - throw "Assert Error \n" + p + "\n must not be equal to \n" + p2 + "\n"; - } - } - } - - public static assertTrue(b:boolean):void { - if (!b) { - throw "Assert Error " + b + " must be true"; - } - } - - public static assertFalse(b:boolean):void { - if (b) { - throw "Assert Error " + b + " must be false"; - } - } - - } - } -} - diff --git a/pom.xml b/pom.xml index ab41777..45537d4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,25 +1,33 @@ + 4.0.0 - org.kevoree.modeling - org.kevoree.modeling.java2typescript.root + com.datathings + j2ts-parent pom - 28-SNAPSHOT - Kevoree :: Modeling :: Java2TypeScript :: Root - https://github.com/kevoree/java2typescript - Kevoree Modeling Java2TypeScript - - - - General Public License (GPL) - http://www.gnu.org/licenses/gpl.html - - + 98.0.1-SNAPSHOT + j2ts-parent + https://github.com/datathings/java2typescript + Java2TypeScript - - scm:git:git@github.com:kevoree/java2typescript.git - scm:git:git@github.com:kevoree/java2typescript.git - http://github.com/kevoree/java2typescript.git - + + ${basedir}/HEADER + org.sonatype.oss @@ -48,22 +56,27 @@ +2 + + Maxime Tricoire + maxleiko + leiko@braindead.fr + + developer + + +2 + - - 10 - - - org.kevoree.modeling.java2typescript - org.kevoree.modeling.java2typescript.mavenplugin + transpiler + mavenplugin junit junit - 4.11 + 4.12 test @@ -73,7 +86,7 @@ org.apache.maven.plugins maven-source-plugin - 2.4 + 3.2.1 attach-sources @@ -83,82 +96,17 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.1 - - - attach-javadocs - - jar - - - - - 128M - ${java.home}/../bin/javadoc - - + org.apache.maven.plugins maven-compiler-plugin - 3.2 + 3.6.1 1.8 1.8 - - org.codehaus.mojo - license-maven-plugin - 1.7 - - false - true - - - - first - - update-file-header - - process-sources - - gpl_v3 - org.kevoree - 2014 - - *.java - - - - - - - org.kevoree.maventools - org.kevoree.maventools.settings.ci - 2 - - - - set - - - - - - - kevoree.oss.release - https://oss.sonatype.org/service/local/staging/deploy/maven2 - - - kevoree.oss.snapshots - https://oss.sonatype.org/content/repositories/snapshots - - - diff --git a/releaseScript.sh b/release.sh similarity index 69% rename from releaseScript.sh rename to release.sh index 2e92a18..1842d22 100755 --- a/releaseScript.sh +++ b/release.sh @@ -1,22 +1,20 @@ +#!/usr/bin/env bash # -# Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; +# Copyright 2017 The Java2TypeScript Authors. 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.gnu.org/licenses/lgpl-3.0.txt -# +#

+# http://www.apache.org/licenses/LICENSE-2.0 +#

# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # -# Authors: -# Fouquet Francois -# Nain Gregory -# -export JAVA_HOME=$(/usr/libexec/java_home) mvn release:clean mvn release:prepare mvn release:perform \ No newline at end of file diff --git a/sample.zip b/sample.zip new file mode 100644 index 0000000..6c83b45 Binary files /dev/null and b/sample.zip differ diff --git a/sample/pom.xml b/sample/pom.xml new file mode 100644 index 0000000..90c474f --- /dev/null +++ b/sample/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + com.datathings + j2ts-sample + j2ts-sample + 1-SNAPSHOT + + + + 83 + + + + + + com.datathings + j2ts-mavenplugin + ${j2ts.version} + + + transpile + + java2ts + + + sample + true + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + compile + compile + + + + + + + + + + + + + + + run + + + + + + + + + diff --git a/sample/src/main/java/sample/HelloWorld.java b/sample/src/main/java/sample/HelloWorld.java new file mode 100644 index 0000000..3280869 --- /dev/null +++ b/sample/src/main/java/sample/HelloWorld.java @@ -0,0 +1,13 @@ +package sample; + +public class HelloWorld { + + public String sayHello() { + return "HelloWorld"; + } + + public static void main(String[] args) { + System.out.println(new HelloWorld().sayHello()); + } + +} diff --git a/sample/src/main/resources/index.html b/sample/src/main/resources/index.html new file mode 100644 index 0000000..a2500c4 --- /dev/null +++ b/sample/src/main/resources/index.html @@ -0,0 +1,14 @@ + + +

+ + + + + \ No newline at end of file diff --git a/sample/taskdef.xml b/sample/taskdef.xml new file mode 100644 index 0000000..5785eba --- /dev/null +++ b/sample/taskdef.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/transpiler/pom.xml b/transpiler/pom.xml new file mode 100644 index 0000000..b2abb2e --- /dev/null +++ b/transpiler/pom.xml @@ -0,0 +1,156 @@ + + + + 4.0.0 + j2ts-transpiler + j2ts-transpiler + + + com.datathings + j2ts-parent + 98.0.1-SNAPSHOT + ../pom.xml + + + + ${basedir}/../HEADER + + + + + org.jetbrains.kotlin + kotlin-compiler + 1.3.61 + + + junit + junit + 4.11 + test + + + + + + + org.codehaus.gmaven + groovy-maven-plugin + 2.1.1 + + + main.ts.compile + compile + + execute + + + + //windows compat... + def gbasedir = basedir.getAbsolutePath().replace('\\', '/') + def prefix = (System.getProperty("os.name").toLowerCase().contains("win")) ? "CMD /C " : "" + //let's start + def ant = new AntBuilder() + //prepare dir + ant.copy(file: "${gbasedir}/src/main/resources/jre/jre.ts", todir: "${gbasedir}/target/classes-npm-jre") + ant.copy(file: "${gbasedir}/src/main/resources/jre/package.json", todir: "${gbasedir}/target/classes-npm-jre") + ant.copy(file: "${gbasedir}/src/main/resources/jre/readme.md", todir: "${gbasedir}/target/classes-npm-jre") + ant.copy(file: "${gbasedir}/src/main/resources/jre/tsconfig.json", todir: "${gbasedir}/target/classes-npm-jre") + //prepare version + def project_version = "${project.version}".replaceAll("-SNAPSHOT", "") + while (project_version.split('\\.').length != 3) { + project_version += '.0' + } + ant.replace(file: "${gbasedir}/target/classes-npm-jre/package.json", token: "J2TS_VERSION", value: project_version) + //run npm install + def npmInstallProcess = (prefix + "npm install").execute(null, new File("${gbasedir}/target/classes-npm-jre")) + npmInstallProcess.waitForProcessOutput(System.out, System.err) + if (npmInstallProcess.exitValue() != 0) { + exit + } + //run tsc and delete temp .ts file + def tscProcess = (prefix + "node ${gbasedir}/target/classes-npm-jre/node_modules/typescript/lib/tsc.js").execute(null, new File("${gbasedir}/target/classes-npm-jre")) + tscProcess.waitForProcessOutput(System.out, System.err) + if (tscProcess.exitValue() != 0) { + exit + } + def npmPackProcess = (prefix + "npm pack classes-npm-jre/").execute(null, new File("${gbasedir}/target/")) + npmPackProcess.waitForProcessOutput(System.out, System.err) + if (npmPackProcess.exitValue() != 0) { + exit + } + ant.delete(file: "${gbasedir}/target/classes-npm-jre/tsconfig.json") + + //prepare junit.ts dir + //prepare dir + ant.copy(file: "${gbasedir}/src/main/resources/junit/junit.ts", todir: "${gbasedir}/target/classes-npm-junit") + ant.copy(file: "${gbasedir}/src/main/resources/junit/package.json", todir: "${gbasedir}/target/classes-npm-junit") + ant.copy(file: "${gbasedir}/src/main/resources/junit/readme.md", todir: "${gbasedir}/target/classes-npm-junit") + ant.copy(file: "${gbasedir}/src/main/resources/junit/tsconfig.json", todir: "${gbasedir}/target/classes-npm-junit") + ant.replace(file: "${gbasedir}/target/classes-npm-junit/package.json", token: "J2TS_VERSION", value: project_version) + //run npm install + def npmInstallProcessUnit = (prefix + "npm install").execute(null, new File("${gbasedir}/target/classes-npm-junit")) + npmInstallProcessUnit.waitForProcessOutput(System.out, System.err) + if (npmInstallProcessUnit.exitValue() != 0) { + exit + } + //run tsc and delete temp .ts file + def tscProcessUnit = (prefix + "node ${gbasedir}/target/classes-npm-junit/node_modules/typescript/lib/tsc.js").execute(null, new File("${gbasedir}/target/classes-npm-junit")) + tscProcessUnit.waitForProcessOutput(System.out, System.err) + if (tscProcessUnit.exitValue() != 0) { + exit + } + + def npmPackProcessUnit = (prefix + "npm pack classes-npm-junit/").execute(null, new File("${gbasedir}/target/")) + npmPackProcessUnit.waitForProcessOutput(System.out, System.err) + if (npmPackProcessUnit.exitValue() != 0) { + exit + } + ant.delete(file: "${gbasedir}/target/classes-npm-junit/tsconfig.json") + + + + + main.ts.deploy + deploy + + execute + + + + //windows compat... + def gbasedir = basedir.getAbsolutePath().replace('\\', '/') + def prefix = (System.getProperty("os.name").toLowerCase().contains("win")) ? "CMD /C " : "" + def npmInstallProcessJRE = (prefix + "npm publish").execute(null, new File("${gbasedir}/target/classes-npm-jre")) + npmInstallProcessJRE.waitForProcessOutput(System.out, System.err) + if (npmInstallProcessJRE.exitValue() != 0) { + exit + } + def npmInstallProcessUnit = (prefix + "npm publish").execute(null, new File("${gbasedir}/target/classes-npm-junit")) + npmInstallProcessUnit.waitForProcessOutput(System.out, System.err) + if (npmInstallProcessUnit.exitValue() != 0) { + exit + } + + + + + + + + \ No newline at end of file diff --git a/transpiler/src/main/java/java2typescript/FlatJUnitGenerator.java b/transpiler/src/main/java/java2typescript/FlatJUnitGenerator.java new file mode 100755 index 0000000..84958c8 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/FlatJUnitGenerator.java @@ -0,0 +1,156 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript; + +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.psi.*; +import com.intellij.psi.javadoc.PsiDocComment; +import com.intellij.psi.javadoc.PsiDocTag; +import java2typescript.translators.DocTagTranslator; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + +public class FlatJUnitGenerator { + + public List headers = null; + + public void generate(File sourceDir, File targetDir) { + try { + + StringBuilder sb = new StringBuilder(); + StringBuilder sbDev = new StringBuilder(); + + if (headers != null) { + for (String s : headers) { + sb.append(s + "\n"); + sbDev.append(s + "\n"); + } + } + + JavaAnalyzer javaAnalyzer = new JavaAnalyzer(); + PsiDirectory parsedDir = javaAnalyzer.analyze(sourceDir); + parsedDir.acceptChildren(new PsiElementVisitor() { + @Override + public void visitElement(PsiElement element) { + boolean ignore = false; + if (element instanceof PsiClass) { + PsiClass clazz = (PsiClass) element; + + PsiDocComment comment = clazz.getDocComment(); + if (comment != null) { + PsiDocTag[] tags = comment.getTags(); + if (tags != null) { + for (PsiDocTag tag : tags) { + if (tag.getName().equals(DocTagTranslator.IGNORE) && tag.getValueElement() != null && tag.getValueElement().getText().equals(DocTagTranslator.TS)) { + ignore = true; + } + } + } + } + + + if (!ignore && !clazz.isInterface() && !clazz.hasModifierProperty(PsiModifier.ABSTRACT)) { + generateTestSuite(sb, sbDev, clazz); + } + } else { + element.acceptChildren(this); + } + } + }); + + + targetDir.mkdirs(); + File generatedTS = new File(targetDir, "testsRunner.js"); + FileUtil.writeToFile(generatedTS, sb.toString().getBytes()); + + File generatedDevTS = new File(targetDir, "testsRunnerDev.js"); + FileUtil.writeToFile(generatedDevTS, sbDev.toString().getBytes()); + + } catch (IOException e) { + e.printStackTrace(); + } + + } + + + private String generateTestSuite(StringBuilder sb, StringBuilder sbDev, PsiClass clazz) { + boolean classInstanciated = false; + for (PsiMethod method : clazz.getAllMethods()) { + boolean ignore = false; + PsiDocComment comment = method.getDocComment(); + if (comment != null) { + PsiDocTag[] tags = comment.getTags(); + if (tags != null) { + for (PsiDocTag tag : tags) { + if (tag.getName().equals(DocTagTranslator.IGNORE) && tag.getValueElement() != null && tag.getValueElement().getText().equals(DocTagTranslator.TS)) { + ignore = true; + } + } + } + } + if (!ignore) { + PsiAnnotation testAnnot = method.getModifierList().findAnnotation("Test"); + if (testAnnot != null) { + if (!classInstanciated) { + sb.append(instanciateClass(clazz)); + sbDev.append(instanciateClassDev(clazz)); + classInstanciated = true; + } + generateTestCall(sb, clazz, method); + generateTestCallDev(sbDev, clazz, method); + } + } + } + if (classInstanciated) { + sb.append("});\n\n"); + sbDev.append("} catch(err) {\n" + + "\tconsole.error(err.stack);\n" + + "}\n\n"); + } + + return sb.toString(); + } + + private String instanciateClass(PsiClass clazz) { + return "\ndescribe(\"" + clazz.getQualifiedName() + "\", function() {\n" + + " var p_" + clazz.getName().toLowerCase() + " = new " + clazz.getQualifiedName() + "();\n"; + } + + private String instanciateClassDev(PsiClass clazz) { + return "try {\n\tvar p_" + clazz.getName().toLowerCase() + " = new " + clazz.getQualifiedName() + "();\n"; + } + + private void generateTestCall(StringBuilder sb, PsiClass clazz, PsiMethod method) { + sb.append(" it(\"" + clazz.getName() + "." + method.getName() + "\", function() {\n"); + sb.append(" expect(p_").append(clazz.getName().toLowerCase()).append(".").append(method.getName()).append(".bind(p_" + clazz.getName().toLowerCase() + ")).not.toThrow();\n"); + sb.append(" });\n"); + } + + private void generateTestCallDev(StringBuilder sb, PsiClass clazz, PsiMethod method) { + sb.append("\tp_").append(clazz.getName().toLowerCase()).append(".").append(method.getName()).append("();\n"); + } + + /* + public static void main(String[] args) { + FlatJUnitGenerator generator = new FlatJUnitGenerator(); + generator.generate(new File("/Users/gnain/Sources/Kevoree-Modeling/mwDB/core/src/test/java"), Paths.get("./transpiler/target", "generated-test-sources", "gentest").toFile()); + }*/ + +} diff --git a/transpiler/src/main/java/java2typescript/JavaAnalyzer.java b/transpiler/src/main/java/java2typescript/JavaAnalyzer.java new file mode 100755 index 0000000..d828697 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/JavaAnalyzer.java @@ -0,0 +1,125 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript; + +import com.intellij.codeInsight.ContainerProvider; +import com.intellij.codeInsight.JavaContainerProvider; +import com.intellij.codeInsight.runner.JavaMainMethodProvider; +import com.intellij.core.*; +import com.intellij.lang.MetaLanguage; +import com.intellij.lang.jvm.facade.JvmElementProvider; +import com.intellij.mock.MockProject; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.extensions.ExtensionsArea; +import com.intellij.openapi.fileTypes.FileTypeExtensionPoint; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.*; +import com.intellij.psi.augment.PsiAugmentProvider; +import com.intellij.psi.augment.TypeAnnotationModifier; +import com.intellij.psi.compiled.ClassFileDecompilers; +import com.intellij.psi.compiled.ClsStubBuilder; +import com.intellij.psi.impl.JavaClassSupersImpl; +import com.intellij.psi.impl.PsiElementFinderImpl; +import com.intellij.psi.impl.PsiNameHelperImpl; +import com.intellij.psi.impl.PsiTreeChangePreprocessor; +import com.intellij.psi.impl.compiled.ClassFileStubBuilder; +import com.intellij.psi.impl.compiled.ClsCustomNavigationPolicy; +import com.intellij.psi.impl.file.impl.JavaFileManager; +import com.intellij.psi.impl.java.stubs.ClsStubPsiFactory; +import com.intellij.psi.impl.java.stubs.PsiClassStub; +import com.intellij.psi.meta.MetaDataContributor; +import com.intellij.psi.stubs.BinaryFileStubBuilders; +import com.intellij.psi.util.JavaClassSupers; + +import java.io.File; + +public class JavaAnalyzer { + + private JavaCoreApplicationEnvironment appEnvironment; + private JavaCoreProjectEnvironment javaEnvironment; + + public JavaAnalyzer() { + Disposable d = () -> { + }; + + CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), ClsCustomNavigationPolicy.EP_NAME, ClsCustomNavigationPolicy.class); + + + + ExtensionsArea area = Extensions.getRootArea(); + CoreApplicationEnvironment.registerExtensionPoint(area, BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class); + CoreApplicationEnvironment.registerExtensionPoint(area, FileContextProvider.EP_NAME, FileContextProvider.class); + CoreApplicationEnvironment.registerExtensionPoint(area, MetaDataContributor.EP_NAME, MetaDataContributor.class); + CoreApplicationEnvironment.registerExtensionPoint(area, PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class); + CoreApplicationEnvironment.registerExtensionPoint(area, JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class); + CoreApplicationEnvironment.registerExtensionPoint(area, ContainerProvider.EP_NAME, ContainerProvider.class); + CoreApplicationEnvironment.registerExtensionPoint(area, ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class); + CoreApplicationEnvironment.registerExtensionPoint(area, TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier.class); + CoreApplicationEnvironment.registerExtensionPoint(area, MetaLanguage.EP_NAME, MetaLanguage.class); + CoreApplicationEnvironment.registerExtensionPoint(area, JavaModuleSystem.EP_NAME, JavaModuleSystem.class); + + CoreApplicationEnvironment.registerApplicationExtensionPoint(ContainerProvider.EP_NAME, JavaContainerProvider.class); + + appEnvironment = new JavaCoreApplicationEnvironment(d); + appEnvironment.registerApplicationService(JavaClassSupers.class, new JavaClassSupersImpl()); + + javaEnvironment = new JavaCoreProjectEnvironment(d, appEnvironment) { + @Override + protected void preregisterServices() { + ExtensionsArea a = Extensions.getArea(myProject); + CoreApplicationEnvironment.registerExtensionPoint(a, PsiTreeChangePreprocessor.EP_NAME, PsiTreeChangePreprocessor.class); + CoreApplicationEnvironment.registerExtensionPoint(a, PsiElementFinder.EP_NAME, PsiElementFinder.class); + CoreApplicationEnvironment.registerExtensionPoint(a, JvmElementProvider.EP_NAME, JvmElementProvider.class); + } + @Override + protected void registerJavaPsiFacade() { + JavaFileManager javaFileManager = getProject().getComponent(JavaFileManager.class); + CoreJavaFileManager coreJavaFileManager = (CoreJavaFileManager) javaFileManager; + ServiceManager.getService(getProject(), CoreJavaFileManager.class); + getProject().registerService(CoreJavaFileManager.class, coreJavaFileManager); + getProject().registerService(PsiNameHelper.class, PsiNameHelperImpl.getInstance()); + PsiElementFinder finder = new PsiElementFinderImpl(getProject(), coreJavaFileManager); + ExtensionsArea area = Extensions.getArea(getProject()); + area.getExtensionPoint(PsiElementFinder.EP_NAME).registerExtension(finder); + super.registerJavaPsiFacade(); + } + }; + System.setProperty("idea.use.native.fs.for.win", "false"); + } + + public void addClasspath(String filePath) { + File f = new File(filePath); + if (f.exists()) { + if (f.isDirectory()) { + javaEnvironment.addSourcesToClasspath(javaEnvironment.getEnvironment().getLocalFileSystem().findFileByIoFile(f)); + } else { + javaEnvironment.addJarToClassPath(f); + } + } + } + + public PsiDirectory analyze(File srcDir) { + VirtualFile vf = javaEnvironment.getEnvironment().getLocalFileSystem().findFileByIoFile(srcDir); + if (vf != null) { + javaEnvironment.addSourcesToClasspath(vf); + return PsiManager.getInstance(javaEnvironment.getProject()).findDirectory(vf); + } + return null; + } + +} diff --git a/transpiler/src/main/java/java2typescript/SourceTranslator.java b/transpiler/src/main/java/java2typescript/SourceTranslator.java new file mode 100755 index 0000000..307e82c --- /dev/null +++ b/transpiler/src/main/java/java2typescript/SourceTranslator.java @@ -0,0 +1,172 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript; + +import com.google.common.collect.Lists; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.psi.*; +import java2typescript.context.TranslationContext; +import java2typescript.translators.ClassTranslator; +import java2typescript.translators.EnumTranslator; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class SourceTranslator { + + private JavaAnalyzer analyzer; + private List srcPaths; + private String outPath; + private String name; + private TranslationContext ctx; + private boolean rootPassed = false; + + public SourceTranslator(String srcPath, String outPath, String name) { + this(Lists.newArrayList(srcPath), outPath, name); + } + + public SourceTranslator(List srcPaths, String outPath, String name) { + this.analyzer = new JavaAnalyzer(); + this.srcPaths = new ArrayList<>(srcPaths); + this.outPath = outPath; + this.name = name; + this.ctx = new TranslationContext(); + } + + private void process(String srcPath) { + ctx.setSrcPath(srcPath); + File srcFolder = new File(srcPath); + if (srcFolder.exists()) { + if (srcFolder.isFile()) { + throw new IllegalArgumentException("Source path is not a directory"); + } + } else { + throw new IllegalArgumentException("Source path " + srcPath + " does not exists"); + } + File outFolder = new File(this.outPath); + + if (!outFolder.exists()) { + outFolder.mkdirs(); + } + + PsiDirectory root = analyzer.analyze(srcFolder); + root.getResolveScope().accept(root.getVirtualFile()); + PsiFile[] containedFiles = root.getFiles(); + Arrays.sort(containedFiles, (f1, f2) -> f1.getName().compareTo(f2.getName())); + for (PsiFile file : containedFiles) { + if (file instanceof PsiJavaFile) { + visit((PsiJavaFile) file); + } else { + visit(file); + } + } + PsiDirectory[] subDirectories = root.getSubdirectories(); + Arrays.sort(subDirectories, (f1, f2) -> f1.getName().compareTo(f2.getName())); + for (PsiDirectory subDir : subDirectories) { + visit(subDir, !rootPassed); + if (!rootPassed) { + rootPassed = true; + } + } + } + + public void process() { + this.srcPaths.forEach(this::process); + } + + public void generate() { + String[] modelPath = new String[]{name + ".ts"}; + File modelFile = Paths.get(outPath, modelPath).toFile(); + try { + FileUtil.writeToFile(modelFile, ctx.toString().getBytes()); + + // files + List files = new ArrayList<>(); + files.add(Paths.get(".", modelPath).toUri()); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void visit(PsiDirectory dir, boolean isRoot) { + ctx.enterPackage(dir.getName(), isRoot); + PsiFile[] containedFiles = dir.getFiles(); + Arrays.sort(containedFiles, (f1, f2) -> f1.getName().compareTo(f2.getName())); + for (PsiFile file : containedFiles) { + if (file instanceof PsiJavaFile) { + visit((PsiJavaFile) file); + } else { + visit(file); + } + } + PsiDirectory[] subDirectories = dir.getSubdirectories(); + Arrays.sort(subDirectories, (f1, f2) -> f1.getName().compareTo(f2.getName())); + for (PsiDirectory subDir : subDirectories) { + visit(subDir, false); + } + ctx.leavePackage(); + } + + private void visit(PsiJavaFile file) { + ctx.setFile(file); + file.acceptChildren(new PsiElementVisitor() { + @Override + public void visitElement(PsiElement element) { + if (element instanceof PsiClass) { + if (((PsiClass) element).isEnum()) { + EnumTranslator.translate((PsiClass) element, ctx); + } else { + ClassTranslator.translate((PsiClass) element, ctx); + } + } + } + }); + } + + private void visit(PsiElement elem) { + System.out.println("Ignored file= " + elem); + } + + public void addToClasspath(String path) { + this.analyzer.addClasspath(path); + } + + + public void addHeader(String moduleImport) { + ctx.addHeader(moduleImport); + } + + public void addPackageTransform(String initialName, String newName) { + ctx.addPackageTransform(initialName, newName); + } + + /** + * Useful for tests + * (you should not mess with this unless you know what you are doing) + * + * @return ctx TranslationContext + */ + protected TranslationContext getCtx() { + return this.ctx; + } + +} diff --git a/transpiler/src/main/java/java2typescript/context/ModuleImport.java b/transpiler/src/main/java/java2typescript/context/ModuleImport.java new file mode 100755 index 0000000..1d3e938 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/context/ModuleImport.java @@ -0,0 +1,92 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.context; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * + * Created by leiko on 3/22/16. + */ +public class ModuleImport { + + private String importAllAs; + private Map properties = new HashMap<>(); + private String name; + + public Map getProperties() { + return properties; + } + + + public void addProperty(String name) { + this.properties.put(name, null); + } + + public void addProperty(String name, String rename) { + this.properties.put(name, rename); + } + + public void importAll(String asName) { + if (asName == null) { + throw new NullPointerException("ModuleImport importAll(...) cannot be called with a null name"); + } + this.properties.clear(); + this.importAllAs = asName; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + if (properties.isEmpty()) { + if (importAllAs != null) { + return "import "+importAllAs+" from '"+name+"';"; + } else { + return "import '"+name+"'"; + } + } else { + StringBuilder props = new StringBuilder("{ "); + Set keySet = properties.keySet(); + Iterator it = keySet.iterator(); + while (it.hasNext()) { + String name = it.next(); + String rename = properties.get(name); + if (rename != null && rename.length() > 0) { + props.append(name); + props.append(" as "); + props.append(rename); + } else { + props.append(name); + } + if (it.hasNext()) { + props.append(", "); + } + } + props.append(" }"); + return "import " +props.toString()+ " from '"+name+"';"; + } + } +} diff --git a/transpiler/src/main/java/java2typescript/context/TranslationContext.java b/transpiler/src/main/java/java2typescript/context/TranslationContext.java new file mode 100755 index 0000000..530a5a3 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/context/TranslationContext.java @@ -0,0 +1,176 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.context; + +import com.intellij.psi.PsiJavaFile; + +import java.util.*; + +public class TranslationContext { + + public boolean NATIVE_ARRAY = true; + private static final int indentSize = 2; + + private StringBuilder sb = new StringBuilder(); + private int indent = 0; + private PsiJavaFile file; + private Set javaClasses = new HashSet<>(); + private String srcPath; + private List headers = new ArrayList<>(); + private Map pkgTransforms = new HashMap<>(); + private ArrayList genericParameterNames; + + public void increaseIdent() { + indent += indentSize; + } + + public void decreaseIdent() { + indent -= indentSize; + if (indent < 0) { + throw new IllegalStateException("Decrease indent was called more times than increase"); + } + } + + public TranslationContext print(String str) { + indent(); + sb.append(str); + return this; + } + + public TranslationContext print(char str) { + indent(); + sb.append(str); + return this; + } + + public void setSrcPath(String srcPath) { + this.srcPath = srcPath; + } + + public void setFile(PsiJavaFile file) { + this.file = file; + } + + public PsiJavaFile getFile() { + return file; + } + + public TranslationContext append(String str) { + sb.append(str); + return this; + } + + public TranslationContext append(char c) { + sb.append(c); + return this; + } + + public void needsJava(String clazz) { + /* + if (this.javaClasses.isEmpty()) { + this.addHeader("* as java from './jre.ts'"); + } + this.javaClasses.add(clazz); + */ + } + + public Set needsJava() { + return this.javaClasses; + } + + @Override + public String toString() { + StringBuilder importsBuilder = new StringBuilder(); + for (String header : headers) { + importsBuilder.append(header); + importsBuilder.append("\n"); + } + if (!headers.isEmpty()) { + importsBuilder.append("\n"); + } + + return importsBuilder.append(sb.toString()).toString(); + } + + public String getContent() { + String content = sb.toString(); + sb = new StringBuilder(content); + return content; + } + + private TranslationContext indent() { + for (int i = 0; i < indent; i++) { + sb.append(' '); + } + return this; + } + + public void enterPackage(String pkgName, boolean isRoot) { + if (isRoot) { + this.print("namespace "); + } else { + this.print("export namespace "); + } + this.append(pkgName); + this.append(" {\n"); + this.increaseIdent(); + } + + public void leavePackage() { + this.decreaseIdent(); + this.print("}\n"); + } + + public String getSrcPath() { + return srcPath; + } + + public void addHeader(String header) { + this.headers.add(header); + } + + public void addPackageTransform(String initialName, String newName) { + this.pkgTransforms.put(initialName, newName); + } + + public String packageTransform(String name) { + int lastIndexOfDot = name.lastIndexOf("."); + if (lastIndexOfDot >= 0) { + String pkg = name.substring(0, lastIndexOfDot); + String transform = this.pkgTransforms.get(pkg); + if (transform != null) { + if (transform.trim().isEmpty()) { + return name.substring(lastIndexOfDot + 1); + } else { + return name.replace(pkg, transform); + } + } + } + return name; + } + + public void setGenericParameterNames(ArrayList genericParameterNames) { + this.genericParameterNames = genericParameterNames; + } + + public ArrayList getGenericParameterNames() { + return this.genericParameterNames; + } + + public void removeGenericParameterNames() { + this.genericParameterNames = null; + } +} diff --git a/transpiler/src/main/java/java2typescript/helper/DocHelper.java b/transpiler/src/main/java/java2typescript/helper/DocHelper.java new file mode 100755 index 0000000..51e17e9 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/helper/DocHelper.java @@ -0,0 +1,130 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.helper; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.javadoc.PsiDocComment; +import com.intellij.psi.javadoc.PsiDocTag; +import com.intellij.psi.javadoc.PsiInlineDocTag; +import java2typescript.metas.DocMeta; +import java2typescript.translators.DocTagTranslator; + +import java.util.ArrayList; + +public class DocHelper { + + public static DocMeta process(PsiDocComment comment) { + DocMeta metas = new DocMeta(); + if (comment != null) { + ArrayList tags = new ArrayList<>(); + //Collects usual tags + PsiDocTag[] usualTags = comment.getTags(); + for (int i = 0; i < usualTags.length; i++) { + tags.add(usualTags[i]); + } + //Collects inline tags + for (PsiElement child : comment.getChildren()) { + if (child instanceof PsiInlineDocTag) { + tags.add((PsiInlineDocTag) child); + } + } + for (PsiDocTag tag : tags) { + if (tag.getName().equals(DocTagTranslator.NATIVE) && tag.getValueElement() != null && tag.getValueElement().getText().equals(DocTagTranslator.TS)) { + metas.nativeActivated = true; + String value = tag.getText(); + String[] lines = value.split("\n"); + int curlyBraceCounter = 0; + for (String line : lines) { + String trimmedLine = line.trim(); + if (trimmedLine.length() > 0 && !trimmedLine.contains("@" + DocTagTranslator.NATIVE) && !trimmedLine.contains("@" + DocTagTranslator.IGNORE) && !trimmedLine.contains("@" + DocTagTranslator.EXTEND)) { + if (trimmedLine.charAt(0) == '*') { + trimmedLine = trimmedLine.substring(1).trim(); + } + int idx = 0; + int nextIdx; + while ((nextIdx = trimmedLine.indexOf('{', idx)) != -1) { + curlyBraceCounter++; + idx = nextIdx + 1; + } + idx = 0; + while ((nextIdx = trimmedLine.indexOf('}', idx)) != -1) { + curlyBraceCounter--; + idx = nextIdx + 1; + } + if (trimmedLine.trim().equals("}") && curlyBraceCounter == -1) { + trimmedLine = ""; + } + if (!trimmedLine.isEmpty()) { + if (metas.nativeBodyLines == null) { + metas.nativeBodyLines = new ArrayList<>(); + } + metas.nativeBodyLines.add(trimmedLine + "\n"); + } + } + } + } + if (tag.getName().equals(DocTagTranslator.EXTEND) && tag.getValueElement() != null && tag.getValueElement().getText().equals(DocTagTranslator.TS)) { + metas.extend = true; + String value = tag.getText(); + String[] lines = value.split("\n"); + int curlyBraceCounter = 0; + for (String line : lines) { + String trimmedLine = line.trim(); + if (trimmedLine.length() > 0 && !trimmedLine.contains("@" + DocTagTranslator.NATIVE) && !trimmedLine.contains("@" + DocTagTranslator.IGNORE) && !trimmedLine.contains("@" + DocTagTranslator.EXTEND)) { + if (trimmedLine.charAt(0) == '*') { + trimmedLine = trimmedLine.substring(1).trim(); + } + int idx = 0; + int nextIdx; + while ((nextIdx = trimmedLine.indexOf('{', idx)) != -1) { + curlyBraceCounter++; + idx = nextIdx + 1; + } + idx = 0; + while ((nextIdx = trimmedLine.indexOf('}', idx)) != -1) { + curlyBraceCounter--; + idx = nextIdx + 1; + } + if (trimmedLine.trim().equals("}") && curlyBraceCounter == -1) { + trimmedLine = ""; + } + if (!trimmedLine.isEmpty()) { + if (metas.nativeBodyLines == null) { + metas.nativeBodyLines = new ArrayList<>(); + } + metas.nativeBodyLines.add(trimmedLine + "\n"); + } + } + } + } + if (tag.getName().equals(DocTagTranslator.IGNORE) && tag.getValueElement() != null && tag.getValueElement().getText().equals(DocTagTranslator.TS)) { + metas.ignored = true; + } + if (tag.getName().equals(DocTagTranslator.OPTIONAL)) { + for (PsiElement elem : tag.getDataElements()) { + if (!elem.getText().contains(" ")) { + metas.optional.add(elem.getText()); + } + } + } + if (tag.getName().equals(DocTagTranslator.TS_CALLBACK)) { + metas.functionType = true; + } + } + } + return metas; + } +} diff --git a/transpiler/src/main/java/java2typescript/helper/GenericHelper.java b/transpiler/src/main/java/java2typescript/helper/GenericHelper.java new file mode 100755 index 0000000..a50fa69 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/helper/GenericHelper.java @@ -0,0 +1,113 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.helper; + +import com.intellij.psi.*; +import com.intellij.psi.impl.source.PsiClassReferenceType; +import java2typescript.context.TranslationContext; + +import java.util.ArrayList; + +/** + * + * Created by leiko on 3/15/16. + */ +public class GenericHelper { + + public static String process(PsiClass clazz) { + String type = clazz.getQualifiedName(); + PsiTypeParameter[] typeParameters = clazz.getTypeParameters(); + if (typeParameters.length > 0) { + String[] generics = new String[typeParameters.length]; + for (int i = 0; i < typeParameters.length; i++) { + generics[i] = "any"; + } + type += "<"+String.join(", ", generics)+">"; + } + return type; + } + + public static String process(PsiClassReferenceType classRefType, TranslationContext ctx, boolean withGenerics) { + String result = ""; + PsiJavaCodeReferenceElement ref = classRefType.getReference(); + if (ref.getText().endsWith("<>")) { + result = processDiamondOperator(ref.getParent().getParent(), ctx); + } else { + ArrayList genericParameterNames = ctx.getGenericParameterNames(); + if (classRefType.getParameterCount() > 0) { + String[] generics = new String[classRefType.getParameterCount()]; + PsiType[] genericTypes = classRefType.getParameters(); + for (int i = 0; i < genericTypes.length; i++) { + if (genericTypes[i] instanceof PsiWildcardType) { + if (((PsiWildcardType) genericTypes[i]).getBound() != null) { + if (classRefType.getReference().getParent().getParent() instanceof PsiParameter) { + PsiParameter param = (PsiParameter) classRefType.getReference().getParent().getParent(); + PsiParameterList paramList = (PsiParameterList) param.getParent(); + generics[i] = genericParameterNames.get(paramList.getParameterIndex(param)); + } + } else { + generics[i] = "any"; + } + } else { + generics[i] = TypeHelper.printType(genericTypes[i], ctx, true, false); + } + } + result += "<" + String.join(", ", generics) + ">"; + } else if (withGenerics) { + PsiClass clazz = classRefType.resolve(); + if (clazz != null) { + if (clazz.getTypeParameters().length > 0) { + String[] genericParams = new String[clazz.getTypeParameters().length]; + for (int i=0; i < clazz.getTypeParameters().length; i++) { + genericParams[i] = "any"; + } + result = "<" + String.join(", ", genericParams) + ">"; + } + } else { + if (ref.getText().endsWith("<>")) { + result = processDiamondOperator(ref.getParent().getParent(), ctx); + } + } + } else { + if (classRefType.getPresentableText().contains("<")) { + result += ""; + } + } + } + + return result; + } + + private static String processDiamondOperator(PsiElement element, TranslationContext ctx) { + String result; + // Java 7 diamond operator not possible in TypeScript + if (element instanceof PsiField) { + PsiField field = (PsiField) element; + result = process((PsiClassReferenceType) field.getType(), ctx, true); + } else if (element instanceof PsiLocalVariable) { + System.out.println("DIAMOND LOCALVAR> " + ((PsiLocalVariable) element).getType()); + PsiLocalVariable localVar = (PsiLocalVariable) element; + result = process((PsiClassReferenceType) localVar.getType(), ctx, true); + } else if (element instanceof PsiAssignmentExpression) { + PsiAssignmentExpression assign = (PsiAssignmentExpression) element; + result = process((PsiClassReferenceType) assign.getLExpression().getType(), ctx, true); + } else { + System.out.println("DIAMOND > "+element); + result = ""; + } + return result; + } +} diff --git a/transpiler/src/main/java/java2typescript/helper/ImportHelper.java b/transpiler/src/main/java/java2typescript/helper/ImportHelper.java new file mode 100755 index 0000000..f01ba4d --- /dev/null +++ b/transpiler/src/main/java/java2typescript/helper/ImportHelper.java @@ -0,0 +1,56 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.helper; + +import com.intellij.psi.PsiElement; +import java2typescript.context.TranslationContext; + +/** + * + * Created by leiko on 20/11/15. + */ +public class ImportHelper { + + public static void importIfValid(PsiElement resolution, TranslationContext ctx) { +// if (resolution != null) { +// if (!ctx.getFile().getVirtualFile().getPath().equals(resolution.getContainingFile().getVirtualFile().getPath())) { +// Path elemPath = Paths.get(ctx.getFile().getParent().getVirtualFile().getPath()); +// Path resolPath = Paths.get(resolution.getContainingFile().getVirtualFile().getPath()); +// +// String pathToResol = elemPath.relativize(resolPath).toString(); +// if (!pathToResol.isEmpty()) { +// ctx.addImport(((PsiClass) resolution).getName(), "./"+pathToResol.substring(0, pathToResol.lastIndexOf("."))); +// } +// } +// } + } + + public static String getGeneratedName(PsiElement resolution, TranslationContext ctx) { +// if (resolution != null) { +// if (!ctx.getFile().getVirtualFile().getPath().equals(resolution.getContainingFile().getVirtualFile().getPath())) { +// Path elemPath = Paths.get(ctx.getFile().getParent().getVirtualFile().getPath()); +// Path resolPath = Paths.get(resolution.getContainingFile().getVirtualFile().getPath()); +// +// String pathToResol = elemPath.relativize(resolPath).toString(); +// if (!pathToResol.isEmpty()) { +// return ctx.getImportGeneratedName(((PsiClass) resolution).getName(), "./"+pathToResol.substring(0, pathToResol.lastIndexOf("."))); +// } +// } +// } + + return null; + } +} diff --git a/transpiler/src/main/java/java2typescript/helper/KeywordHelper.java b/transpiler/src/main/java/java2typescript/helper/KeywordHelper.java new file mode 100755 index 0000000..4c0a241 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/helper/KeywordHelper.java @@ -0,0 +1,35 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.helper; + +import com.google.common.collect.Sets; +import java2typescript.context.TranslationContext; + +import java.util.Set; + +public class KeywordHelper { + + public static final Set reservedWords = Sets.newHashSet( + "let", "var", "debugger", "constructor", "yield", "export", "with", "function", "typeof", "in"); + + public static String process(String name, TranslationContext ctx) { + if (reservedWords.contains(name)) { + throw new IllegalArgumentException("Name \""+name+"\" in " + PathHelper.lastPart(ctx) + + " should not use TypeScript reserved keywords: " + reservedWords.toString()); + } + return name; + } +} diff --git a/transpiler/src/main/java/java2typescript/helper/PathHelper.java b/transpiler/src/main/java/java2typescript/helper/PathHelper.java new file mode 100755 index 0000000..a23ab9f --- /dev/null +++ b/transpiler/src/main/java/java2typescript/helper/PathHelper.java @@ -0,0 +1,54 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.helper; + +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiJavaFile; +import java2typescript.context.TranslationContext; + +import java.io.File; + +/** + * + * Created by leiko on 20/11/15. + */ +public class PathHelper { + + public static String getPath(String srcPath, String outPath, PsiDirectory dir) { + return outPath + dir.getVirtualFile().getPath().substring(srcPath.length()); + } + + public static String getPath(String srcPath, String outPath, String dir) { + return outPath + dir.substring(srcPath.length()); + } + +// public static String getPath(TranslationContext ctx, PsiDirectory dir) { +// return getPath(ctx.getSrcPath(), ctx.getOutPath(), dir); +// } + + public static String getPath(String srcPath, String outPath, PsiJavaFile file) { + return getPath(srcPath, outPath, file.getParent()) + File.separator + file.getName().replaceAll("\\.java$", ".ts"); + } + +// public static String getPath(TranslationContext ctx, PsiJavaFile file) { +// return getPath(ctx.getSrcPath(), ctx.getOutPath(), file); +// } + + public static String lastPart(TranslationContext ctx) { + String path = ctx.getFile().getVirtualFile().getPath(); + return path.substring(ctx.getSrcPath().length()+1); + } +} diff --git a/transpiler/src/main/java/java2typescript/helper/TypeHelper.java b/transpiler/src/main/java/java2typescript/helper/TypeHelper.java new file mode 100755 index 0000000..8f62327 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/helper/TypeHelper.java @@ -0,0 +1,288 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.helper; + +import com.google.common.collect.ImmutableSet; +import com.intellij.psi.*; +import com.intellij.psi.impl.source.PsiClassReferenceType; +import java2typescript.context.TranslationContext; +import java2typescript.metas.DocMeta; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +public class TypeHelper { + + public static String printType(PsiType element, TranslationContext ctx) { + return printType(element, ctx, true, false); + } + + + public static String printType(PsiType element, TranslationContext ctx, boolean withGenericParams, boolean avoidNativeOptim) { + String result = element.getPresentableText(); + + if (result.equals("Throwable") || result.endsWith("Exception")) { + return "Error"; + } + if (result.equals("Pattern")) { + return "RegExp"; + } + if (objects.contains(result) || classes.contains(result)) { + return "any"; + } else if (primitiveNumbers.contains(result) || objectNumbers.contains(result)) { + return "number"; + } else if (strings.contains(result)) { + return "string"; + } else if (booleans.contains(result)) { + return "boolean"; + } + /* + if (ctx.NATIVE_ARRAY && !avoidNativeOptim && element.getArrayDimensions() == 1) { + return printArrayBaseType(element); + }*/ + if (element instanceof PsiPrimitiveType) { + if (result.equals("null")) { + System.err.println("TypeHelper::printType -> Result null with elem:" + element.toString()); + } + return result; + } else if (element instanceof PsiArrayType) { + PsiArrayType typedElement = (PsiArrayType) element; + String partialResult = printArrayBaseType(typedElement); + if (partialResult != null) { + result = ""; + for (int i = 1; i < typedElement.getArrayDimensions(); i++) { + result += "Array<"; + } + result += partialResult; + for (int i = 1; i < typedElement.getArrayDimensions(); i++) { + result += ">"; + } + } else { + partialResult = printType(typedElement.getComponentType(), ctx, withGenericParams, avoidNativeOptim); + if (withGenericParams) { + result = partialResult + "[]"; + } else { + result = partialResult; + } + } + return result; + } else if (element instanceof PsiClassReferenceType) { + PsiClassReferenceType elementClassRefType = ((PsiClassReferenceType) element); + PsiClass resolvedClass = elementClassRefType.resolve(); + + if (resolvedClass != null) { + if (resolvedClass.getQualifiedName() == null) { + result = resolvedClass.getName(); + } else { + result = resolvedClass.getQualifiedName(); + result += GenericHelper.process(elementClassRefType, ctx, withGenericParams); + } + } else { + if (((PsiClassReferenceType) element).getClassName().startsWith("Class")) { + // "Class" concept does not exists in TypeScript => any + result = "any"; + } else { + String tryJavaUtil = javaTypes.get(elementClassRefType.getClassName()); + if (tryJavaUtil != null) { + ctx.needsJava(tryJavaUtil); + result = tryJavaUtil; + } else { + result = elementClassRefType.getReference().getQualifiedName(); + } + result += GenericHelper.process(elementClassRefType, ctx, withGenericParams); + } + } + } else if (element instanceof PsiWildcardType) { + PsiType bound = ((PsiWildcardType) element).getBound(); + if (bound != null) { + result = "T"; + } else { + result = "any"; + } + } else { + System.out.println("TypeHelper: unhandled type -> " + element); + } + + if (result.equals("null")) { + // this is kind of desperate but well... + result = element.getPresentableText(); + } + + return ctx.packageTransform(result); + } + + public static String printArrayBaseType(PsiType type) { + if (type.toString().contains("int[]")) { + return "Int32Array"; + } else if (type.toString().contains("double[]")) { + return "Float64Array"; + } else if (type.toString().contains("long[]")) { + return "Float64Array"; + } else if (type.toString().contains("byte[]")) { + return "Int8Array"; + } + return null; + } + + public static boolean isCallbackClass(PsiClass clazz) { + if (clazz == null) { + return false; + } + + PsiAnnotation[] annots = clazz.getModifierList() != null ? clazz.getModifierList().getAnnotations() : new PsiAnnotation[0]; + for (int i = 0; i < annots.length; i++) { + if (annots[i].getNameReferenceElement().getReferenceName().equals("FunctionalInterface")) { + return true; + } + } + DocMeta metas = DocHelper.process(clazz.getDocComment()); + return metas.functionType; + } + + public static String primitiveStaticCall(String clazz, TranslationContext ctx) { + String result = javaTypes.get(clazz); + if (result != null) { + ctx.needsJava(result); + return result; + } + return KeywordHelper.process(clazz, ctx); + } + + + public static final HashMap javaTypes = new HashMap(); + + static { + + javaTypes.put("Assert", "junit.Assert"); + + javaTypes.put("System", "java.lang.System"); + + javaTypes.put("AtomicBoolean", "java.util.concurrent.atomic.AtomicBoolean"); + javaTypes.put("AtomicInteger", "java.util.concurrent.atomic.AtomicInteger"); + javaTypes.put("AtomicLong", "java.util.concurrent.atomic.AtomicLong"); + javaTypes.put("AtomicReference", "java.util.concurrent.atomic.AtomicReference"); + javaTypes.put("AtomicIntegerArray", "java.util.concurrent.atomic.AtomicIntegerArray"); + javaTypes.put("AtomicLongArray", "java.util.concurrent.atomic.AtomicLongArray"); + javaTypes.put("AtomicReferenceArray", "java.util.concurrent.atomic.AtomicReferenceArray"); + + javaTypes.put("ReentrantLock", "java.util.concurrent.locks.ReentrantLock"); + + javaTypes.put("Arrays", "java.util.Arrays"); + javaTypes.put("Collections", "java.util.Collections"); + javaTypes.put("Map", "java.util.Map"); + javaTypes.put("Stack", "java.util.Stack"); + javaTypes.put("HashMap", "java.util.HashMap"); + javaTypes.put("ConcurrentHashMap", "java.util.ConcurrentHashMap"); + javaTypes.put("List", "java.util.List"); + javaTypes.put("Set", "java.util.Set"); + javaTypes.put("HashSet", "java.util.HashSet"); + javaTypes.put("ArrayList", "java.util.ArrayList"); + javaTypes.put("LinkedList", "java.util.LinkedList"); + javaTypes.put("Random", "java.util.Random"); + javaTypes.put("Iterator", "java.util.Iterator"); + javaTypes.put("ListIterator", "java.util.ListIterator"); + + javaTypes.put("Long", "java.lang.Long"); + javaTypes.put("Double", "java.lang.Double"); + javaTypes.put("Float", "java.lang.Float"); + javaTypes.put("Integer", "java.lang.Integer"); + javaTypes.put("Short", "java.lang.Short"); + javaTypes.put("Boolean", "java.lang.Boolean"); + javaTypes.put("String", "java.lang.String"); + javaTypes.put("StringBuilder", "java.lang.StringBuilder"); + + javaTypes.put("Thread", "java.lang.Thread"); + javaTypes.put("Throwable", "java.lang.Throwable"); + javaTypes.put("Exception", "java.lang.Exception"); + javaTypes.put("Runnable", "java.lang.Runnable"); + javaTypes.put("RuntimeException", "java.lang.RuntimeException"); + javaTypes.put("IndexOutOfBoundsException", "java.lang.IndexOutOfBoundsException"); + javaTypes.put("WeakReference", "java.lang.ref.WeakReference"); + } + + public static final Set primitiveNumbers = ImmutableSet.of("byte", "short", "int", "long", "float", "double"); + + public static final Set objectNumbers = ImmutableSet.of( + Byte.class.getName(), + Byte.class.getSimpleName(), + Short.class.getName(), + Short.class.getSimpleName(), + Integer.class.getName(), + Integer.class.getSimpleName(), + Long.class.getName(), + Long.class.getSimpleName(), + Float.class.getName(), + Float.class.getSimpleName(), + Double.class.getName(), + Double.class.getSimpleName(), + BigInteger.class.getName(), + BigInteger.class.getSimpleName(), + BigDecimal.class.getName(), + BigDecimal.class.getSimpleName(), + Number.class.getName(), + Number.class.getSimpleName() + ); + + public static final Set strings = ImmutableSet.of( + "char", + Character.class.getName(), + Character.class.getSimpleName(), + String.class.getName(), + String.class.getSimpleName() + ); + + public static final Set booleans = ImmutableSet.of( + "boolean", + Boolean.class.getName(), + Boolean.class.getSimpleName() + ); + + public static final Set objects = ImmutableSet.of( + Object.class.getName(), + Object.class.getSimpleName() + ); + + public static final Set classes = ImmutableSet.of( + Class.class.getName(), + Class.class.getSimpleName() + ); + + private static final String genericLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + public static String availableGenericType(HashSet usedGenerics) { + if (usedGenerics.isEmpty()) { + return "A"; + } else { + return availableGenericType(usedGenerics, 0); + } + } + + private static String availableGenericType(HashSet usedGenerics, int count) { + if (count == genericLetters.length() - 1) { + throw new UnsupportedOperationException("Unable to find a suitable generic type character"); + } else { + String genType = genericLetters.substring(count, count + 1); + if (!usedGenerics.contains(genType)) { + return genType; + } else { + return availableGenericType(usedGenerics, count + 1); + } + } + } +} diff --git a/transpiler/src/main/java/java2typescript/metas/DocMeta.java b/transpiler/src/main/java/java2typescript/metas/DocMeta.java new file mode 100755 index 0000000..8ce45b3 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/metas/DocMeta.java @@ -0,0 +1,29 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.metas; + +import java.util.ArrayList; +import java.util.List; + +public class DocMeta { + + public boolean nativeActivated = false; + public boolean ignored = false; + public boolean extend = false; + public boolean functionType = false; + public List optional = new ArrayList(); + public List nativeBodyLines; +} diff --git a/transpiler/src/main/java/java2typescript/translators/AnonymousClassTranslator.java b/transpiler/src/main/java/java2typescript/translators/AnonymousClassTranslator.java new file mode 100755 index 0000000..68e4459 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/AnonymousClassTranslator.java @@ -0,0 +1,101 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators; + +import com.google.common.base.*; +import com.intellij.psi.*; +import java2typescript.context.TranslationContext; +import java2typescript.helper.KeywordHelper; +import java2typescript.helper.TypeHelper; + +import java.util.*; + +public class AnonymousClassTranslator { + + // private static final Joiner joiner = Joiner.on(", ").withKeyValueSeparator().; + + public static void translate(PsiAnonymousClass element, TranslationContext ctx) { + if (TypeHelper.isCallbackClass(element.getBaseClassType().resolve())) { + PsiMethod method = element.getAllMethods()[0]; + PsiParameter[] parameters = method.getParameterList().getParameters(); + String[] methodParameters = new String[parameters.length]; + for (int i = 0; i < methodParameters.length; i++) { + methodParameters[i] = KeywordHelper.process(parameters[i].getName(), ctx) + " : " + TypeHelper.printType(parameters[i].getTypeElement().getType(), ctx); + } + ctx.append("(" + String.join(", ", methodParameters) + ") => {\n"); + if (method.getBody() != null) { + ctx.increaseIdent(); + CodeBlockTranslator.translate(method.getBody(), ctx); + ctx.decreaseIdent(); + } + ctx.print("}"); + } else { + ctx.append("{\n"); + ctx.increaseIdent(); + printClassMembers(element, ctx); + ctx.decreaseIdent(); + ctx.print("}"); + } + } + + private static void printClassMembers(PsiClass element, TranslationContext ctx) { + PsiMethod[] methods = element.getMethods(); + for (int i = 0; i < methods.length; i++) { + ctx.print(methods[i].getName()); + ctx.append(": function ("); + printParameterList(methods[i], ctx); + ctx.append(") {\n"); + if (methods[i].getBody() != null) { + ctx.increaseIdent(); + CodeBlockTranslator.translate(methods[i].getBody(), ctx); + ctx.decreaseIdent(); + } + ctx.print("}"); + if (i < methods.length - 1) { + ctx.append(",\n"); + } else { + ctx.append("\n"); + } + } + } + + private static void printParameterList(PsiMethod element, TranslationContext ctx) { + List params = new ArrayList(); + for (PsiParameter parameter : element.getParameterList().getParameters()) { + StringBuilder paramSB = new StringBuilder(); + paramSB.setLength(0); + if (parameter.isVarArgs()) { + paramSB.append("..."); + } + paramSB.append(KeywordHelper.process(parameter.getName(), ctx)); + paramSB.append(": "); + paramSB.append(TypeHelper.printType(parameter.getType(), ctx)); + params.add(paramSB.toString()); + } + //JOIN + StringBuilder buf = new StringBuilder(); + for (int i = 0; i < params.size(); i++) { + if (i == 0) { + buf.append(params.get(i)); + } else { + buf.append(", "); + buf.append(params.get(i)); + } + } + ctx.append(buf.toString()); + } + +} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/ClassTranslator.java b/transpiler/src/main/java/java2typescript/translators/ClassTranslator.java similarity index 51% rename from org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/ClassTranslator.java rename to transpiler/src/main/java/java2typescript/translators/ClassTranslator.java index 2d156d1..dc36ae2 100755 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/ClassTranslator.java +++ b/transpiler/src/main/java/java2typescript/translators/ClassTranslator.java @@ -1,63 +1,53 @@ - -package org.kevoree.modeling.java2typescript.translators; +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators; import com.intellij.psi.*; import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.psi.javadoc.PsiDocTag; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; - -import java.util.ArrayList; +import java2typescript.helper.DocHelper; +import java2typescript.context.TranslationContext; +import java2typescript.helper.TypeHelper; +import java2typescript.metas.DocMeta; public class ClassTranslator { public static void translate(PsiClass clazz, TranslationContext ctx) { - - boolean ignoreClass = false; - boolean nativeActivated = false; - PsiDocComment comment = clazz.getDocComment(); - if (comment != null) { - PsiDocTag[] tags = comment.getTags(); - if (tags != null) { - for (PsiDocTag tag : tags) { - if (tag.getName().equals(NativeTsTranslator.TAG_IGNORE) && tag.getValueElement()!=null && tag.getValueElement().getText().equals(NativeTsTranslator.TAG_VAL_TS)) { - ignoreClass = true; - } - if (tag.getName().equals(NativeTsTranslator.TAG) && tag.getValueElement()!=null && tag.getValueElement().getText().equals(NativeTsTranslator.TAG_VAL_TS)) { - nativeActivated = true; - } - } - } - } - if (ignoreClass) { + DocMeta metas = DocHelper.process(clazz.getDocComment()); + if (metas.ignored) { //we skip the class return; } - if (clazz.isInterface()) { + + if (clazz.getModifierList() != null && + clazz.getModifierList().hasExplicitModifier(PsiModifier.ABSTRACT)) { + ctx.print("export abstract class "); + } else if (clazz.isInterface()) { ctx.print("export interface "); } else { ctx.print("export class "); } + ctx.append(clazz.getName()); - PsiTypeParameter[] typeParameters = clazz.getTypeParameters(); - if (typeParameters.length > 0) { - ctx.append('<'); - for (int i = 0; i < typeParameters.length; i++) { - PsiTypeParameter p = typeParameters[i]; - ctx.append(p.getName()); - PsiClassType[] extentions = p.getExtendsList().getReferencedTypes(); - if (extentions.length > 0) { - ctx.append(" extends "); - for (PsiClassType ext : extentions) { - ctx.append(TypeHelper.printType(ext, ctx)); - } - } - if (i != typeParameters.length - 1) { - ctx.append(", "); - } - } - ctx.append('>'); + String genericParams = TypeParametersTranslator.print(clazz.getTypeParameters(), ctx); + if (!genericParams.isEmpty()) { + ctx.append("<"); + ctx.append(genericParams); + ctx.append(">"); } + PsiClassType[] extendsList = clazz.getExtendsListTypes(); if (extendsList.length != 0 && !clazz.isEnum()) { ctx.append(" extends "); @@ -68,18 +58,17 @@ public static void translate(PsiClass clazz, TranslationContext ctx) { ctx.append(" implements "); writeTypeList(ctx, implementsList); } - ctx.append(" {\n\n"); + ctx.append(" {\n"); - if (!nativeActivated) { - printClassMembers(clazz, ctx); - } else { + if (metas.nativeActivated) { ctx.increaseIdent(); - NativeTsTranslator.translate(comment, ctx); + DocTagTranslator.translate(metas, ctx); ctx.decreaseIdent(); + } else { + printClassMembers(clazz, ctx, metas); } ctx.print("}\n"); - ctx.append("\n"); printInnerClasses(clazz, ctx); } @@ -87,61 +76,86 @@ private static void printInnerClasses(PsiClass element, TranslationContext ctx) PsiClass[] innerClasses = element.getInnerClasses(); boolean atLeastOne = false; - for(PsiClass loopClass : innerClasses){ - boolean ignoreClass = false; - PsiDocComment comment = loopClass.getDocComment(); - if (comment != null) { - PsiDocTag[] tags = comment.getTags(); - if (tags != null) { - for (PsiDocTag tag : tags) { - if (tag.getName().equals(NativeTsTranslator.TAG_IGNORE) && tag.getValueElement()!=null && tag.getValueElement().getText().equals(NativeTsTranslator.TAG_VAL_TS)) { - ignoreClass = true; - } - } - } - } - if(!ignoreClass){ + for (PsiClass loopClass : innerClasses) { + DocMeta docMeta = DocHelper.process(loopClass.getDocComment()); + if (!docMeta.ignored) { atLeastOne = true; } } if (innerClasses.length > 0 && atLeastOne) { - ctx.print("export module ").append(element.getName()).append(" { \n"); + ctx.print("export namespace "); + ctx.append(element.getName()); + ctx.append(" {\n"); ctx.increaseIdent(); - for (PsiClass innerClass : innerClasses) { + for (int i=0; i < innerClasses.length; i++) { + PsiClass innerClass = innerClasses[i]; translate(innerClass, ctx); - ctx.append("\n"); + if (i < innerClasses.length-1) { + ctx.append("\n"); + } } ctx.decreaseIdent(); ctx.print("}\n"); } } - private static void printClassMembers(PsiClass clazz, TranslationContext ctx) { + private static void printClassMembers(PsiClass clazz, TranslationContext ctx, DocMeta classMetas) { ctx.increaseIdent(); PsiField[] fields = clazz.getFields(); for (PsiField field : fields) { FieldTranslator.translate(field, ctx); } PsiClassInitializer[] initializers = clazz.getInitializers(); - for (PsiClassInitializer initializer : initializers) { + initLoop : for (PsiClassInitializer initializer : initializers) { + PsiElement p = initializer.getModifierList(); + while(p != null) { + if(p instanceof PsiDocComment) { + DocMeta metas = DocHelper.process((PsiDocComment) p); + if (metas.ignored) { + continue initLoop; + } + } + p = p.getPrevSibling(); + } + if (initializer.hasModifierProperty("static")) { ctx.print("//TODO Resolve static initializer\n"); - ctx.print("static {\n"); + ctx.print("static {"); } else { ctx.print("//TODO Resolve instance initializer\n"); - ctx.print("{\n"); + ctx.print("{"); + } + if (initializer.getBody().getStatements().length > 0) { + ctx.append("\n"); + ctx.increaseIdent(); + CodeBlockTranslator.translate(initializer.getBody(), ctx); + ctx.decreaseIdent(); + ctx.print("}\n"); + } else { + ctx.append("}\n"); } - ctx.increaseIdent(); - CodeBlockTranslator.translate(initializer.getBody(), ctx); - ctx.decreaseIdent(); - ctx.print("}\n"); } PsiMethod[] methods = clazz.getMethods(); - for (PsiMethod method : methods) { - MethodTranslator.translate(method, ctx); + if (TypeHelper.isCallbackClass(clazz)) { + MethodTranslator.translate(methods[0], ctx, true); + } else { + // TODO handle method with same name but different signature +// Map> methodsByName = new HashMap<>(); +// for (PsiMethod method : methods) { +// List mList = methodsByName.get(method.getName()); +// if (mList == null) { +// mList = new ArrayList<>(); +// methodsByName.put(method.getName(), mList); +// } +// mList.add(method); +// } + for (PsiMethod method: methods) { + MethodTranslator.translate(method, ctx, false); + } } - if (clazz.isEnum()) { + + /*if (clazz.isEnum()) { ctx.print("public equals(other: any): boolean {\n"); ctx.increaseIdent(); ctx.print("return this == other;\n"); @@ -179,14 +193,15 @@ private static void printClassMembers(PsiClass clazz, TranslationContext ctx) { ctx.decreaseIdent(); ctx.print("}\n"); - } + }*/ + DocTagTranslator.translate(classMetas, ctx); ctx.decreaseIdent(); } private static void writeTypeList(TranslationContext ctx, PsiClassType[] typeList) { for (int i = 0; i < typeList.length; i++) { PsiClassType type = typeList[i]; - ctx.append(TypeHelper.printType(type, ctx, true, true)); + ctx.append(TypeHelper.printType(type, ctx, false, false)); if (i != typeList.length - 1) { ctx.append(", "); } diff --git a/transpiler/src/main/java/java2typescript/translators/CodeBlockTranslator.java b/transpiler/src/main/java/java2typescript/translators/CodeBlockTranslator.java new file mode 100755 index 0000000..423abb8 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/CodeBlockTranslator.java @@ -0,0 +1,35 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators; + +import com.intellij.psi.PsiCodeBlock; +import com.intellij.psi.PsiStatement; +import java2typescript.context.TranslationContext; +import java2typescript.translators.statement.StatementTranslator; + +public class CodeBlockTranslator { + + public static void translate(PsiCodeBlock block, TranslationContext ctx) { + ctx.append("{\n"); + ctx.increaseIdent(); + for (PsiStatement statement : block.getStatements()) { + StatementTranslator.translate(statement, ctx); + } + ctx.decreaseIdent(); + ctx.print("}"); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/DocTagTranslator.java b/transpiler/src/main/java/java2typescript/translators/DocTagTranslator.java new file mode 100755 index 0000000..dd728f7 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/DocTagTranslator.java @@ -0,0 +1,43 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators; + +import java2typescript.context.TranslationContext; +import java2typescript.metas.DocMeta; + +public class DocTagTranslator { + + public static final String NATIVE = "native"; + + public static final String IGNORE = "ignore"; + + public static final String EXTEND = "extend"; + + public static final String TS = "ts"; + + public static final String TS_CALLBACK = "ts_callback"; + + public static final String OPTIONAL = "optional"; + + + public static void translate(DocMeta docMeta, TranslationContext ctx) { + if ((docMeta.nativeActivated || docMeta.extend) && docMeta.nativeBodyLines != null) { + for (String line : docMeta.nativeBodyLines) { + ctx.print(line); + } + } + } +} diff --git a/transpiler/src/main/java/java2typescript/translators/EnumTranslator.java b/transpiler/src/main/java/java2typescript/translators/EnumTranslator.java new file mode 100644 index 0000000..59aa290 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/EnumTranslator.java @@ -0,0 +1,110 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators; + +import com.intellij.psi.*; +import com.intellij.psi.javadoc.PsiDocComment; +import java2typescript.context.TranslationContext; +import java2typescript.helper.DocHelper; +import java2typescript.helper.TypeHelper; +import java2typescript.metas.DocMeta; + +public class EnumTranslator { + + public static void translate(PsiClass enumClass, TranslationContext ctx) { + DocMeta metas = DocHelper.process(enumClass.getDocComment()); + if (metas.ignored) { + //we skip the class + return; + } + + ctx.print("export enum "); + + ctx.append(enumClass.getName()); + + ctx.append(" {\n"); + + if (metas.nativeActivated) { + ctx.increaseIdent(); + DocTagTranslator.translate(metas, ctx); + ctx.decreaseIdent(); + } else { + printEnumMembers(enumClass, ctx); + } + + ctx.print("}\n"); + } + + private static void printEnumMembers(PsiClass enumClass, TranslationContext ctx) { + + ctx.increaseIdent(); + boolean isFirst = true; + + for (int i = 0; i < enumClass.getFields().length; i++) { + if (enumClass.getFields()[i].hasModifierProperty("static")) { + if (!isFirst) { + ctx.append(", "); + } else { + ctx.print(""); + isFirst = false; + } + ctx.append(enumClass.getFields()[i].getName().trim()); + } + } + ctx.append("\n"); + ctx.decreaseIdent(); + /* + ctx.print("public equals(other: any): boolean {\n"); + ctx.increaseIdent(); + ctx.print("return this == other;\n"); + ctx.decreaseIdent(); + ctx.print("}\n"); + ctx.print("public static _" + clazz.getName() + "VALUES : " + clazz.getName() + "[] = [\n"); + ctx.increaseIdent(); + boolean isFirst = true; + for (int i = 0; i < clazz.getFields().length; i++) { + if (clazz.getFields()[i].hasModifierProperty("static")) { + if (!isFirst) { + ctx.print(","); + } else { + ctx.print(""); + } + ctx.append(clazz.getName()); + ctx.append("."); + ctx.append(clazz.getFields()[i].getName()); + ctx.append("\n"); + isFirst = false; + } + } + ctx.decreaseIdent(); + ctx.print("];\n"); + + ctx.print("public static values():"); + ctx.append(clazz.getName()); + ctx.append("[]{\n"); + ctx.increaseIdent(); + ctx.print("return "); + ctx.append(clazz.getName()); + ctx.append("._"); + ctx.append(clazz.getName()); + ctx.append("VALUES;\n"); + ctx.decreaseIdent(); + ctx.print("}\n"); + */ + + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/FieldTranslator.java b/transpiler/src/main/java/java2typescript/translators/FieldTranslator.java new file mode 100755 index 0000000..1d1d7cc --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/FieldTranslator.java @@ -0,0 +1,95 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators; + +import com.intellij.psi.*; +import com.intellij.psi.impl.source.PsiClassReferenceType; +import java2typescript.helper.DocHelper; +import java2typescript.context.TranslationContext; +import java2typescript.helper.TypeHelper; +import java2typescript.metas.DocMeta; +import java2typescript.translators.expression.ExpressionListTranslator; +import java2typescript.translators.expression.ExpressionTranslator; + +public class FieldTranslator { + + public static void translate(PsiField element, TranslationContext ctx) { + //Check for native code + DocMeta docMeta = DocHelper.process(element.getDocComment()); + if (docMeta.ignored) { + return; + } + if (!docMeta.nativeActivated) { + if (element instanceof PsiEnumConstant) { + translateEnumConstant((PsiEnumConstant) element, ctx); + } else { + translateClassField(element, ctx, docMeta); + } + } else { + DocTagTranslator.translate(docMeta, ctx); + } + } + + private static void translateEnumConstant(PsiEnumConstant element, TranslationContext ctx) { + String enumName = ((PsiClass) element.getParent()).getName(); + ctx.print("public static ").append(element.getName()).append(": ").append(enumName); + ctx.append(" = new ").append(enumName); + ctx.append('('); + if (element.getArgumentList() != null) { + ExpressionListTranslator.translate(element.getArgumentList(), ctx); + } + ctx.append(");\n"); + } + + private static void translateClassField(PsiField element, TranslationContext ctx, DocMeta docMeta) { + PsiModifierList modifierList = element.getModifierList(); + if (modifierList != null && modifierList.hasModifierProperty("private")) { + ctx.print("private "); + } else { + ctx.print("public "); + } + if (modifierList != null && modifierList.hasModifierProperty("static")) { + ctx.append("static "); + } + ctx.append(element.getName()).append(": "); + + if (element.hasInitializer() && (element.getInitializer() instanceof PsiLambdaExpression)) { + if (element.getType() instanceof PsiClassReferenceType) { + try { + MethodTranslator.translateToLambdaType(((PsiClassReferenceType) element.getType()).rawType().resolve().getMethods()[0], ctx, docMeta); + } catch (Exception e){ + ((PsiClassReferenceType) element.getType()).rawType() + .resolve(); + e.printStackTrace(); + } + } else { + System.err.println("FieldTranslator:: Type not instance of PsiClassReferenceType. Could not translate lambda expression. (" + element.getType().getClass().getName() + ")"); + } + + } else { + ctx.append(TypeHelper.printType(element.getType(), ctx)); + } + + if (element.hasInitializer()) { + ctx.append(" = "); + ExpressionTranslator.translate(element.getInitializer(), ctx); + ctx.append(";\n"); + } else { + ctx.append(";\n"); + } + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/JavaTokenTranslator.java b/transpiler/src/main/java/java2typescript/translators/JavaTokenTranslator.java new file mode 100755 index 0000000..009d72f --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/JavaTokenTranslator.java @@ -0,0 +1,30 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators; + +import com.intellij.psi.PsiJavaToken; +import com.intellij.psi.impl.source.tree.ElementType; +import java2typescript.context.TranslationContext; + +public class JavaTokenTranslator { + + public static void translate(PsiJavaToken element, TranslationContext ctx) { + if (ElementType.OPERATION_BIT_SET.contains(element.getTokenType())) { + ctx.append(element.getText()); + } + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/MethodTranslator.java b/transpiler/src/main/java/java2typescript/translators/MethodTranslator.java new file mode 100755 index 0000000..ff70f2e --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/MethodTranslator.java @@ -0,0 +1,171 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators; + +import com.intellij.psi.*; +import com.intellij.psi.impl.source.PsiClassReferenceType; +import java2typescript.context.TranslationContext; +import java2typescript.helper.DocHelper; +import java2typescript.helper.KeywordHelper; +import java2typescript.helper.TypeHelper; +import java2typescript.metas.DocMeta; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +/** + * Created by duke on 11/6/14. + */ +public class MethodTranslator { + + public static void translate(PsiMethod method, TranslationContext ctx, boolean isAnonymous) { + DocMeta docMeta = DocHelper.process(method.getDocComment()); + + if (docMeta.ignored) { + return; + } + + PsiModifierList modifierList = method.getModifierList(); + PsiClass containingClass = (PsiClass) method.getParent(); + ArrayList paramGenParamTypeName = new ArrayList<>(); + ctx.setGenericParameterNames(paramGenParamTypeName); + if (method.isConstructor()) { + ctx.print("constructor"); + } else { + if (method.getContainingClass() != null && method.getContainingClass().isInterface()) { + ctx.print(""); + } else { + if (modifierList.hasModifierProperty("private")) { + ctx.print("private "); + } else { + ctx.print("public "); + } + } + if (modifierList.hasModifierProperty("static")) { + ctx.append("static "); + } + if (!containingClass.isInterface() && modifierList.hasModifierProperty(PsiModifier.ABSTRACT)) { + ctx.append("abstract "); + } + if (!isAnonymous) { + ctx.append(KeywordHelper.process(method.getName(), ctx)); + } + HashSet usedGenerics = new HashSet<>(); + PsiTypeParameter[] parameters = method.getTypeParameters(); + for (PsiTypeParameter parameter : parameters) { + usedGenerics.add(parameter.getName()); + } + String genericParams = TypeParametersTranslator.print(method.getTypeParameters(), ctx); + if (!genericParams.isEmpty()) { + genericParams = "<" + genericParams; + } + for (int i = 0; i < method.getParameterList().getParameters().length; i++) { + PsiParameter param = method.getParameterList().getParameters()[i]; + if (param.getType() instanceof PsiClassReferenceType) { + PsiClassReferenceType paramClassRef = (PsiClassReferenceType) param.getType(); + if (paramClassRef.getParameters().length > 0) { + // param has generic params + for (PsiType paramGenParamType : paramClassRef.getParameters()) { + if (paramGenParamType instanceof PsiWildcardType) { + if (((PsiWildcardType) paramGenParamType).getBound() != null) { + if (!genericParams.isEmpty()) { + genericParams += ", "; + } else { + genericParams = "<"; + } + String genType = TypeHelper.availableGenericType(usedGenerics); + usedGenerics.add(genType); + paramGenParamTypeName.add(i, genType); + genericParams += genType + + " extends " + + TypeHelper.printType(((PsiWildcardType) paramGenParamType).getBound(), ctx); + break; + } + } + } + } + } + } + if (!genericParams.isEmpty()) { + genericParams += ">"; + } + ctx.append(genericParams); + } + translateMethodParametersDeclaration(method, ctx, docMeta); + if (!method.isConstructor()) { + ctx.append(": "); + ctx.append(TypeHelper.printType(method.getReturnType(), ctx)); + } + if(containingClass.isInterface() || method.getModifierList().hasModifierProperty("abstract")){ + ctx.append(";\n"); + } else { + ctx.append(" "); + if (method.getBody() == null) { + ctx.append("{\n"); + ctx.increaseIdent(); + ctx.print("throw \"Empty body\";\n"); + ctx.decreaseIdent(); + ctx.print("}\n"); + } else { + if (method.getBody().getStatements().length > 0) { + if (!docMeta.nativeActivated) { + + CodeBlockTranslator.translate(method.getBody(), ctx); + ctx.append("\n"); + } else { + ctx.append("{\n"); + ctx.increaseIdent(); + DocTagTranslator.translate(docMeta, ctx); + ctx.decreaseIdent(); + ctx.print("}\n"); + } + } else { + ctx.append("{}\n"); + } + } + } + ctx.removeGenericParameterNames(); + } + + public static void translateToLambdaType(PsiMethod method, TranslationContext ctx, DocMeta docMeta) { + translateMethodParametersDeclaration(method, ctx, docMeta); + ctx.append("=>"); + ctx.append(TypeHelper.printType(method.getReturnType(), ctx)); + } + + private static void translateMethodParametersDeclaration(PsiMethod method, TranslationContext ctx, DocMeta docMeta) { + ctx.append('('); + List params = new ArrayList<>(); + StringBuilder paramSB = new StringBuilder(); + for (PsiParameter parameter : method.getParameterList().getParameters()) { + paramSB.setLength(0); + if (parameter.isVarArgs()) { + paramSB.append("..."); + } + paramSB.append(KeywordHelper.process(parameter.getName(), ctx)); + if (docMeta != null && docMeta.optional.contains(parameter.getName())) { + paramSB.append("?"); + } + paramSB.append(": "); + + paramSB.append(TypeHelper.printType(parameter.getType(), ctx, true, false)); + params.add(paramSB.toString()); + } + ctx.append(String.join(", ", params)); + ctx.append(')'); + } +} diff --git a/transpiler/src/main/java/java2typescript/translators/TypeParametersTranslator.java b/transpiler/src/main/java/java2typescript/translators/TypeParametersTranslator.java new file mode 100755 index 0000000..7f1dcf7 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/TypeParametersTranslator.java @@ -0,0 +1,47 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators; + +import com.intellij.psi.PsiClassType; +import com.intellij.psi.PsiTypeParameter; +import java2typescript.context.TranslationContext; +import java2typescript.helper.TypeHelper; + +/** + * + * Created by leiko on 23/11/15. + */ +public class TypeParametersTranslator { + + public static String print(PsiTypeParameter[] parameters, TranslationContext ctx) { + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < parameters.length; i++) { + PsiTypeParameter p = parameters[i]; + builder.append(p.getName()); + PsiClassType[] extensions = p.getExtendsList().getReferencedTypes(); + if (extensions.length > 0) { + builder.append(" extends "); + for (PsiClassType ext : extensions) { + builder.append(TypeHelper.printType(ext, ctx)); + } + } + if (i != parameters.length - 1) { + builder.append(", "); + } + } + return builder.toString(); + } +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/ArrayAccessExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/ArrayAccessExpressionTranslator.java new file mode 100755 index 0000000..649f192 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/ArrayAccessExpressionTranslator.java @@ -0,0 +1,30 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiArrayAccessExpression; +import java2typescript.context.TranslationContext; + +public class ArrayAccessExpressionTranslator { + + public static void translate(PsiArrayAccessExpression element, TranslationContext ctx) { + ExpressionTranslator.translate(element.getArrayExpression(), ctx); + ctx.append('['); + ExpressionTranslator.translate(element.getIndexExpression(), ctx); + ctx.append(']'); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/ArrayInitializerExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/ArrayInitializerExpressionTranslator.java new file mode 100755 index 0000000..b966017 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/ArrayInitializerExpressionTranslator.java @@ -0,0 +1,65 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiArrayInitializerExpression; +import com.intellij.psi.PsiExpression; +import java2typescript.context.TranslationContext; + +public class ArrayInitializerExpressionTranslator { + + public static void translate(PsiArrayInitializerExpression element, TranslationContext ctx) { + boolean hasToBeClosed, isByteArray = false; + if (ctx.NATIVE_ARRAY && element.getType() != null && element.getType().equalsToText("int[]")) { + ctx.append("new Int32Array(["); + hasToBeClosed = true; + } else if (ctx.NATIVE_ARRAY && element.getType() != null && element.getType().equalsToText("double[]")) { + ctx.append("new Float64Array(["); + hasToBeClosed = true; + } else if (ctx.NATIVE_ARRAY && element.getType() != null && element.getType().equalsToText("long[]")) { + ctx.append("new Float64Array(["); + hasToBeClosed = true; + } else if (ctx.NATIVE_ARRAY && element.getType() != null && element.getType().equalsToText("byte[]")) { + ctx.append("new Int8Array(["); + hasToBeClosed = true; + } else { + ctx.append("["); + hasToBeClosed = false; + } + PsiExpression[] initializers = element.getInitializers(); + if (element.getType() != null && + element.getType().getPresentableText().equals("byte[]")) { + isByteArray = true; + } + if (initializers.length > 0) { + for (int i = 0; i < initializers.length; i++) { + ExpressionTranslator.translate(initializers[i], ctx); + if (isByteArray && + initializers[i].getType() != null && + initializers[i].getType().getPresentableText().equals("char")) { + ctx.append(".charCodeAt(0)"); + } + if (i != initializers.length - 1) { + ctx.append(", "); + } + } + } + ctx.append("]"); + if (hasToBeClosed) { + ctx.append(")"); + } + } +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/AssignmentExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/AssignmentExpressionTranslator.java new file mode 100755 index 0000000..50607ff --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/AssignmentExpressionTranslator.java @@ -0,0 +1,42 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiAssignmentExpression; +import java2typescript.context.TranslationContext; +import java2typescript.translators.JavaTokenTranslator; + +public class AssignmentExpressionTranslator { + + public static void translate(PsiAssignmentExpression element, TranslationContext ctx) { + ExpressionTranslator.translate(element.getLExpression(), ctx); + ctx.append(' '); + JavaTokenTranslator.translate(element.getOperationSign(), ctx); + ctx.append(' '); + ExpressionTranslator.translate(element.getRExpression(), ctx); + + /* + if (element.getLExpression().getType() != null && + element.getRExpression() != null && + element.getRExpression().getType() != null && + element.getLExpression().getType().getPresentableText().equals("byte") && + element.getRExpression().getType().getPresentableText().equals("char")) { + ctx.append(".charCodeAt(0)"); + } + */ + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/BinaryExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/BinaryExpressionTranslator.java new file mode 100755 index 0000000..280d467 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/BinaryExpressionTranslator.java @@ -0,0 +1,32 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiBinaryExpression; +import java2typescript.context.TranslationContext; +import java2typescript.translators.JavaTokenTranslator; + +public class BinaryExpressionTranslator { + + public static void translate(PsiBinaryExpression element, TranslationContext ctx) { + ExpressionTranslator.translate(element.getLOperand(), ctx); + ctx.append(' '); + JavaTokenTranslator.translate(element.getOperationSign(), ctx); + ctx.append(' '); + ExpressionTranslator.translate(element.getROperand(), ctx); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/ClassObjectAccessExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/ClassObjectAccessExpressionTranslator.java new file mode 100755 index 0000000..e2e862a --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/ClassObjectAccessExpressionTranslator.java @@ -0,0 +1,28 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiClassObjectAccessExpression; +import java2typescript.context.TranslationContext; +import java2typescript.helper.TypeHelper; + +public class ClassObjectAccessExpressionTranslator { + + public static void translate(PsiClassObjectAccessExpression element, TranslationContext ctx) { + ctx.append(TypeHelper.printType(element.getOperand().getType(), ctx)); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/ConditionalExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/ConditionalExpressionTranslator.java new file mode 100755 index 0000000..9b95431 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/ConditionalExpressionTranslator.java @@ -0,0 +1,31 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiConditionalExpression; +import java2typescript.context.TranslationContext; + +public class ConditionalExpressionTranslator { + + public static void translate(PsiConditionalExpression element, TranslationContext ctx) { + ExpressionTranslator.translate(element.getCondition(), ctx); + ctx.append(" ? "); + ExpressionTranslator.translate(element.getThenExpression(), ctx); + ctx.append(" : "); + ExpressionTranslator.translate(element.getElseExpression(), ctx); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/ExpressionListTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/ExpressionListTranslator.java new file mode 100755 index 0000000..6f494f9 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/ExpressionListTranslator.java @@ -0,0 +1,37 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiExpression; +import com.intellij.psi.PsiExpressionList; +import java2typescript.context.TranslationContext; + +/** + * + * Created by leiko on 23/11/15. + */ +public class ExpressionListTranslator { + + public static void translate(PsiExpressionList element, TranslationContext ctx) { + PsiExpression[] arguments = element.getExpressions(); + for (int i = 0; i < arguments.length; i++) { + ExpressionTranslator.translate(arguments[i], ctx); + if (i != arguments.length - 1) { + ctx.append(", "); + } + } + } +} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/ExpressionTranslator.java old mode 100644 new mode 100755 similarity index 78% rename from org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ExpressionTranslator.java rename to transpiler/src/main/java/java2typescript/translators/expression/ExpressionTranslator.java index 947bf64..40c6f6b --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/expression/ExpressionTranslator.java +++ b/transpiler/src/main/java/java2typescript/translators/expression/ExpressionTranslator.java @@ -1,7 +1,22 @@ -package org.kevoree.modeling.java2typescript.translators.expression; +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; import com.intellij.psi.*; -import org.kevoree.modeling.java2typescript.TranslationContext; +import java2typescript.context.TranslationContext; /** * Created by duke on 11/6/14. @@ -45,6 +60,8 @@ public static void translate(PsiExpression expression, TranslationContext ctx) { SuperExpressionTranslator.translate((PsiSuperExpression) expression, ctx); } else if (expression instanceof PsiClassObjectAccessExpression) { ClassObjectAccessExpressionTranslator.translate((PsiClassObjectAccessExpression) expression, ctx); + } else if (expression instanceof PsiLambdaExpression) { + LambdaExpressionTranslator.translate((PsiLambdaExpression) expression, ctx); } else { System.err.println("EXPR " + expression); } diff --git a/transpiler/src/main/java/java2typescript/translators/expression/InstanceOfExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/InstanceOfExpressionTranslator.java new file mode 100755 index 0000000..f380d3f --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/InstanceOfExpressionTranslator.java @@ -0,0 +1,59 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiInstanceOfExpression; +import java2typescript.context.TranslationContext; +import java2typescript.helper.TypeHelper; + +public class InstanceOfExpressionTranslator { + + public static void translate(PsiInstanceOfExpression element, TranslationContext ctx) { + + String rightHandType = TypeHelper.printType(element.getCheckType().getType(), ctx, false, false); + + if (!isNativeArray(rightHandType) && element.getCheckType().getType().getArrayDimensions() == 1) { + if (element.getCheckType().getText().equals("Object[]")) { + ctx.append("Array.isArray("); + ExpressionTranslator.translate(element.getOperand(), ctx); + ctx.append(")"); + } else { + ctx.append("arrayInstanceOf("); + ExpressionTranslator.translate(element.getOperand(), ctx); + ctx.append(", "); + ctx.append(rightHandType); + ctx.append(")"); + } + } else if(rightHandType.equals("string")) { + ctx.append("typeof("); + ExpressionTranslator.translate(element.getOperand(), ctx); + ctx.append(") === \"string\""); + } else { + ExpressionTranslator.translate(element.getOperand(), ctx); + ctx.append(" instanceof "); + if(rightHandType.equals("number") || rightHandType.equals("boolean")) { + ctx.append(rightHandType.substring(0, 1).toUpperCase()).append(rightHandType.substring(1)); + } else { + ctx.append(rightHandType); + } + } + } + + private static boolean isNativeArray(String type) { + return type.equals("Float64Array") || type.equals("Int32Array"); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/LambdaExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/LambdaExpressionTranslator.java new file mode 100755 index 0000000..7c50757 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/LambdaExpressionTranslator.java @@ -0,0 +1,71 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.*; +import java2typescript.context.TranslationContext; +import java2typescript.helper.KeywordHelper; +import java2typescript.helper.TypeHelper; +import java2typescript.translators.CodeBlockTranslator; + +public class LambdaExpressionTranslator { + + public static void translate(PsiLambdaExpression element, TranslationContext ctx) { + boolean asFunctionParameter = false; + PsiElement parent = element.getParent(); + while (parent != null && !(parent instanceof PsiExpressionList)) { + parent = parent.getParent(); + } + if (parent != null && parent.getParent() != null && parent.getParent() instanceof PsiMethodCallExpression) { + if (!TypeHelper.isCallbackClass(((PsiClassType.Stub) element.getFunctionalInterfaceType()).rawType().resolve())) { + asFunctionParameter = true; + } + } + if (asFunctionParameter) { + ctx.append("(() => {let r:any=()=>{};r."); + ctx.append(((PsiClassType.Stub) element.getFunctionalInterfaceType()).rawType().resolve().getMethods()[0].getName()); + ctx.append("="); + } + ctx.append("("); + PsiParameter[] paramList = element.getParameterList().getParameters(); + for (int i = 0; i < paramList.length; i++) { + PsiParameter param = paramList[i]; + ctx.append(KeywordHelper.process(param.getName(), ctx)); + if (i < paramList.length - 1) { + ctx.append(", "); + } + } + ctx.append(")=>"); + PsiElement body = element.getBody(); + if (body instanceof PsiCodeBlock) { + //ctx.append("{\n"); + //ctx.increaseIdent(); + CodeBlockTranslator.translate((PsiCodeBlock) body, ctx); + //ctx.decreaseIdent(); + //ctx.print("}"); + } else { + ctx.append("("); + ExpressionTranslator.translate((PsiExpression) body, ctx); + ctx.append(")"); + //System.err.println("LambdaExpressionTranslator:: Unsupported body type:" + body.getClass().getName()); + } + if (asFunctionParameter) { + ctx.append(";return r;})()"); + } + + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/LiteralTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/LiteralTranslator.java new file mode 100755 index 0000000..ce55f03 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/LiteralTranslator.java @@ -0,0 +1,48 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiLiteralExpression; +import java2typescript.context.TranslationContext; + +public class LiteralTranslator { + + public static void translate(PsiLiteralExpression element, TranslationContext ctx) { + String value = element.getText().trim(); + + if (value.toLowerCase().equals("null")) { + ctx.append(value); + return; + } + + if (value.toLowerCase().endsWith("l")) { + ctx.append(value.substring(0, value.length() - 1)); + return; + } + + if (value.toLowerCase().endsWith("f") || value.toLowerCase().endsWith("d")) { + if (value.contains("0x")) { + ctx.append(value); + } else { + ctx.append(value.substring(0, value.length() - 1)); + } + return; + } + ctx.append(value); + + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/MethodCallExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/MethodCallExpressionTranslator.java new file mode 100755 index 0000000..854bffb --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/MethodCallExpressionTranslator.java @@ -0,0 +1,338 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.*; +import java2typescript.context.TranslationContext; +import java2typescript.helper.TypeHelper; + +public class MethodCallExpressionTranslator { + + public static void translate(PsiMethodCallExpression element, TranslationContext ctx) { + PsiReferenceExpression methodExpr = element.getMethodExpression(); + PsiExpression methodQualifierExpression = methodExpr.getQualifierExpression(); + + if (methodQualifierExpression != null) { + if (methodQualifierExpression.getType() != null) { + if (methodQualifierExpression.getType() instanceof PsiClassType) { + PsiClass cls = ((PsiClassType) methodQualifierExpression.getType()).resolve(); + if (cls == null) { + PsiClassType rawType = ((PsiClassType) methodQualifierExpression.getType()).rawType(); + if (rawType != null) { + cls = rawType.resolve(); + } + } + if (cls != null) { + if (TypeHelper.isCallbackClass(cls)) { + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append('('); + printCallParameters(element.getArgumentList().getExpressions(), ctx); + ctx.append(")"); + return; + } + } else { + + } + } + } + } + + boolean hasBeenTransformed = tryNativeTransform(element, ctx); + if (!hasBeenTransformed) { + if ((methodExpr.getQualifier() == null) + && (element.getParent() instanceof PsiField) + && (methodExpr.resolve().getParent() == ((PsiField) element.getParent()).getParent())) { + ctx.append(((PsiClass) methodExpr.getReference().resolve().getParent()).getName()); + ctx.append('.'); + ctx.append(methodExpr.getReferenceName()); + } else { + ReferenceExpressionTranslator.translate(methodExpr, ctx); + } + ctx.append('('); + printCallParameters(element.getArgumentList().getExpressions(), ctx); + ctx.append(")"); + } + } + + public static void printCallParameters(PsiExpression[] arguments, TranslationContext ctx) { + for (int i = 0; i < arguments.length; i++) { + if (arguments[i] instanceof PsiMethodCallExpression) { + if (arguments[i].getType() != null && arguments[i].getType().getArrayDimensions() > 0) { + checkVarArgs(arguments, i, ctx); + } + ExpressionTranslator.translate(arguments[i], ctx); + } else if (arguments[i] instanceof PsiReferenceExpression) { + PsiReference ref = arguments[i].getReference(); + if (ref != null) { + PsiElement resolved = ref.resolve(); + if (resolved != null) { + if (resolved instanceof PsiParameter) { + if ((((PsiParameter) resolved).isVarArgs())) { + ctx.append("..."); + } + } else if (resolved instanceof PsiVariable) { + boolean isArray = ((PsiVariable) resolved).getType().getArrayDimensions() > 0; + if (isArray) { + checkVarArgs(arguments, i, ctx); + } + } + } + } + ReferenceExpressionTranslator.translate((PsiReferenceExpression) arguments[i], ctx); + } else { + ExpressionTranslator.translate(arguments[i], ctx); + } + if (i != arguments.length - 1) { + ctx.append(", "); + } + } + } + + private static void checkVarArgs(PsiExpression[] arguments, int index, TranslationContext ctx) { + PsiElement parentExp = arguments[index].getParent(); + if (parentExp != null) { + PsiElement grandParentExp = parentExp.getParent(); + if (grandParentExp != null) { + if (grandParentExp instanceof PsiNewExpression) { + PsiElement resolvedClass = ((PsiNewExpression) grandParentExp).getClassOrAnonymousClassReference().resolve(); + if (resolvedClass instanceof PsiClass) { + for (PsiMethod m : ((PsiClass) resolvedClass).getConstructors()) { + PsiParameter[] parameters = m.getParameterList().getParameters(); + if (parameters.length == arguments.length) { + if (parameters[index].isVarArgs()) { + ctx.append("..."); + break; + } + } + } + } + } else if (grandParentExp instanceof PsiMethodCallExpression) { + PsiElement method = ((PsiMethodCallExpression) grandParentExp).getMethodExpression().resolve(); + if (method != null && method instanceof PsiMethod) { + PsiParameter[] parameters = ((PsiMethod) method).getParameterList().getParameters(); + if (parameters.length == arguments.length) { + if (parameters[index].isVarArgs()) { + ctx.append("..."); + } + } + } + } + } + } + } + + private static boolean tryNativeTransform(PsiMethodCallExpression element, TranslationContext ctx) { + + // a.b.c.method() + PsiReferenceExpression methodExpression = element.getMethodExpression(); + // a.b.c + PsiExpression methodQualifierExpression = methodExpression.getQualifierExpression(); + + if (methodQualifierExpression != null) { + if (methodQualifierExpression.getType() != null) { + if (methodQualifierExpression.getType().getCanonicalText().contains("String")) { + if (methodExpression.getReferenceName() != null) { + + if (methodExpression.getReferenceName().equals("length")) { + ExpressionTranslator.translate(methodQualifierExpression, ctx); + if (element.getArgumentList().getExpressions().length == 0) { + ctx.append(".length"); + return true; + } + + + } else if (methodExpression.getReferenceName().equals("codePointAt")) { + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(".charCodeAt("); + PsiExpression[] arguments = element.getArgumentList().getExpressions(); + for (int i = 0; i < arguments.length; i++) { + ExpressionTranslator.translate(arguments[i], ctx); + if (i != arguments.length - 1) { + ctx.append(", "); + } + } + ctx.append(")"); + ctx.needsJava(TypeHelper.javaTypes.get("String")); + return true; + + + } else if (methodExpression.getReferenceName().equals("concat")) { + + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(" + "); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + return true; + } else if (methodExpression.getReferenceName().equals("equals")) { + + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(" === "); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + return true; + } else if (methodExpression.getReferenceName().equals("getBytes")) { + + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(".split('').map(function(e){return e.charCodeAt(0);})"); + return true; + } else if (methodExpression.getReferenceName().equals("startsWith")) { + ctx.append("("); + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(".lastIndexOf("); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + ctx.append(", 0) === 0)"); + return true; + } + } + + + } else if (methodQualifierExpression.getType().getCanonicalText().equals("Exception") + || methodQualifierExpression.getType().getCanonicalText().equals("Error") + || methodQualifierExpression.getType().getCanonicalText().equals("Throwable")) { + //error .printStackTrace + if (methodExpression.getReferenceName() != null && + methodExpression.getReferenceName().equals("printStackTrace")) { + ctx.append("console.error("); + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(")"); + return true; + } else if (methodExpression.getReferenceName() != null && + methodExpression.getReferenceName().equals("getMessage")) { + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(".message"); + return true; + } + } else if (methodQualifierExpression.getType().getCanonicalText().equals("PrintStream")) { + //error .printStackTrace + if (methodExpression.getReferenceName() != null && + methodExpression.getReferenceName().equals("println")) { + ctx.append("console.log("); + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(")"); + return true; + } + } else if (methodQualifierExpression.getType().getCanonicalText().equals("Pattern")) { + if (methodExpression.getReferenceName() != null && + methodExpression.getReferenceName().equals("matcher")) { + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(".test("); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + ctx.append(")"); + return true; + } + } else if (methodQualifierExpression.getType().getCanonicalText().equalsIgnoreCase("Double")) { + if (methodExpression.getReferenceName() != null && + methodExpression.getReferenceName().equals("longValue")) { + ctx.append("("); + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(" < 0 ? Math.ceil("); + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(") : Math.floor("); + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append(")"); + ctx.append(")"); + return true; + } + } + } else if (methodQualifierExpression instanceof PsiReferenceExpression) { + PsiReferenceExpression objectRef = (PsiReferenceExpression) methodQualifierExpression; + if (objectRef.getQualifier() != null) { + if (element.getArgumentList().getExpressions().length > 0) { + if (objectRef.getQualifier().getText().equals("System")) { + if (objectRef.getReferenceName().equals("out")) { + ctx.append("console.log("); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + ctx.append(")"); + return true; + } else if (objectRef.getReferenceName().equals("err")) { + ctx.append("console.error("); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + ctx.append(")"); + return true; + } + } + } + } else { + if (objectRef.getText().equals("Pattern")) { + if (methodExpression.getReferenceName().equals("compile")) { + ctx.append("new RegExp("); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + ctx.append(")"); + return true; + } + } else if (objectRef.getText().equals("System")) { + if (methodExpression.getReferenceName().equals("currentTimeMillis")) { + ctx.append("Date.now()"); + return true; + } + } else if (objectRef.getText().equals("Arrays")) { + if (methodExpression.getReferenceName().equals("sort")) { + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + ctx.append(".sort()"); + return true; + } + } else if (objectRef.getText().equals("Double")) { + if (methodExpression.getReferenceName().equals("parseDouble")) { + ctx.append("parseFloat("); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + ctx.append(")"); + return true; + } + } else if (objectRef.getText().equals("Assert")) { + if (methodExpression.getReferenceName().equals("assertEquals") || methodExpression.getReferenceName().equals("assertNotEquals")) { + if (element.getArgumentList().getExpressions().length == 3) { + ExpressionTranslator.translate(methodQualifierExpression, ctx); + ctx.append("." + methodExpression.getReferenceName() + "("); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[1], ctx); + ctx.append(","); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[2], ctx); + ctx.append(","); + ExpressionTranslator.translate(element.getArgumentList().getExpressions()[0], ctx); + ctx.append(")"); + return true; + } + } + } + } + } else if (methodQualifierExpression instanceof PsiMethodCallExpression) { // remove the [] part in regEx.matcher(expr)[.matches()] + PsiMethodCallExpression previousMethodCall = (PsiMethodCallExpression) methodQualifierExpression; + + if (previousMethodCall.getMethodExpression().getReferenceName().equals("toString")) { + if (methodExpression.getReferenceName().equals("length")) { + ExpressionTranslator.translate(previousMethodCall, ctx); + ctx.append(".length"); + return true; + } + } + + PsiElement previousMethodQualifier = previousMethodCall.getMethodExpression().getQualifier(); + if (previousMethodQualifier instanceof PsiReferenceExpression) { + PsiReferenceExpression previousMethodReference = (PsiReferenceExpression) previousMethodQualifier; + String previoudMethodName = previousMethodCall.getMethodExpression().getReferenceName(); + if (previousMethodReference.getType() != null && previousMethodReference.getType().getCanonicalText().equals("Pattern")) { + if (previoudMethodName.equals("matcher")) { + ExpressionTranslator.translate(previousMethodCall, ctx); + return true; + } + } else if (previousMethodReference.getType() != null && previousMethodReference.getType().getCanonicalText().equals("String")) { + + } + } + } + } + + return false; + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/NewExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/NewExpressionTranslator.java new file mode 100755 index 0000000..929e099 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/NewExpressionTranslator.java @@ -0,0 +1,176 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.*; +import java2typescript.helper.GenericHelper; +import java2typescript.context.TranslationContext; +import java2typescript.helper.TypeHelper; +import java2typescript.translators.AnonymousClassTranslator; + +import static java2typescript.translators.expression.MethodCallExpressionTranslator.printCallParameters; + +public class NewExpressionTranslator { + + public static void translate(PsiNewExpression element, TranslationContext ctx) { + + PsiAnonymousClass anonymousClass = element.getAnonymousClass(); + if (anonymousClass != null) { + AnonymousClassTranslator.translate(anonymousClass, ctx); + } else { + boolean arrayDefinition = false; + PsiJavaCodeReferenceElement classReference = element.getClassReference(); + String className; + if (classReference != null) { + className = TypeHelper.printType(element.getType(), ctx); + } else { + className = TypeHelper.printType(element.getType().getDeepComponentType(), ctx); + arrayDefinition = true; + } + PsiExpression[] arrayDimensions = element.getArrayDimensions(); + PsiArrayInitializerExpression arrayInitializer = element.getArrayInitializer(); + if (arrayDimensions.length > 0) { + arrayDefinition = true; + } + if (arrayInitializer != null) { + arrayDefinition = true; + } + if (!arrayDefinition) { + if (className.equals("string")) { + if (element.getArgumentList() != null) { + ExpressionListTranslator.translate(element.getArgumentList(), ctx); + } + } else { + ctx.append("new ").append(className).append('('); + if (element.getArgumentList() != null) { + printCallParameters(element.getArgumentList().getExpressions(), ctx); + //ExpressionListTranslator.translate(element.getArgumentList(), ctx); + } + ctx.append(')'); + } + } else { + if (arrayInitializer != null) { + ArrayInitializerExpressionTranslator.translate(arrayInitializer, ctx); + } else { + String arrayBaseType = TypeHelper.printArrayBaseType(element.getType()); + + int dimensionCount = element.getType().getArrayDimensions(); + if (arrayBaseType != null) { + ctx.append("new "); + for (int i = 1; i < dimensionCount; i++) { + ctx.append("Array<"); + } + ctx.append(arrayBaseType); + for (int i = 1; i < dimensionCount; i++) { + ctx.append(">"); + } + ctx.append("("); + ExpressionTranslator.translate(element.getArrayDimensions()[0], ctx); + ctx.append(")"); + generateInitializer(ctx, element); + } else if (element.getClassOrAnonymousClassReference() != null) { + ctx.append("new Array<"); + PsiJavaCodeReferenceElement ref = element.getClassOrAnonymousClassReference(); + if (ref.getReference() != null && ref.getReference().resolve() != null) { + PsiClass refClass = (PsiClass) ref.getReference().resolve(); + ctx.append(GenericHelper.process(refClass)); + } else { + ctx.append(TypeHelper.printType(((PsiArrayType) element.getType()).getComponentType(), ctx, false, false)); + } + ctx.append(">("); + ExpressionTranslator.translate(element.getArrayDimensions()[0], ctx); + ctx.append(")"); + } else { + for (int i = 0; i < dimensionCount; i++) { + ctx.append("[]"); + } + } + + } + } + } + } + + private static void generateInitializer(TranslationContext ctx, PsiNewExpression element) { + int dimensionCount = element.getArrayDimensions().length; + PsiElement parentElement = element.getParent(); + if (dimensionCount > 1 && (parentElement instanceof PsiLocalVariable || parentElement instanceof PsiAssignmentExpression)) { + ctx.append(";\n"); + String arrayBaseType = TypeHelper.printArrayBaseType(element.getType()); + String fieldName = ""; + String prefix = ""; + if (parentElement instanceof PsiLocalVariable) { + fieldName = ((PsiLocalVariable) parentElement).getNameIdentifier().getText(); + } else if (parentElement instanceof PsiAssignmentExpression) { + PsiExpression left = ((PsiAssignmentExpression) parentElement).getLExpression(); + if (left instanceof PsiReferenceExpression) { + PsiReferenceExpression leftExpr = (PsiReferenceExpression) left; + fieldName = leftExpr.getReferenceName(); + + PsiExpression qualifierExpression = leftExpr.getQualifierExpression(); + if (qualifierExpression != null) { + if (qualifierExpression instanceof PsiThisExpression) { + prefix = "this."; + } else if (qualifierExpression instanceof PsiReferenceExpression) { + prefix = ReferenceExpressionTranslator.translate((PsiReferenceExpression) qualifierExpression, ctx, false); + } else { + prefix = qualifierExpression.getText(); + } + } else{ + PsiElement resolvedReference = leftExpr.getReference().resolve(); + if(resolvedReference instanceof PsiField) { + prefix = "this."; + } + } + } else { + fieldName = ((PsiAssignmentExpression) parentElement).getLExpression().getText(); + } + } + + for (int dimension = 1; dimension < dimensionCount; dimension++) { + String varname = fieldName + "_d" + dimension; + ctx.print("for(let " + varname + " = 0; " + varname + " < " + element.getArrayDimensions()[dimension - 1].getText() + "; " + varname + "++){\n"); + ctx.increaseIdent(); + ctx.print(prefix + fieldName); + for (int i = 1; i <= dimension; i++) { + String prevVar = fieldName + "_d" + i; + ctx.append("[" + prevVar + "]"); + } + ctx.append(" = new "); + for (int i = 1; i < dimensionCount - dimension; i++) { + ctx.append("Array<"); + } + ctx.append(arrayBaseType); + for (int i = 1; i < dimensionCount - dimension; i++) { + ctx.append(">"); + } + ctx.append("("); + ExpressionTranslator.translate(element.getArrayDimensions()[dimension], ctx); + ctx.append(");\n"); + + } + + for (int dimension = 1; dimension < dimensionCount - 1; dimension++) { + ctx.decreaseIdent(); + ctx.print("}\n"); + } + ctx.decreaseIdent(); + ctx.print("}"); + } + } +} + + diff --git a/transpiler/src/main/java/java2typescript/translators/expression/ParenthesizedExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/ParenthesizedExpressionTranslator.java new file mode 100755 index 0000000..279f943 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/ParenthesizedExpressionTranslator.java @@ -0,0 +1,29 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiParenthesizedExpression; +import java2typescript.context.TranslationContext; + +public class ParenthesizedExpressionTranslator { + + public static void translate(PsiParenthesizedExpression element, TranslationContext ctx) { + ctx.append('('); + ExpressionTranslator.translate(element.getExpression(), ctx); + ctx.append(')'); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/PolyadicExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/PolyadicExpressionTranslator.java new file mode 100755 index 0000000..0e73842 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/PolyadicExpressionTranslator.java @@ -0,0 +1,37 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiExpression; +import com.intellij.psi.PsiJavaToken; +import com.intellij.psi.PsiPolyadicExpression; +import java2typescript.context.TranslationContext; +import java2typescript.translators.JavaTokenTranslator; + +public class PolyadicExpressionTranslator { + + public static void translate(PsiPolyadicExpression element, TranslationContext ctx) { + for (PsiExpression expression : element.getOperands()) { + PsiJavaToken token = element.getTokenBeforeOperand(expression); + if (token != null) { + ctx.append(' '); + JavaTokenTranslator.translate(token, ctx); + ctx.append(' '); + } + ExpressionTranslator.translate(expression, ctx); + } + } +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/PostfixExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/PostfixExpressionTranslator.java new file mode 100755 index 0000000..4ca2660 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/PostfixExpressionTranslator.java @@ -0,0 +1,32 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiPostfixExpression; +import java2typescript.context.TranslationContext; +import java2typescript.translators.JavaTokenTranslator; + +/** + * Created by duke on 11/6/14. + */ +public class PostfixExpressionTranslator { + + public static void translate(PsiPostfixExpression element, TranslationContext ctx) { + ExpressionTranslator.translate(element.getOperand(), ctx); + JavaTokenTranslator.translate(element.getOperationSign(), ctx); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/PrefixExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/PrefixExpressionTranslator.java new file mode 100755 index 0000000..38a09f2 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/PrefixExpressionTranslator.java @@ -0,0 +1,32 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiPrefixExpression; +import java2typescript.context.TranslationContext; +import java2typescript.translators.JavaTokenTranslator; + +/** + * Created by duke on 11/6/14. + */ +public class PrefixExpressionTranslator { + + public static void translate(PsiPrefixExpression element, TranslationContext ctx) { + JavaTokenTranslator.translate(element.getOperationSign(), ctx); + ExpressionTranslator.translate(element.getOperand(), ctx); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/ReferenceExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/ReferenceExpressionTranslator.java new file mode 100755 index 0000000..781296c --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/ReferenceExpressionTranslator.java @@ -0,0 +1,109 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.*; +import java2typescript.context.TranslationContext; +import java2typescript.helper.TypeHelper; + +public class ReferenceExpressionTranslator { + + public static String translate(PsiReferenceExpression element, TranslationContext ctx, boolean appendToCtx) { + String result = ""; + if (element.getReference() != null && element.getReference().resolve() instanceof PsiClass) { + PsiClass clazz = (PsiClass) element.getReference().resolve(); + if (clazz != null) { + result += clazz.getQualifiedName(); + if (appendToCtx) { + ctx.append(result); + } + return result; + } + } + + PsiElement resolution = element.resolve(); + if (element.getQualifierExpression() != null) { + if (element.getQualifierExpression() instanceof PsiReferenceExpression) { + + if(element.getQualifierExpression().getText().equals("org.junit")) { + result += "junit"; + } else { + result += translate((PsiReferenceExpression) element.getQualifierExpression(), ctx, false); + } + } else { + ExpressionTranslator.translate(element.getQualifierExpression(), ctx); + } + result += "."; + } else { + if (resolution != null) { + String qualifier = "this"; + if (resolution instanceof PsiField) { + PsiField field = (PsiField) resolution; + if (field.getModifierList() != null && field.getModifierList().hasModifierProperty("static")) { + PsiClass currentClassDef = null; + PsiElement parent = element; + while(parent != null) { + if(parent instanceof PsiClass) { + currentClassDef = (PsiClass) parent; + break; + } else { + parent = parent.getParent(); + } + } + boolean sameClass = false; + if(currentClassDef != null) { + sameClass = (currentClassDef == field.getContainingClass()); + } + if (sameClass) { + qualifier = field.getContainingClass().getName(); + } else { + qualifier = field.getContainingClass().getQualifiedName(); + } + } + result += qualifier + "."; + } else if (resolution instanceof PsiMethod) { + PsiMethod method = (PsiMethod) resolution; + if (method.getModifierList().hasModifierProperty("static")) { + qualifier = method.getContainingClass().getQualifiedName(); + } + if (!element.getReferenceName().equals("super")) { + result += qualifier + "."; + } + }/* else if (resolution instanceof PsiParameter) { + if((((PsiParameter) resolution).isVarArgs())) { + result += "..."; + } + }*/ + } + } + + String type = TypeHelper.primitiveStaticCall(element.getReferenceName(), ctx); + if (!result.isEmpty() && type.startsWith(result)) { + result = type; + } else { + result += type; + } + + if (appendToCtx) { + ctx.append(result); + } + return result; + } + + public static void translate(PsiReferenceExpression element, TranslationContext ctx) { + translate(element, ctx, true); + } +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/SuperExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/SuperExpressionTranslator.java new file mode 100755 index 0000000..d1ced05 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/SuperExpressionTranslator.java @@ -0,0 +1,27 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiSuperExpression; +import java2typescript.context.TranslationContext; + +public class SuperExpressionTranslator { + + public static void translate(PsiSuperExpression element, TranslationContext ctx) { + ctx.append("super"); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/ThisExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/ThisExpressionTranslator.java new file mode 100755 index 0000000..52c6d3a --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/ThisExpressionTranslator.java @@ -0,0 +1,27 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiThisExpression; +import java2typescript.context.TranslationContext; + +public class ThisExpressionTranslator { + + public static void translate(PsiThisExpression element, TranslationContext ctx) { + ctx.append("this"); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/expression/TypeCastExpressionTranslator.java b/transpiler/src/main/java/java2typescript/translators/expression/TypeCastExpressionTranslator.java new file mode 100755 index 0000000..b0e2d40 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/expression/TypeCastExpressionTranslator.java @@ -0,0 +1,29 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.expression; + +import com.intellij.psi.PsiTypeCastExpression; +import java2typescript.context.TranslationContext; +import java2typescript.helper.TypeHelper; + +public class TypeCastExpressionTranslator { + + public static void translate(PsiTypeCastExpression element, TranslationContext ctx) { + ctx.append('<').append(TypeHelper.printType(element.getType(), ctx, true, false)).append('>'); + ExpressionTranslator.translate(element.getOperand(), ctx); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/BreakStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/BreakStatementTranslator.java new file mode 100755 index 0000000..07966a4 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/BreakStatementTranslator.java @@ -0,0 +1,32 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiBreakStatement; +import java2typescript.context.TranslationContext; + +public class BreakStatementTranslator { + + public static void translate(PsiBreakStatement element, TranslationContext ctx) { + ctx.append("break"); + if (element.getLabelIdentifier() != null) { + ctx.append(' '); + ctx.append(element.getLabelIdentifier().getText().trim()); + } + ctx.append(";\n"); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/ContinueStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/ContinueStatementTranslator.java new file mode 100755 index 0000000..029defd --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/ContinueStatementTranslator.java @@ -0,0 +1,32 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiContinueStatement; +import java2typescript.context.TranslationContext; + +public class ContinueStatementTranslator { + + public static void translate(PsiContinueStatement element, TranslationContext ctx) { + ctx.print("continue"); + if (element.getLabelIdentifier() != null) { + ctx.append(' '); + ctx.append(element.getLabelIdentifier().getText().trim()); + } + ctx.append(";\n"); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/DeclarationStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/DeclarationStatementTranslator.java new file mode 100755 index 0000000..8987645 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/DeclarationStatementTranslator.java @@ -0,0 +1,44 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiDeclarationStatement; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiLocalVariable; +import com.intellij.psi.PsiStatement; +import java2typescript.context.TranslationContext; + +public class DeclarationStatementTranslator { + + public static void translate(PsiDeclarationStatement stmt, TranslationContext ctx) { + for (int i = 0; i < stmt.getDeclaredElements().length; i++) { + + if(i > 0) { + ctx.append(", "); + } + + PsiElement element1 = stmt.getDeclaredElements()[i]; + if (element1 instanceof PsiStatement) { + StatementTranslator.translate((PsiStatement) element1, ctx); + } else if (element1 instanceof PsiLocalVariable) { + LocalVariableTranslator.translate((PsiLocalVariable) element1, ctx); + } else { + System.err.println("Not managed " + element1); + } + } + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/DoWhileStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/DoWhileStatementTranslator.java new file mode 100755 index 0000000..6d77243 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/DoWhileStatementTranslator.java @@ -0,0 +1,31 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiDoWhileStatement; +import java2typescript.context.TranslationContext; +import java2typescript.translators.expression.ExpressionTranslator; + +public class DoWhileStatementTranslator { + + public static void translate(PsiDoWhileStatement element, TranslationContext ctx) { + ctx.print("do "); + StatementTranslator.translate(element.getBody(), ctx); + ctx.append(" while ("); + ExpressionTranslator.translate(element.getCondition(),ctx); + ctx.append(");\n"); + } +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/ExpressionListStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/ExpressionListStatementTranslator.java new file mode 100755 index 0000000..a73e33d --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/ExpressionListStatementTranslator.java @@ -0,0 +1,38 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.*; +import java2typescript.context.TranslationContext; +import java2typescript.translators.expression.ExpressionTranslator; + +public class ExpressionListStatementTranslator { + + public static void translate(PsiExpressionListStatement element, TranslationContext ctx) { + + PsiExpression[] expressions = element.getExpressionList().getExpressions(); + + for (int i = 0; i < expressions.length; i++) { + if (i > 0) { + ctx.append(", "); + } + ExpressionTranslator.translate(expressions[i], ctx); + } + + + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/ExpressionStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/ExpressionStatementTranslator.java new file mode 100755 index 0000000..ac906c3 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/ExpressionStatementTranslator.java @@ -0,0 +1,40 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.*; +import java2typescript.context.TranslationContext; +import java2typescript.translators.expression.ExpressionTranslator; + +public class ExpressionStatementTranslator { + + public static void translate(PsiExpressionStatement element, TranslationContext ctx) { + + boolean loopDeclaration = false; + PsiElement parent = element.getParent(); + if (parent instanceof PsiLoopStatement && !((PsiLoopStatement)parent).getBody().equals(element)) { + loopDeclaration = true; + } + if (!loopDeclaration) { + ctx.print(""); + } + ExpressionTranslator.translate(element.getExpression(),ctx); + if (!loopDeclaration) { + ctx.append(";\n"); + } + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/ForEachStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/ForEachStatementTranslator.java new file mode 100755 index 0000000..83578c2 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/ForEachStatementTranslator.java @@ -0,0 +1,41 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiForeachStatement; +import com.intellij.psi.PsiParameter; +import java2typescript.context.TranslationContext; +import java2typescript.helper.KeywordHelper; +import java2typescript.helper.TypeHelper; +import java2typescript.translators.expression.ExpressionTranslator; + +public class ForEachStatementTranslator { + + public static void translate(PsiForeachStatement element, TranslationContext ctx) { + PsiParameter parameter = element.getIterationParameter(); + ctx.print(""); + ExpressionTranslator.translate(element.getIteratedValue(), ctx); + ctx.append(".forEach(("); + ctx.append(KeywordHelper.process(parameter.getName(), ctx)); + ctx.append(": "); + ctx.append(TypeHelper.printType(parameter.getType(), ctx)); + ctx.append(") => {\n"); + ctx.increaseIdent(); + StatementTranslator.translate(element.getBody(), ctx); + ctx.decreaseIdent(); + ctx.print("});\n"); + } +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/ForStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/ForStatementTranslator.java new file mode 100755 index 0000000..51530c7 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/ForStatementTranslator.java @@ -0,0 +1,55 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiBlockStatement; +import com.intellij.psi.PsiForStatement; +import java2typescript.context.TranslationContext; +import java2typescript.translators.expression.ExpressionTranslator; + +public class ForStatementTranslator { + + public static void translate(PsiForStatement element, TranslationContext ctx) { + ctx.print("for ("); + if (element.getInitialization() != null) { + StatementTranslator.translate(element.getInitialization(), ctx); + } + ctx.append("; "); + if (element.getCondition() != null) { + ExpressionTranslator.translate(element.getCondition(), ctx); + } + ctx.append("; "); + if (element.getUpdate() != null) { + StatementTranslator.translate(element.getUpdate(), ctx); + } + + ctx.append(")"); + if(element.getBody() != null) { + if( !(element.getBody() instanceof PsiBlockStatement)) { + ctx.append("\n"); + ctx.increaseIdent(); + StatementTranslator.translate(element.getBody(), ctx); + ctx.decreaseIdent(); + } else { + ctx.append(" "); + StatementTranslator.translate(element.getBody(), ctx); + } + } + ctx.append("\n"); + + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/IfStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/IfStatementTranslator.java new file mode 100755 index 0000000..6854a80 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/IfStatementTranslator.java @@ -0,0 +1,68 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiBlockStatement; +import com.intellij.psi.PsiIfStatement; +import java2typescript.context.TranslationContext; +import java2typescript.translators.expression.ExpressionTranslator; + +public class IfStatementTranslator { + + public static void translate(PsiIfStatement element, TranslationContext ctx, boolean elseif) { + if (elseif) { + ctx.append("if ("); + } else { + ctx.print("if ("); + } + ExpressionTranslator.translate(element.getCondition(), ctx); + ctx.append(")"); + if (!(element.getThenBranch() instanceof PsiBlockStatement)) { + ctx.append("\n"); + ctx.increaseIdent(); + StatementTranslator.translate(element.getThenBranch(), ctx); + ctx.decreaseIdent(); + } else { + ctx.append(" "); + StatementTranslator.translate(element.getThenBranch(), ctx); + } + if (element.getElseElement() != null) { + if (!(element.getThenBranch() instanceof PsiBlockStatement)) { + ctx.print("else"); + } else { + ctx.append(" else"); + } + if (element.getElseBranch() instanceof PsiIfStatement) { + ctx.append(" "); + IfStatementTranslator.translate((PsiIfStatement) element.getElseBranch(), ctx, true); + } else { + if (!(element.getElseBranch() instanceof PsiBlockStatement)) { + ctx.append("\n"); + ctx.increaseIdent(); + StatementTranslator.translate(element.getElseBranch(), ctx); + ctx.decreaseIdent(); + } else { + ctx.append(" "); + StatementTranslator.translate(element.getElseBranch(), ctx); + } + } + ctx.append("\n"); + } else { + ctx.append("\n"); + } + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/LocalVariableTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/LocalVariableTranslator.java new file mode 100755 index 0000000..89c38f8 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/LocalVariableTranslator.java @@ -0,0 +1,74 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.*; +import java2typescript.context.TranslationContext; +import java2typescript.helper.KeywordHelper; +import java2typescript.helper.TypeHelper; +import java2typescript.translators.expression.ExpressionTranslator; + +public class LocalVariableTranslator { + + public static void translate(PsiLocalVariable element, TranslationContext ctx) { + PsiElement parent = element.getParent(); + boolean loopDeclaration = false; + + if (parent instanceof PsiDeclarationStatement) { + parent = parent.getParent(); + if (parent instanceof PsiLoopStatement) { + loopDeclaration = true; + } + } + if (element.getPrevSibling() == null) { + if (loopDeclaration) { + ctx.append("let "); + } else { + ctx.print("let "); + } + } + + ctx.append(KeywordHelper.process(element.getName(), ctx)); + + // explicit local variable type + ctx.append(": "); + ctx.append(TypeHelper.printType(element.getType(), ctx)); + + if (element.hasInitializer() && element.getInitializer() != null) { + ctx.append(" = "); + ExpressionTranslator.translate(element.getInitializer(), ctx); + if (element.getType().getPresentableText().equals("byte") && + element.getInitializer().getType() != null && + element.getInitializer().getType().getPresentableText().equals("char")) { + ctx.append(".charCodeAt(0)"); + } + } + + boolean listDecl = false; + PsiElement next = element.getNextSibling(); + while (next instanceof PsiWhiteSpace) { + next = next.getNextSibling(); + } + if (next instanceof PsiJavaToken) { + listDecl = true; + } + + if (!loopDeclaration && !listDecl) { + ctx.append(";"); + ctx.append("\n"); + } + } +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/ReturnStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/ReturnStatementTranslator.java new file mode 100755 index 0000000..d8f6179 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/ReturnStatementTranslator.java @@ -0,0 +1,33 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiReturnStatement; +import java2typescript.context.TranslationContext; +import java2typescript.translators.expression.ExpressionTranslator; + +public class ReturnStatementTranslator { + + public static void translate(PsiReturnStatement element, TranslationContext ctx) { + ctx.print("return"); + if (element.getReturnValue() != null) { + ctx.append(' '); + ExpressionTranslator.translate(element.getReturnValue(),ctx); + } + ctx.append(";\n"); + } + +} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/StatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/StatementTranslator.java old mode 100644 new mode 100755 similarity index 61% rename from org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/StatementTranslator.java rename to transpiler/src/main/java/java2typescript/translators/statement/StatementTranslator.java index 6f5f7d1..3eec86c --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/StatementTranslator.java +++ b/transpiler/src/main/java/java2typescript/translators/statement/StatementTranslator.java @@ -1,8 +1,23 @@ -package org.kevoree.modeling.java2typescript.translators.statement; +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; import com.intellij.psi.*; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.translators.CodeBlockTranslator; +import java2typescript.context.TranslationContext; +import java2typescript.translators.CodeBlockTranslator; /** * Created by duke on 11/6/14. @@ -13,7 +28,7 @@ public static void translate(PsiStatement statement, TranslationContext ctx) { if (statement instanceof PsiExpressionStatement) { ExpressionStatementTranslator.translate((PsiExpressionStatement) statement, ctx); } else if (statement instanceof PsiIfStatement) { - IfStatementTranslator.translate((PsiIfStatement) statement, ctx); + IfStatementTranslator.translate((PsiIfStatement) statement, ctx, false); } else if (statement instanceof PsiReturnStatement) { ReturnStatementTranslator.translate((PsiReturnStatement) statement, ctx); } else if (statement instanceof PsiWhileStatement) { @@ -36,10 +51,18 @@ public static void translate(PsiStatement statement, TranslationContext ctx) { SwitchStatementTranslator.translate((PsiSwitchStatement) statement, ctx); } else if (statement instanceof PsiForeachStatement) { ForEachStatementTranslator.translate((PsiForeachStatement) statement, ctx); - } else if (statement instanceof PsiSwitchLabelStatement) { - SwitchLabelStatementTranslator.translate((PsiSwitchLabelStatement) statement, ctx); } else if (statement instanceof PsiDeclarationStatement) { DeclarationStatementTranslator.translate((PsiDeclarationStatement) statement, ctx); + } else if (statement instanceof PsiExpressionListStatement) { + ExpressionListStatementTranslator.translate((PsiExpressionListStatement) statement, ctx); + } else if (statement instanceof PsiSynchronizedStatement) { + SynchronizedStatementTranslator.translate((PsiSynchronizedStatement) statement, ctx); + } else if (statement instanceof PsiEmptyStatement) { + //Ignore + } else if (statement instanceof PsiAssertStatement) { + //Ignore + } else { + System.err.println("StatementTranslator ! "+statement.toString()); } } diff --git a/transpiler/src/main/java/java2typescript/translators/statement/SwitchStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/SwitchStatementTranslator.java new file mode 100755 index 0000000..78b489f --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/SwitchStatementTranslator.java @@ -0,0 +1,71 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.*; +import java2typescript.context.TranslationContext; +import java2typescript.translators.CodeBlockTranslator; +import java2typescript.translators.expression.ExpressionTranslator; + +public class SwitchStatementTranslator { + + public static void translate(PsiSwitchStatement element, TranslationContext ctx) { + ctx.print("switch ("); + ExpressionTranslator.translate(element.getExpression(), ctx); + ctx.append(") {\n"); + ctx.increaseIdent(); + PsiStatement prev = null; + + for(PsiStatement s : element.getBody().getStatements()) { + if(s instanceof PsiSwitchLabelStatement) { + if(prev != null && (prev instanceof PsiSwitchLabelStatement || prev instanceof PsiBlockStatement)) { + ctx.append("\n"); + } + PsiSwitchLabelStatement label = (PsiSwitchLabelStatement)s; + if (label.isDefaultCase()) { + ctx.print("default: \n"); + } else { + ctx.print("case "); + ExpressionTranslator.translate(label.getCaseValue(), ctx); + ctx.append(":"); + } + } else if(s instanceof PsiExpressionStatement){ + ctx.append("\n"); + ctx.increaseIdent(); + ctx.print(""); + ExpressionTranslator.translate(((PsiExpressionStatement)s).getExpression(), ctx); + ctx.append(";\n"); + ctx.decreaseIdent(); + } else if(s instanceof PsiBreakStatement){ + BreakStatementTranslator.translate(((PsiBreakStatement)s), ctx); + } else if(s instanceof PsiBlockStatement){ + ctx.append(" "); + CodeBlockTranslator.translate(((PsiBlockStatement)s).getCodeBlock(), ctx); + } else if(s instanceof PsiReturnStatement){ + ctx.append("\n"); + ctx.increaseIdent(); + ReturnStatementTranslator.translate(((PsiReturnStatement)s), ctx); + ctx.decreaseIdent(); + } else { + StatementTranslator.translate(s, ctx); + } + prev = s; + } + ctx.decreaseIdent(); + ctx.print("}\n"); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/SynchronizedStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/SynchronizedStatementTranslator.java new file mode 100755 index 0000000..d717db6 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/SynchronizedStatementTranslator.java @@ -0,0 +1,28 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiSynchronizedStatement; +import java2typescript.context.TranslationContext; +import java2typescript.translators.CodeBlockTranslator; + +public class SynchronizedStatementTranslator { + + public static void translate(PsiSynchronizedStatement element, TranslationContext ctx) { + CodeBlockTranslator.translate(element.getBody(), ctx); + } + +} diff --git a/transpiler/src/main/java/java2typescript/translators/statement/ThrowStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/ThrowStatementTranslator.java new file mode 100755 index 0000000..3846ee4 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/ThrowStatementTranslator.java @@ -0,0 +1,30 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiThrowStatement; +import java2typescript.context.TranslationContext; +import java2typescript.translators.expression.ExpressionTranslator; + +public class ThrowStatementTranslator { + + public static void translate(PsiThrowStatement element, TranslationContext ctx) { + ctx.print("throw "); + ExpressionTranslator.translate(element.getException(), ctx); + ctx.append(";\n"); + } + +} diff --git a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/TryStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/TryStatementTranslator.java similarity index 55% rename from org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/TryStatementTranslator.java rename to transpiler/src/main/java/java2typescript/translators/statement/TryStatementTranslator.java index 3dc3992..72f8d45 100755 --- a/org.kevoree.modeling.java2typescript/src/main/java/org/kevoree/modeling/java2typescript/translators/statement/TryStatementTranslator.java +++ b/transpiler/src/main/java/java2typescript/translators/statement/TryStatementTranslator.java @@ -1,22 +1,34 @@ - -package org.kevoree.modeling.java2typescript.translators.statement; +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; import com.intellij.psi.PsiCatchSection; import com.intellij.psi.PsiTryStatement; -import org.kevoree.modeling.java2typescript.TranslationContext; -import org.kevoree.modeling.java2typescript.TypeHelper; -import org.kevoree.modeling.java2typescript.translators.CodeBlockTranslator; +import java2typescript.context.TranslationContext; +import java2typescript.helper.KeywordHelper; +import java2typescript.helper.TypeHelper; +import java2typescript.translators.CodeBlockTranslator; public class TryStatementTranslator { private static final String EXCEPTION_VAR = "$ex$"; public static void translate(PsiTryStatement element, TranslationContext ctx) { - ctx.print("try {\n"); - ctx.increaseIdent(); + ctx.print("try "); CodeBlockTranslator.translate(element.getTryBlock(), ctx); - ctx.decreaseIdent(); - ctx.print("}"); PsiCatchSection[] catchSections = element.getCatchSections(); if (catchSections.length > 0) { ctx.append(" catch (").append(EXCEPTION_VAR).append(") {\n"); @@ -26,16 +38,19 @@ public static void translate(PsiTryStatement element, TranslationContext ctx) { String exceptionType = TypeHelper.printType(catchSection.getCatchType(), ctx); ctx.print("if (").append(EXCEPTION_VAR).append(" instanceof ").append(exceptionType).append(") {\n"); ctx.increaseIdent(); - ctx.print("var ").append(catchSection.getParameter().getName()); + ctx.print("var ").append(KeywordHelper.process(catchSection.getParameter().getName(), ctx)); ctx.append(": ").append(exceptionType).append(" = <").append(exceptionType).append(">").append(EXCEPTION_VAR).append(";\n"); CodeBlockTranslator.translate(catchSection.getCatchBlock(), ctx); ctx.decreaseIdent(); - if (i != catchSections.length - 1) { - ctx.print("} else "); - } else { - ctx.print("}\n "); - } + ctx.print("} else "); } + + ctx.append("{\n"); + ctx.increaseIdent(); + ctx.print("throw ").append(EXCEPTION_VAR).append(";\n"); + ctx.decreaseIdent(); + ctx.print("}\n"); + ctx.decreaseIdent(); ctx.print("}"); } diff --git a/transpiler/src/main/java/java2typescript/translators/statement/WhileStatementTranslator.java b/transpiler/src/main/java/java2typescript/translators/statement/WhileStatementTranslator.java new file mode 100755 index 0000000..843bd87 --- /dev/null +++ b/transpiler/src/main/java/java2typescript/translators/statement/WhileStatementTranslator.java @@ -0,0 +1,32 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript.translators.statement; + +import com.intellij.psi.PsiWhileStatement; +import java2typescript.context.TranslationContext; +import java2typescript.translators.expression.ExpressionTranslator; + +public class WhileStatementTranslator { + + public static void translate(PsiWhileStatement element, TranslationContext ctx) { + ctx.print("while ("); + ExpressionTranslator.translate(element.getCondition(), ctx); + ctx.append(") "); + StatementTranslator.translate(element.getBody(), ctx); + ctx.append("\n"); + } + +} diff --git a/transpiler/src/main/resources/jre/jre.ts b/transpiler/src/main/resources/jre/jre.ts new file mode 100755 index 0000000..89a7ab3 --- /dev/null +++ b/transpiler/src/main/resources/jre/jre.ts @@ -0,0 +1,1427 @@ +export namespace java { + export namespace lang { + export class System { + static gc() { + } + + static arraycopy(src: any[] | Float64Array | Int32Array | Int8Array, srcPos: number, dest: any[] | Float64Array | Int32Array | Int8Array, destPos: number, numElements: number): void { + if ((dest instanceof Float64Array || dest instanceof Int32Array || dest instanceof Int8Array) + && (src instanceof Float64Array || src instanceof Int32Array || src instanceof Int8Array)) { + if (numElements == src.length) { + dest.set(src, destPos); + } else { + dest.set(src.subarray(srcPos, srcPos + numElements), destPos); + } + } else { + for (let i = 0; i < numElements; i++) { + dest[destPos + i] = src[srcPos + i]; + } + } + } + } + + export class StringBuilder { + private _buffer: string = ''; + public length = 0; + + append(val: any): StringBuilder { + this._buffer = this._buffer + val; + this.length = this._buffer.length; + return this; + } + + insert(position: number, val: any): StringBuilder { + this._buffer = this._buffer.slice(0, position) + val + this._buffer.slice(position); + + return this; + } + + toString(): string { + return this._buffer; + } + } + + export class String { + static valueOf(data: any, offset?: number, count?: number): string { + if (typeof offset === 'undefined' && typeof count === 'undefined') { + return data + ''; + } else { + return data.slice(offset, offset + count); + } + } + + static hashCode(str: string): number { + var h: number = str['_hashCode'] ? str['_hashCode'] : 0; + if (h === 0 && str.length > 0) { + var val: string = str; + + for (var i: number = 0; i < str.length; i++) { + h = 31 * h + str.charCodeAt(i); + } + str['_hashCode'] = h; + } + return h; + } + + static isEmpty(str: string): boolean { + return str.length === 0; + } + + static join(delimiter: string, elements: string[]): string { + return elements.join(delimiter); + } + } + + export class Thread { + static sleep(time: number): void { + + } + } + + export class Double { + public static MAX_VALUE: number = Number.MAX_VALUE; + public static POSITIVE_INFINITY: number = Number.POSITIVE_INFINITY; + public static NEGATIVE_INFINITY: number = Number.NEGATIVE_INFINITY; + public static NaN = NaN; + + public static isInfinite(value: number): boolean { + return value === Number.NEGATIVE_INFINITY || value === Number.POSITIVE_INFINITY; + } + + public static isFinite(value: number): boolean { + return !Double.isInfinite(value); + } + + public static isNaN(value: number): boolean { + return value === Number.NaN; + } + + public static parseDouble(d: any) { + return Number(d); + } + + public static valueOf(d: any) { + return Number(d); + } + } + + export class Long { + public static parseLong(d: any) { + return parseInt(d); + } + } + + export class Integer { + public static parseInt(d: any) { + return parseInt(d); + } + } + + } + + export namespace util { + export namespace concurrent { + export namespace atomic { + export class AtomicIntegerArray { + _internal: Int32Array; + + constructor(initialCapacity: number) { + this._internal = new Int32Array(initialCapacity); + } + + set(index: number, newVal: number) { + this._internal[index] = newVal; + } + + get(index: number) { + return this._internal[index]; + } + + getAndSet(index: number, newVal: number) { + var temp = this._internal[index]; + this._internal[index] = newVal; + return temp; + } + + compareAndSet(index: number, expect: number, update: number): boolean { + if (this._internal[index] == expect) { + this._internal[index] = update; + return true; + } else { + return false; + } + } + } + + export class AtomicLongArray { + _internal: Float64Array; + + constructor(initialCapacity: number) { + this._internal = new Float64Array(initialCapacity); + } + + set(index: number, newVal: number) { + this._internal[index] = newVal; + } + + get(index: number) { + return this._internal[index]; + } + + getAndSet(index: number, newVal: number) { + var temp = this._internal[index]; + this._internal[index] = newVal; + return temp; + } + + compareAndSet(index: number, expect: number, update: number): boolean { + if (this._internal[index] == expect) { + this._internal[index] = update; + return true; + } else { + return false; + } + } + + length(): number { + return this._internal.length; + } + } + + export class AtomicReferenceArray { + _internal: Array; + + constructor(initialCapacity: number) { + this._internal = new Array(); + } + + set(index: number, newVal: A) { + this._internal[index] = newVal; + } + + get(index: number): A { + return this._internal[index]; + } + + getAndSet(index: number, newVal: A) { + var temp = this._internal[index]; + this._internal[index] = newVal; + return temp; + } + + compareAndSet(index: number, expect: A, update: A): boolean { + if (this._internal[index] == expect) { + this._internal[index] = update; + return true; + } else { + return false; + } + } + + length(): number { + return this._internal.length; + } + } + + export class AtomicReference { + _internal: A = null; + + compareAndSet(expect: A, update: A): boolean { + if (this._internal == expect) { + this._internal = update; + return true; + } else { + return false; + } + } + + get(): A { + return this._internal + } + + set(newRef: A) { + this._internal = newRef; + } + + getAndSet(newVal: A): A { + var temp = this._internal; + this._internal = newVal; + return temp; + } + } + + export class AtomicLong { + _internal = 0; + + constructor(init: number) { + this._internal = init; + } + + compareAndSet(expect: number, update: number): boolean { + if (this._internal == expect) { + this._internal = update; + return true; + } else { + return false; + } + } + + get(): number { + return this._internal; + } + + incrementAndGet(): number { + this._internal++; + return this._internal; + } + + decrementAndGet(): number { + this._internal--; + return this._internal; + } + } + + export class AtomicBoolean { + _internal = false; + + constructor(init: boolean) { + this._internal = init; + } + + compareAndSet(expect: boolean, update: boolean): boolean { + if (this._internal == expect) { + this._internal = update; + return true; + } else { + return false; + } + } + + get(): boolean { + return this._internal; + } + + set(newVal: boolean) { + this._internal = newVal + } + + } + + export class AtomicInteger { + _internal = 0; + + constructor(init: number) { + this._internal = init; + } + + compareAndSet(expect: number, update: number): boolean { + if (this._internal == expect) { + this._internal = update; + return true; + } else { + return false; + } + } + + get(): number { + return this._internal; + } + + set(newVal: number) { + this._internal = newVal + } + + getAndSet(newVal: number): number { + var temp = this._internal; + this._internal = newVal; + return temp; + } + + incrementAndGet(): number { + this._internal++; + return this._internal; + } + + decrementAndGet(): number { + this._internal--; + return this._internal; + } + + getAndIncrement(): number { + var temp = this._internal; + this._internal++; + return temp; + } + + getAndDecrement(): number { + var temp = this._internal; + this._internal--; + return temp; + } + + intValue(): number { + return this._internal; + } + } + } + export namespace locks { + export class ReentrantLock { + public lock(): void { + + } + + public unlock(): void { + + } + } + } + } + + export class Random { + private seed: number = undefined; + + public nextInt(max?: number): number { + if (typeof max === 'undefined') { + max = Math.pow(2, 32); + } + if (this.seed == undefined) { + return Math.floor(Math.random() * max); + } else { + return Math.floor(this.nextSeeded(0, max)); + } + } + + public nextDouble(): number { + if (this.seed == undefined) { + return Math.random(); + } else { + return this.nextSeeded(); + } + } + + public nextBoolean(): boolean { + if (this.seed == undefined) { + return Math.random() >= 0.5; + } else { + return this.nextSeeded() >= 0.5; + } + } + + public setSeed(seed: number): void { + this.seed = seed; + } + + private nextSeeded(min?: number, max?: number) { + var max = max || 1; + var min = min || 0; + + this.seed = (this.seed * 9301 + 49297) % 233280; + var rnd = this.seed / 233280; + + return min + rnd * (max - min); + } + + private haveNextNextGaussian: boolean = false; + private nextNextGaussian: number = 0.; + + public nextGaussian(): number { + + if (this.haveNextNextGaussian) { + this.haveNextNextGaussian = false; + return this.nextNextGaussian; + } else { + var v1, v2, s; + do { + v1 = 2 * this.nextDouble() - 1; // between -1 and 1 + v2 = 2 * this.nextDouble() - 1; // between -1 and 1 + s = v1 * v1 + v2 * v2; + } while (s >= 1 || s == 0); + var multiplier = Math.sqrt(-2 * Math.log(s) / s); + this.nextNextGaussian = v2 * multiplier; + this.haveNextNextGaussian = true; + return v1 * multiplier; + } + } + + } + + export interface Iterator { + hasNext(): boolean; + + next(): E; + } + + export class Arrays { + public static fill(data: any, begin: number, nbElem: number, param: number): void { + var max = begin + nbElem; + for (var i = begin; i < max; i++) { + data[i] = param; + } + } + + public static copyOf(original: any[], newLength: number, ignore?: any): T[] { + var copy = new Array(newLength); + lang.System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength)); + return copy; + } + } + + export class Collections { + + public static swap(list: List, i: number, j: number) { + const l = list; + l.set(i, l.set(j, l.get(i))); + } + + } + + export interface Collection { + add(val: E): void; + + addAll(vals: Collection): void; + + get(index: number): E; + + remove(o: any): any; + + clear(): void; + + isEmpty(): boolean; + + size(): number; + + contains(o: E): boolean; + + toArray(a: Array): E[]; + + iterator(): Iterator; + + containsAll(c: Collection): boolean; + + addAll(c: Collection): boolean; + + removeAll(c: Collection): boolean; + + } + + export interface List extends Collection { + add(elem: E): void; + + add(index: number, elem: E): void; + + poll(): E; + + addAll(c: Collection): boolean; + + addAll(index: number, c: Collection): boolean; + + get(index: number): E; + + set(index: number, element: E): E; + + indexOf(o: E): number; + + lastIndexOf(o: E): number; + + remove(index: number): E; + } + + export interface Set extends Collection { + forEach(f: (e: any) => void): void; + } + + export class Itr implements Iterator { + public cursor: number = 0; + public lastRet: number = -1; + protected list: Collection; + + constructor(list: Collection) { + this.list = list; + } + + public hasNext(): boolean { + return this.cursor != this.list.size(); + } + + public next(): E { + try { + var i: number = this.cursor; + var next: E = this.list.get(i); + this.lastRet = i; + this.cursor = i + 1; + return next; + } catch ($ex$) { + if ($ex$ instanceof Error) { + var e: Error = $ex$; + throw new Error('no such element exception'); + } else { + throw $ex$; + } + } + } + } + + export class HashSet implements Set { + private content = {}; + + add(val: E) { + this.content[val] = val; + } + + clear() { + this.content = {}; + } + + contains(val: E): boolean { + return this.content.hasOwnProperty(val); + } + + containsAll(elems: Collection): boolean { + return false; + } + + addAll(vals: Collection): boolean { + var tempArray = vals.toArray(null); + for (var i = 0; i < tempArray.length; i++) { + this.content[tempArray[i]] = tempArray[i]; + } + return true; + } + + remove(val: E): boolean { + var b = false; + if (this.content[val]) { + b = true; + } + delete this.content[val]; + return b; + } + + removeAll(): boolean { + return false; + } + + size(): number { + return Object.keys(this.content).length; + } + + isEmpty(): boolean { + return this.size() == 0; + } + + toArray(a: Array): E[] { + return Object.keys(this.content).map(key => this.content[key]); + } + + iterator(): Iterator { + return new java.util.Itr(this); + } + + forEach(f: (e: any) => void): void { + for (var p in this.content) { + f(this.content[p]); + } + } + + get(index: number): E { + return this.content[index]; + } + } + + + export class AbstractList implements List { + private content: E[] = []; + + addAll(index: any, vals?: any): boolean { + var tempArray = vals.toArray(null); + for (var i = 0; i < tempArray.length; i++) { + this.content.push(tempArray[i]); + } + return false; + } + + clear() { + this.content = []; + } + + poll(): E { + return this.content.shift(); + } + + remove(indexOrElem: any): any { + this.content.splice(indexOrElem, 1); + return true; + } + + removeAll(): boolean { + this.content = []; + return true; + } + + toArray(a: Array): E[] { + return this.content; + } + + size(): number { + return this.content.length; + } + + add(index: any, elem?: E) { + if (typeof elem !== 'undefined') { + this.content.splice(index, 0, elem); + } else { + this.content.push(index); + } + } + + get(index: number): E { + return this.content[index]; + } + + contains(val: E): boolean { + return this.content.indexOf(val) != -1; + } + + containsAll(elems: Collection): boolean { + return false; + } + + isEmpty(): boolean { + return this.content.length == 0; + } + + set(index: number, element: E): E { + this.content[index] = element; + return element; + } + + indexOf(element: E): number { + return this.content.indexOf(element); + } + + lastIndexOf(element: E): number { + return this.content.lastIndexOf(element); + } + + iterator(): Iterator { + return new Itr(this); + } + + } + + export class LinkedList extends AbstractList { + } + + export class ArrayList extends AbstractList { + } + + export class Stack { + content = new Array(); + + pop(): E { + return this.content.pop(); + } + + push(t: E): void { + this.content.push(t); + } + + isEmpty(): boolean { + return this.content.length == 0; + } + + peek(): E { + return this.content.slice(-1)[0]; + } + } + + export interface Map { + get(key: K): V; + + put(key: K, value: V): V; + + containsKey(key: K): boolean; + + remove(key: K): V; + + keySet(): Set; + + isEmpty(): boolean; + + values(): Collection; + + clear(): void; + + size(): number; + } + + export class HashMap implements Map { + + private content = {}; + + get(key: K): V { + return this.content[key]; + } + + put(key: K, value: V): V { + var previous_val = this.content[key]; + this.content[key] = value; + return previous_val; + } + + containsKey(key: K): boolean { + return this.content.hasOwnProperty(key); + } + + remove(key: K): V { + var tmp = this.content[key]; + delete this.content[key]; + return tmp; + } + + keySet(): Set { + var result = new HashSet(); + for (var p in this.content) { + if (this.content.hasOwnProperty(p)) { + result.add( p); + } + } + return > result; + } + + isEmpty(): boolean { + return Object.keys(this.content).length == 0; + } + + values(): Collection { + var result = new ArrayList(); + for (var p in this.content) { + if (this.content.hasOwnProperty(p)) { + result.add(this.content[p]); + } + } + return >result; + } + + clear(): void { + this.content = {}; + } + + size(): number { + return Object.keys(this.content).length + } + } + + export class ConcurrentHashMap extends HashMap { + + } + } +} + +function arrayInstanceOf(arr: any, arg: Function): boolean { + if (!(arr instanceof Array)) { + return false; + } else { + if (arr.length == 0) { + return true; + } else { + return (arr[0] instanceof arg); + } + } +} + + +export class Long { + + /* + long.js (c) 2013 Daniel Wirtz + Released under the Apache License, Version 2.0 + see: https://github.com/dcodeIO/long.js for details + */ + + private high: number = 0; + private low: number = 0; + private unsigned: boolean = false; + + private static INT_CACHE = {}; + private static UINT_CACHE = {}; + private static pow_dbl = Math.pow; + + public static fromInt(value: number, unsigned ?: boolean): Long { + var obj, cachedObj, cache; + if (unsigned) { + value >>>= 0; + if (cache = (0 <= value && value < 256)) { + cachedObj = Long.UINT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true); + if (cache) + Long.UINT_CACHE[value] = obj; + return obj; + } else { + value |= 0; + if (cache = (-128 <= value && value < 128)) { + cachedObj = Long.INT_CACHE[value]; + if (cachedObj) + return cachedObj; + } + obj = Long.fromBits(value, value < 0 ? -1 : 0, false); + if (cache) + Long.INT_CACHE[value] = obj; + return obj; + } + } + + public static fromBits(lowBits ?: number, highBits ?: number, unsigned ?: boolean): Long { + return new Long(lowBits, highBits, unsigned); + } + + public static fromNumber(value: number, unsigned ?: boolean): Long { + if (isNaN(value) || !isFinite(value)) + return unsigned ? Long.UZERO : Long.ZERO; + if (unsigned) { + if (value < 0) + return Long.UZERO; + if (value >= Long.TWO_PWR_64_DBL) + return Long.MAX_UNSIGNED_VALUE; + } else { + if (value <= -Long.TWO_PWR_63_DBL) + return Long.MIN_VALUE; + if (value + 1 >= Long.TWO_PWR_63_DBL) + return Long.MAX_VALUE; + } + if (value < 0) + return Long.fromNumber(-value, unsigned).neg(); + return Long.fromBits((value % Long.TWO_PWR_32_DBL) | 0, (value / Long.TWO_PWR_32_DBL) | 0, unsigned); + } + + private static TWO_PWR_16_DBL = 1 << 16; + private static TWO_PWR_24_DBL = 1 << 24; + private static TWO_PWR_32_DBL = Long.TWO_PWR_16_DBL * Long.TWO_PWR_16_DBL; + private static TWO_PWR_64_DBL = Long.TWO_PWR_32_DBL * Long.TWO_PWR_32_DBL; + private static TWO_PWR_63_DBL = Long.TWO_PWR_64_DBL / 2; + private static TWO_PWR_24 = Long.fromInt(Long.TWO_PWR_24_DBL); + + public static ZERO: Long = Long.fromInt(0); + public static UZERO: Long = Long.fromInt(0, true); + public static ONE: Long = Long.fromInt(1); + public static UONE: Long = Long.fromInt(1, true); + public static NEG_ONE: Long = Long.fromInt(-1); + public static MAX_VALUE: Long = Long.fromBits(0x7FFFFFFF, 0xFFFFFFFF, false); + public static MAX_UNSIGNED_VALUE: Long = Long.fromBits(0xFFFFFFFF, 0xFFFFFFFF, true); + public static MIN_VALUE: Long = Long.fromBits(0x80000000, 0, false); + + + constructor(low ?: number, high ?: number, unsigned ?: boolean) { + if (!(high == undefined)) { + this.high = high; + } + if (!(low == undefined)) { + this.low = low; + } + if (!(unsigned == undefined)) { + this.unsigned = unsigned; + } + } + + public static isLong(obj: any): boolean { + return (obj && obj['__isLong__']) === true; + } + + public static fromString(str: string, radix: number = 10, unsigned: boolean = false): Long { + if (str.length === 0) + throw Error('empty string'); + if (str === 'NaN' || str === 'Infinity' || str === '+Infinity' || str === '-Infinity') + return Long.ZERO; + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + + var p; + if ((p = str.indexOf('-')) > 0) + throw Error('interior hyphen'); + else if (p === 0) { + return Long.fromString(str.substring(1), radix, unsigned).neg(); + } + + // Do several (8) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Long.fromNumber(Long.pow_dbl(radix, 8)); + + var result = Long.ZERO; + for (var i = 0; i < str.length; i += 8) { + var size = Math.min(8, str.length - i), + value = parseInt(str.substring(i, i + size), radix); + if (size < 8) { + var power = Long.fromNumber(Long.pow_dbl(radix, size)); + result = result.mul(power).add(Long.fromNumber(value)); + } else { + result = result.mul(radixToPower); + result = result.add(Long.fromNumber(value)); + } + } + result.unsigned = unsigned; + return result; + } + + public static fromValue(val: any): Long { + if (val /* is compatible */ instanceof Long) + return val; + if (typeof val === 'number') + return Long.fromNumber(val); + if (typeof val === 'string') + return Long.fromString(val); + // Throws for non-objects, converts non-instanceof Long: + return Long.fromBits(val.low, val.high, val.unsigned); + } + + + public toInt(): number { + return this.unsigned ? this.low >>> 0 : this.low; + }; + + public toNumber(): number { + if (this.unsigned) + return ((this.high >>> 0) * Long.TWO_PWR_32_DBL) + (this.low >>> 0); + return this.high * Long.TWO_PWR_32_DBL + (this.low >>> 0); + }; + + public toString(radix: number): string { + radix = radix || 10; + if (radix < 2 || 36 < radix) + throw RangeError('radix'); + if (this.isZero()) + return '0'; + if (this.isNegative()) { // Unsigned Longs are never negative + if (this.eq(Long.MIN_VALUE)) { + // We need to change the Long value before it can be negated, so we remove + // the bottom-most digit in this base and then recurse to do the rest. + var radixLong = Long.fromNumber(radix), + div = this.div(radixLong), + rem1 = div.mul(radixLong).sub(this); + return div.toString(radix) + rem1.toInt().toString(radix); + } else + return '-' + this.neg().toString(radix); + } + + // Do several (6) digits each time through the loop, so as to + // minimize the calls to the very expensive emulated div. + var radixToPower = Long.fromNumber(Long.pow_dbl(radix, 6), this.unsigned); + var rem: Long = this; + var result = ''; + while (true) { + var remDiv = rem.div(radixToPower); + var intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0; + var digits = intval.toString(radix); + rem = remDiv; + if (rem.isZero()) + return digits + result; + else { + while (digits.length < 6) + digits = '0' + digits; + result = '' + digits + result; + } + } + }; + + public getHighBits(): number { + return this.high; + }; + + public getHighBitsUnsigned(): number { + return this.high >>> 0; + }; + + public getLowBits(): number { + return this.low; + }; + + public getLowBitsUnsigned(): number { + return this.low >>> 0; + }; + + public getNumBitsAbs(): number { + if (this.isNegative()) // Unsigned Longs are never negative + return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs(); + var val = this.high != 0 ? this.high : this.low; + for (var bit = 31; bit > 0; bit--) + if ((val & (1 << bit)) != 0) + break; + return this.high != 0 ? bit + 33 : bit + 1; + }; + + public isZero(): boolean { + return this.high === 0 && this.low === 0; + }; + + public isNegative(): boolean { + return !this.unsigned && this.high < 0; + }; + + public isPositive(): boolean { + return this.unsigned || this.high >= 0; + }; + + public isOdd(): boolean { + return (this.low & 1) === 1; + }; + + public isEven(): boolean { + return (this.low & 1) === 0; + }; + + public equals(other: any): boolean { + if (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.unsigned !== other.unsigned && (this.high >>> 31) === 1 && (other.high >>> 31) === 1) + return false; + return this.high === other.high && this.low === other.low; + }; + + public eq = this.equals; + + public notEquals(other: any): boolean { + return !this.eq(other); + }; + + public neq = this.notEquals; + + public lessThan(other: any): boolean { + return this.comp(other) < 0; + }; + + public lt = this.lessThan; + + public lessThanOrEqual(other: any): boolean { + return this.comp(other) <= 0; + }; + + public lte = this.lessThanOrEqual; + + public greaterThan(other: any): boolean { + return this.comp(other) > 0; + }; + + public gt = this.greaterThan; + + public greaterThanOrEqual(other: any): boolean { + return this.comp(other) >= 0; + }; + + public gte = this.greaterThanOrEqual; + + public compare(other: any): number { + if (!Long.isLong(other)) + other = Long.fromValue(other); + if (this.eq(other)) + return 0; + var thisNeg = this.isNegative(), + otherNeg = other.isNegative(); + if (thisNeg && !otherNeg) + return -1; + if (!thisNeg && otherNeg) + return 1; + // At this point the sign bits are the same + if (!this.unsigned) + return this.sub(other).isNegative() ? -1 : 1; + // Both are positive if at least one is unsigned + return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1; + }; + + public comp = this.compare; + + public negate(): Long { + if (!this.unsigned && this.eq(Long.MIN_VALUE)) + return Long.MIN_VALUE; + return this.not().add(Long.ONE); + }; + + public neg = this.negate; + + public add(addend: any): Long { + if (!Long.isLong(addend)) { + addend = Long.fromValue(addend); + } + + // Divide each number into 4 chunks of 16 bits, and then sum the chunks. + + var a48 = this.high >>> 16; + var a32 = this.high & 0xFFFF; + var a16 = this.low >>> 16; + var a00 = this.low & 0xFFFF; + + var b48 = addend.high >>> 16; + var b32 = addend.high & 0xFFFF; + var b16 = addend.low >>> 16; + var b00 = addend.low & 0xFFFF; + + var c48 = 0, c32 = 0, c16 = 0, c00 = 0; + c00 += a00 + b00; + c16 += c00 >>> 16; + c00 &= 0xFFFF; + c16 += a16 + b16; + c32 += c16 >>> 16; + c16 &= 0xFFFF; + c32 += a32 + b32; + c48 += c32 >>> 16; + c32 &= 0xFFFF; + c48 += a48 + b48; + c48 &= 0xFFFF; + return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); + }; + + public subtract(subtrahend: any): Long { + if (!Long.isLong(subtrahend)) + subtrahend = Long.fromValue(subtrahend); + return this.add(subtrahend.neg()); + }; + + public sub = this.subtract; + + public multiply(multiplier: any): Long { + if (this.isZero()) + return Long.ZERO; + if (!Long.isLong(multiplier)) + multiplier = Long.fromValue(multiplier); + if (multiplier.isZero()) + return Long.ZERO; + if (this.eq(Long.MIN_VALUE)) + return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO; + if (multiplier.eq(Long.MIN_VALUE)) + return this.isOdd() ? Long.MIN_VALUE : Long.ZERO; + + if (this.isNegative()) { + if (multiplier.isNegative()) + return this.neg().mul(multiplier.neg()); + else + return this.neg().mul(multiplier).neg(); + } else if (multiplier.isNegative()) + return this.mul(multiplier.neg()).neg(); + + // If both longs are small, use float multiplication + if (this.lt(Long.TWO_PWR_24) && multiplier.lt(Long.TWO_PWR_24)) + return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned); + + // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products. + // We can skip products that would overflow. + + var a48 = this.high >>> 16; + var a32 = this.high & 0xFFFF; + var a16 = this.low >>> 16; + var a00 = this.low & 0xFFFF; + + var b48 = multiplier.high >>> 16; + var b32 = multiplier.high & 0xFFFF; + var b16 = multiplier.low >>> 16; + var b00 = multiplier.low & 0xFFFF; + + var c48 = 0, c32 = 0, c16 = 0, c00 = 0; + c00 += a00 * b00; + c16 += c00 >>> 16; + c00 &= 0xFFFF; + c16 += a16 * b00; + c32 += c16 >>> 16; + c16 &= 0xFFFF; + c16 += a00 * b16; + c32 += c16 >>> 16; + c16 &= 0xFFFF; + c32 += a32 * b00; + c48 += c32 >>> 16; + c32 &= 0xFFFF; + c32 += a16 * b16; + c48 += c32 >>> 16; + c32 &= 0xFFFF; + c32 += a00 * b32; + c48 += c32 >>> 16; + c32 &= 0xFFFF; + c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48; + c48 &= 0xFFFF; + return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned); + }; + + public mul = this.multiply; + + public divide(divisor: any): Long { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + if (divisor.isZero()) + throw Error('division by zero'); + if (this.isZero()) + return this.unsigned ? Long.UZERO : Long.ZERO; + var approx, rem, res; + if (!this.unsigned) { + // This section is only relevant for signed longs and is derived from the + // closure library as a whole. + if (this.eq(Long.MIN_VALUE)) { + if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE)) + return Long.MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE + else if (divisor.eq(Long.MIN_VALUE)) + return Long.ONE; + else { + // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|. + var halfThis = this.shr(1); + approx = halfThis.div(divisor).shl(1); + if (approx.eq(Long.ZERO)) { + return divisor.isNegative() ? Long.ONE : Long.NEG_ONE; + } else { + rem = this.sub(divisor.mul(approx)); + res = approx.add(rem.div(divisor)); + return res; + } + } + } else if (divisor.eq(Long.MIN_VALUE)) + return this.unsigned ? Long.UZERO : Long.ZERO; + if (this.isNegative()) { + if (divisor.isNegative()) + return this.neg().div(divisor.neg()); + return this.neg().div(divisor).neg(); + } else if (divisor.isNegative()) + return this.div(divisor.neg()).neg(); + res = Long.ZERO; + } else { + // The algorithm below has not been made for unsigned longs. It's therefore + // required to take special care of the MSB prior to running it. + if (!divisor.unsigned) + divisor = divisor.toUnsigned(); + if (divisor.gt(this)) + return Long.UZERO; + if (divisor.gt(this.shru(1))) // 15 >>> 1 = 7 ; with divisor = 8 ; true + return Long.UONE; + res = Long.UZERO; + } + + // Repeat the following until the remainder is less than other: find a + // floating-point that approximates remainder / other *from below*, add this + // into the result, and subtract it from the remainder. It is critical that + // the approximate value is less than or equal to the real value so that the + // remainder never becomes negative. + rem = this; + while (rem.gte(divisor)) { + // Approximate the result of division. This may be a little greater or + // smaller than the actual value. + approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber())); + + // We will tweak the approximate result by changing it in the 48-th digit or + // the smallest non-fractional digit, whichever is larger. + var log2 = Math.ceil(Math.log(approx) / Math.LN2), + delta = (log2 <= 48) ? 1 : Long.pow_dbl(2, log2 - 48), + + // Decrease the approximation until it is smaller than the remainder. Note + // that if it is too large, the product overflows and is negative. + approxRes = Long.fromNumber(approx), + approxRem = approxRes.mul(divisor); + while (approxRem.isNegative() || approxRem.gt(rem)) { + approx -= delta; + approxRes = Long.fromNumber(approx, this.unsigned); + approxRem = approxRes.mul(divisor); + } + + // We know the answer can't be zero... and actually, zero would cause + // infinite recursion since we would make no progress. + if (approxRes.isZero()) + approxRes = Long.ONE; + + res = res.add(approxRes); + rem = rem.sub(approxRem); + } + return res; + }; + + public div = this.divide; + + public modulo(divisor: any): Long { + if (!Long.isLong(divisor)) + divisor = Long.fromValue(divisor); + return this.sub(this.div(divisor).mul(divisor)); + }; + + public mod = this.modulo; + + public not(): Long { + return Long.fromBits(~this.low, ~this.high, this.unsigned); + }; + + public and(other: any): Long { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned); + }; + + public or(other: any): Long { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned); + }; + + public xor(other: any): Long { + if (!Long.isLong(other)) + other = Long.fromValue(other); + return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned); + }; + + public shiftLeft(numBits): Long { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned); + else + return Long.fromBits(0, this.low << (numBits - 32), this.unsigned); + }; + + public shl = this.shiftLeft; + + public shiftRight(numBits): Long { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + if ((numBits &= 63) === 0) + return this; + else if (numBits < 32) + return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned); + else + return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned); + }; + + public shr = this.shiftRight; + + public shiftRightUnsigned(numBits): Long { + if (Long.isLong(numBits)) + numBits = numBits.toInt(); + numBits &= 63; + if (numBits === 0) + return this; + else { + var high = this.high; + if (numBits < 32) { + var low = this.low; + return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned); + } else if (numBits === 32) + return Long.fromBits(high, 0, this.unsigned); + else + return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned); + } + }; + + public shru = this.shiftRightUnsigned; + + public toSigned(): Long { + if (!this.unsigned) + return this; + return Long.fromBits(this.low, this.high, false); + }; + + public toUnsigned(): Long { + if (this.unsigned) + return this; + return Long.fromBits(this.low, this.high, true); + }; +} + +Object.defineProperty(Long.prototype, '__isLong__', { + value : true, + enumerable : false, + configurable: false +}); diff --git a/transpiler/src/main/resources/jre/package.json b/transpiler/src/main/resources/jre/package.json new file mode 100644 index 0000000..e7aa891 --- /dev/null +++ b/transpiler/src/main/resources/jre/package.json @@ -0,0 +1,18 @@ +{ + "name": "@greycat/j2ts-jre", + "homepage": "https://github.com/datathings/java2typescript", + "version": "J2TS_VERSION", + "main": "jre.js", + "typings": "jre.d.ts", + "repository": { + "type": "git", + "url": "git://github.com/datathings/java2typescript.git" + }, + "bugs": { + "url": "https://github.com/datathings/java2typescript/issues" + }, + "license": "Apache-2.0", + "devDependencies": { + "typescript": "2.8.1" + } +} \ No newline at end of file diff --git a/transpiler/src/main/resources/jre/readme.md b/transpiler/src/main/resources/jre/readme.md new file mode 100644 index 0000000..051a4cb --- /dev/null +++ b/transpiler/src/main/resources/jre/readme.md @@ -0,0 +1,3 @@ +# Java2TypeScript Runtime + +This package is the required dependency for J2TS transpiler project \ No newline at end of file diff --git a/transpiler/src/main/resources/jre/tsconfig.json b/transpiler/src/main/resources/jre/tsconfig.json new file mode 100644 index 0000000..2994021 --- /dev/null +++ b/transpiler/src/main/resources/jre/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": false, + "removeComments": true, + "preserveConstEnums": true, + "sourceMap": true, + "target": "es5", + "declaration": true + }, + "files": [ + "jre.ts" + ] +} \ No newline at end of file diff --git a/transpiler/src/main/resources/junit/junit.ts b/transpiler/src/main/resources/junit/junit.ts new file mode 100755 index 0000000..fe18e22 --- /dev/null +++ b/transpiler/src/main/resources/junit/junit.ts @@ -0,0 +1,110 @@ +export namespace org { + export namespace junit { + export class Assert { + public static assertArrayEquals(p: any, p2: any) { + if (p == null || p == undefined) { + if (p2 == null || p2 == undefined) { + return; + } else { + throw new Error("Assert Error " + p + " and " + p2 + " must be equals"); + } + } + if (p2 == null || p2 == undefined) { + if (p == null || p == undefined) { + return; + } else { + throw new Error("Assert Error " + p + " and " + p2 + " must be equals"); + } + } + if (p.length != p2.length) { + throw new Error("Assert Error " + p + " and " + p2 + " must be equals"); + } + for (var i = 0; i < p.length; i++) { + if (p[i] != p2[i]) { + throw new Error("Assert Error " + p + " and " + p2 + " must be equals"); + } + } + } + + public static assertNotNull(p: any): void { + if (p == null) { + throw new Error("Assert Error " + p + " must not be null"); + } + } + + public static assertNull(p: any): void { + if (p != null) { + throw new Error("Assert Error " + p + " must be null"); + } + } + + public static assertEquals(p: any, p2: any, p3: string = ""): void { + if (p == null) { + if (p2 == null) { + return; + } else { + throw new Error("Assert Error: " + p3 + "\n" + p + "\n must be equal to \n" + p2 + "\n"); + } + } + if (p2 == null) { + if (p == null) { + return; + } else { + throw new Error("Assert Error: " + p3 + "\n" + p + "\n must be equal to \n" + p2 + "\n"); + } + } + if (p.equals !== undefined) { + if (!p.equals(p2)) { + throw new Error("Assert Error: " + p3 + "\n" + p + "\n must be equal to \n" + p2 + "\n"); + } + } else { + if (p != p2) { + throw new Error("Assert Error: " + p3 + "\n" + p + "\n must be equal to \n" + p2 + "\n"); + } + } + } + + public static assertNotEquals(p: any, p2: any, p3: string = ""): void { + if (p == null) { + if (p2 == null) { + throw new Error("Assert Error: " + p3 + "\n" + p + "\n must not be equal to \n" + p2 + "\n"); + } else { + return; + } + } + if (p2 == null) { + if (p == null) { + throw new Error("Assert Error: " + p3 + "\n" + p + "\n must not be equal to \n" + p2 + "\n"); + } else { + return; + } + } + if (p.equals !== undefined) { + if (p.equals(p2)) { + throw new Error("Assert Error: " + p3 + "\n" + p + "\n must not be equal to \n" + p2 + "\n"); + } + } else { + if (p == p2) { + throw new Error("Assert Error: " + p3 + "\n" + p + "\n must not be equal to \n" + p2 + "\n"); + } + } + } + + public static assertTrue(b: boolean): void { + if (!b) { + throw new Error("Assert Error " + b + " must be true"); + } + } + + public static assertFalse(b: boolean): void { + if (b) { + throw new Error("Assert Error " + b + " must be false"); + } + } + + public static fail(msg: string): void { + throw new Error("Assert Error \n" + msg + "\n"); + } + } + } +} diff --git a/transpiler/src/main/resources/junit/package.json b/transpiler/src/main/resources/junit/package.json new file mode 100644 index 0000000..49d0c19 --- /dev/null +++ b/transpiler/src/main/resources/junit/package.json @@ -0,0 +1,18 @@ +{ + "name": "@greycat/j2ts-junit", + "homepage": "https://github.com/datathings/java2typescript", + "version": "J2TS_VERSION", + "main": "junit.js", + "typings": "junit.d.ts", + "repository": { + "type": "git", + "url": "git://github.com/datathings/java2typescript.git" + }, + "bugs": { + "url": "https://github.com/datathings/java2typescript/issues" + }, + "license": "Apache-2.0", + "devDependencies": { + "typescript": "2.8.1" + } +} \ No newline at end of file diff --git a/transpiler/src/main/resources/junit/readme.md b/transpiler/src/main/resources/junit/readme.md new file mode 100644 index 0000000..b10c62d --- /dev/null +++ b/transpiler/src/main/resources/junit/readme.md @@ -0,0 +1,3 @@ +# Java2TypeScript JUnit + +This package is the required dependency for J2TS transpiler project \ No newline at end of file diff --git a/transpiler/src/main/resources/junit/tsconfig.json b/transpiler/src/main/resources/junit/tsconfig.json new file mode 100644 index 0000000..edec681 --- /dev/null +++ b/transpiler/src/main/resources/junit/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": false, + "removeComments": true, + "preserveConstEnums": true, + "sourceMap": true, + "target": "es5", + "declaration": true + }, + "files": [ + "junit.ts" + ] +} \ No newline at end of file diff --git a/transpiler/src/test/java/java2typescript/SourceTranslatorTest.java b/transpiler/src/test/java/java2typescript/SourceTranslatorTest.java new file mode 100755 index 0000000..e84380f --- /dev/null +++ b/transpiler/src/test/java/java2typescript/SourceTranslatorTest.java @@ -0,0 +1,313 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package java2typescript; + +import org.junit.Assert; +import org.junit.Test; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class SourceTranslatorTest { + + /* + @Test + public void freestyle() throws IOException { + + String source = "/home/duke/Documents/projects/greycat-java/greycat/greycat/src/main/java"; + String target = Paths.get("target", "generated-sources", "java2ts").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "generics"); + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + BufferedReader br = new BufferedReader(new FileReader(Paths.get("src", "test", "resources", "generics", "output.ts").toFile())); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = br.readLine()) != null) { + sb.append('\n').append(line); + } + + Assert.assertEquals( + sb.toString().substring(1), + result); + + } + */ + + @Test + public void generics() throws IOException { + + String source = Paths.get("src", "test", "java", "sources", "generics").toAbsolutePath().toString(); + String target = Paths.get("target", "generated-sources", "java2ts").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "generics"); + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + BufferedReader br = new BufferedReader(new FileReader(Paths.get("src", "test", "resources", "generics", "output.ts").toFile())); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = br.readLine()) != null) { + sb.append('\n').append(line); + } + + Assert.assertEquals( + sb.toString().substring(1), + result); + + } + + @Test + public void strings() throws IOException { + String source = Paths.get("src", "test", "java", "sources", "strings").toAbsolutePath().toString(); + String target = Paths.get("target", "generated-sources", "java2ts").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "strings"); + translator.addPackageTransform("sources.strings", ""); + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + BufferedReader br = new BufferedReader(new FileReader(Paths.get("src", "test", "resources", "strings", "output.ts").toFile())); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = br.readLine()) != null) { + sb.append('\n').append(line); + } + + Assert.assertEquals( + sb.toString().substring(1), + result); + } + + @Test + public void enums() throws IOException { + String source = Paths.get("src", "test", "java", "sources", "enums").toAbsolutePath().toString(); + String target = Paths.get("target", "generated-sources", "java2ts").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "enums"); + translator.addPackageTransform("sources.enums", ""); + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + BufferedReader br = new BufferedReader(new FileReader(Paths.get("src", "test", "resources", "enums", "output.ts").toFile())); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = br.readLine()) != null) { + sb.append('\n').append(line); + } + + Assert.assertEquals( + sb.toString().substring(1), + result); + } + + @Test + public void arrays() throws IOException { + String source = Paths.get("src", "test", "java", "sources", "arrays", "test").toAbsolutePath().toString(); + String target = Paths.get("target", "generated-sources", "java2ts").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "arrays"); + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + BufferedReader br = new BufferedReader(new FileReader(Paths.get("src", "test", "resources", "arrays", "output.ts").toFile())); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = br.readLine()) != null) { + sb.append('\n').append(line); + } + + Assert.assertEquals( + sb.toString().substring(1), + result); + } + + @Test + public void closures() throws IOException { + String source = Paths.get("src", "test", "java", "sources", "closures").toAbsolutePath().toString(); + String target = Paths.get("target", "generated-sources", "java2ts").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "closures"); + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + BufferedReader br = new BufferedReader(new FileReader(Paths.get("src", "test", "resources", "closures", "output.ts").toFile())); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = br.readLine()) != null) { + sb.append('\n').append(line); + } + + Assert.assertEquals( + sb.toString().substring(1), + result); + } + + @Test + public void baseElements() throws IOException { + String source = Paths.get("src", "test", "java", "sources", "base").toAbsolutePath().toString(); + String target = Paths.get("target", "generated-sources", "java2ts").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "base"); + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + BufferedReader br = new BufferedReader(new FileReader(Paths.get("src", "test", "resources", "base", "output.ts").toFile())); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = br.readLine()) != null) { + sb.append('\n').append(line); + } + + Assert.assertEquals( + sb.toString().substring(1), + result); + } + + @Test + public void varArgs() throws IOException { + String source = Paths.get("src", "test", "java", "sources", "varargs").toAbsolutePath().toString(); + String target = Paths.get("target", "generated-sources", "java2ts").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "varargs"); + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + BufferedReader br = new BufferedReader(new FileReader(Paths.get("src", "test", "resources", "varargs", "output.ts").toFile())); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = br.readLine()) != null) { + sb.append('\n').append(line); + } + + Assert.assertEquals( + sb.toString().substring(1), + result); + } + + @Test + public void extendClass() throws IOException { + String source = Paths.get("src", "test", "java", "sources", "extend").toAbsolutePath().toString(); + String target = Paths.get("target", "generated-sources", "java2ts").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "extend"); + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + BufferedReader br = new BufferedReader(new FileReader(Paths.get("src", "test", "resources", "extend", "output.ts").toFile())); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = br.readLine()) != null) { + sb.append('\n').append(line); + } + + Assert.assertEquals( + sb.toString().substring(1), + result); + } + + + // @Test + public void greycat_core() throws IOException { + String source = "/Users/duke/Documents/datathings/greycat/greycat/src/main/java"; + + String target = Paths.get("target", "generated-sources", "core").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "strings"); + translator.addPackageTransform("sources.strings", ""); + // Path classes = Paths.get("/Users/gnain/Sources/Kevoree-Modeling/mwDB/api/target/api-11-SNAPSHOT.jar"); + + // if(classes.toFile().exists()) { + // translator.addToClasspath(classes.toString()); + // } + + + translator.process(); + + //TODO comment + String result = translator.getCtx().toString().trim(); + System.out.println(result); + + + } + + //@Test + public void mwdb__core_test() throws IOException { + String source = "/Users/gnain/Sources/Kevoree-Modeling/mwDB/core/src/test/java"; + String target = Paths.get("target", "generated-test-sources", "test").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "test"); + translator.addPackageTransform("sources.strings", ""); + Path classes = Paths.get("/Users/gnain/Sources/Kevoree-Modeling/mwDB/api/target/api-7-SNAPSHOT.jar"); + + if (classes.toFile().exists()) { + System.out.println("DepAdded"); + translator.addToClasspath(classes.toString()); + } + + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + } + + //@Test + public void mwdb_ml() throws IOException { + String source = "/Users/gnain/Sources/Kevoree-Modeling/mwDB/plugins/ml/src/main/java"; + String target = Paths.get("target", "generated-sources", "main").toAbsolutePath().toString(); + + SourceTranslator translator = new SourceTranslator(source, target, "test"); + translator.addPackageTransform("sources.strings", ""); + Path classes = Paths.get("/Users/gnain/Sources/Kevoree-Modeling/mwDB/api/target/api-7-SNAPSHOT.jar"); + + if (classes.toFile().exists()) { + translator.addToClasspath(classes.toString()); + } + + translator.process(); + + String result = translator.getCtx().toString().trim(); + //System.out.println(result); + + } + + /* + */ + +} \ No newline at end of file diff --git a/transpiler/src/test/java/sources/arrays/test/DoubleArray.java b/transpiler/src/test/java/sources/arrays/test/DoubleArray.java new file mode 100644 index 0000000..f33978d --- /dev/null +++ b/transpiler/src/test/java/sources/arrays/test/DoubleArray.java @@ -0,0 +1,62 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.arrays.test; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; + +/** + * Created by gnain on 03/06/16. + */ +public class DoubleArray { + + public double[][] arrayD = new double[1][]; + public int[][] arrayI; + public double[][][][] arrayD2 = new double[10][9][8][7]; + + private double[][] _values; + + DoubleArray() { + this._values = new double[10][10]; + } + + public Class c; + + public void set() { + + double d = Double.POSITIVE_INFINITY; + double d2 = Double.NEGATIVE_INFINITY; + + double[][] centroids = new double[1][2]; + arrayD = new double[1][2]; + arrayI = new int[1][]; + + arrayD2 = new double[20][19][18][17]; + + boolean[] _back_colors = new boolean[10]; + } + + public void sortTest() { + int[] arr = new int[]{0, 1, 2, 3, 4}; + Arrays.sort(arr); + for (int i = 0; i < 10; i++) { + Assert.assertEquals(1., 2., 3.); + } + } + +} diff --git a/transpiler/src/test/java/sources/base/BaseElements.java b/transpiler/src/test/java/sources/base/BaseElements.java new file mode 100644 index 0000000..3e103fe --- /dev/null +++ b/transpiler/src/test/java/sources/base/BaseElements.java @@ -0,0 +1,70 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.base; + +/** + * Created by gnain on 13/09/16. + */ +public class BaseElements { + + public void printAll(int a) { + + for (int i = 0; i < 3; i++) { + System.out.println("hey !"); + } + + for (int i = 0; i < 3; i++) + System.out.println("hey !"); + + int i = 0; + while (i < 3) { + System.out.println("hey !"); + } + + do { + System.out.println("hey !"); + } while (i < 3); + + switch (i) { + case 1: + System.out.println("hey !"); + case 2: { + System.out.println("hey !"); + } + case 3: + case 4: { + System.out.println("hey !"); + } + break; + } + + if (i == 2) { + System.out.println("hey !"); + } else if (i == 3) { + System.out.println("hey !"); + } else { + System.out.println("hey !"); + } + + if (i == 2) + System.out.println("hey !"); + else + System.out.println("hey !"); + + } + + +} diff --git a/transpiler/src/test/java/sources/closures/ClosureInterface.java b/transpiler/src/test/java/sources/closures/ClosureInterface.java new file mode 100644 index 0000000..48eb160 --- /dev/null +++ b/transpiler/src/test/java/sources/closures/ClosureInterface.java @@ -0,0 +1,23 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.closures; + +/** + * Created by gnain on 10/08/16. + */ +public interface ClosureInterface { + void method(); +} diff --git a/transpiler/src/test/java/sources/closures/ClosureInterfaceWithParam.java b/transpiler/src/test/java/sources/closures/ClosureInterfaceWithParam.java new file mode 100644 index 0000000..f57ab37 --- /dev/null +++ b/transpiler/src/test/java/sources/closures/ClosureInterfaceWithParam.java @@ -0,0 +1,25 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.closures; + +/** + * Created by gnain on 10/08/16. + */ +public interface ClosureInterfaceWithParam { + + void methodParam(boolean b); + +} diff --git a/transpiler/src/test/java/sources/closures/ClosureInterfaceWithParamAndResult.java b/transpiler/src/test/java/sources/closures/ClosureInterfaceWithParamAndResult.java new file mode 100644 index 0000000..dd9bd9d --- /dev/null +++ b/transpiler/src/test/java/sources/closures/ClosureInterfaceWithParamAndResult.java @@ -0,0 +1,23 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.closures; + +/** + * Created by gnain on 10/08/16. + */ +public interface ClosureInterfaceWithParamAndResult { + boolean methodParam(boolean b); +} diff --git a/transpiler/src/test/java/sources/closures/Closures.java b/transpiler/src/test/java/sources/closures/Closures.java new file mode 100644 index 0000000..1cc27ce --- /dev/null +++ b/transpiler/src/test/java/sources/closures/Closures.java @@ -0,0 +1,69 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.closures; + +/** + * Created by gnain on 10/08/16. + */ +public class Closures { + + + private ClosureInterface ci = () -> { }; + private ClosureInterface ci2 = () -> System.out.println("super !!"); + private ClosureInterfaceWithParam cip = (b) -> {System.out.println("Another");System.out.println("super !!");}; + private ClosureInterfaceWithParamAndResult cipr = (b) -> b && true; + + + private FunctionalClosureInterface fci = () -> { }; + private FunctionalClosureInterface fci2 = () -> System.out.println("super !!"); + private FunctionalClosureInterfaceWithParam fcip = (b) -> {System.out.println("Another");System.out.println("super !!");}; + private FunctionalClosureInterfaceWithParamAndResult fcipr = (b) -> b && true; + + + public Closures() { + + this.localMethod(bool->bool); + this.localMethod(bool->{return bool;}); + this.localMethod((bool)->{return bool;}); + this.localMethod(((bool)->{return bool;})); + this.localMethod2(bool->bool, true); + + + + this.functionalLocalMethod(bool->bool); + this.functionalLocalMethod(bool->{return bool;}); + this.functionalLocalMethod((bool)->{return bool;}); + this.functionalLocalMethod(((bool)->{return bool;})); + this.functionalLocalMethod2(bool->bool, true); + } + + + private void localMethod(ClosureInterfaceWithParamAndResult clos) { + clos.methodParam(false); + } + + private void localMethod2(ClosureInterfaceWithParamAndResult clos, boolean c) { + clos.methodParam(false); + } + + private void functionalLocalMethod(FunctionalClosureInterfaceWithParamAndResult clos) { + clos.methodParam(false); + } + + private void functionalLocalMethod2(FunctionalClosureInterfaceWithParamAndResult clos, boolean c) { + clos.methodParam(false); + } +} diff --git a/transpiler/src/test/java/sources/closures/FunctionalClosureInterface.java b/transpiler/src/test/java/sources/closures/FunctionalClosureInterface.java new file mode 100644 index 0000000..c617cc1 --- /dev/null +++ b/transpiler/src/test/java/sources/closures/FunctionalClosureInterface.java @@ -0,0 +1,24 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.closures; + +/** + * Created by gnain on 10/08/16. + */ +@FunctionalInterface +public interface FunctionalClosureInterface { + void method(); +} diff --git a/transpiler/src/test/java/sources/closures/FunctionalClosureInterfaceWithParam.java b/transpiler/src/test/java/sources/closures/FunctionalClosureInterfaceWithParam.java new file mode 100644 index 0000000..d6236f0 --- /dev/null +++ b/transpiler/src/test/java/sources/closures/FunctionalClosureInterfaceWithParam.java @@ -0,0 +1,26 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.closures; + +/** + * Created by gnain on 10/08/16. + */ +@FunctionalInterface +public interface FunctionalClosureInterfaceWithParam { + + void methodParam(boolean b); + +} diff --git a/transpiler/src/test/java/sources/closures/FunctionalClosureInterfaceWithParamAndResult.java b/transpiler/src/test/java/sources/closures/FunctionalClosureInterfaceWithParamAndResult.java new file mode 100644 index 0000000..bc76051 --- /dev/null +++ b/transpiler/src/test/java/sources/closures/FunctionalClosureInterfaceWithParamAndResult.java @@ -0,0 +1,24 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.closures; + +/** + * Created by gnain on 10/08/16. + */ +@FunctionalInterface +public interface FunctionalClosureInterfaceWithParamAndResult { + boolean methodParam(boolean b); +} diff --git a/transpiler/src/test/java/sources/enums/TestEnum.java b/transpiler/src/test/java/sources/enums/TestEnum.java new file mode 100644 index 0000000..d479371 --- /dev/null +++ b/transpiler/src/test/java/sources/enums/TestEnum.java @@ -0,0 +1,25 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.enums; + +/** + * Created by Gregory NAIN on 16/03/17. + */ +public enum TestEnum { + + VALUE1, VALUE2, VALUE_A + +} diff --git a/transpiler/src/test/java/sources/extend/ExClass.java b/transpiler/src/test/java/sources/extend/ExClass.java new file mode 100644 index 0000000..a501369 --- /dev/null +++ b/transpiler/src/test/java/sources/extend/ExClass.java @@ -0,0 +1,30 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.extend; + + +/** + * {@extend ts + * sayHello(){ console.log("hello"); } + * } + */ +public class ExClass { + + public final String getHello() { + return "hello"; + } + +} diff --git a/transpiler/src/test/java/sources/generics/MyArrayList.java b/transpiler/src/test/java/sources/generics/MyArrayList.java new file mode 100755 index 0000000..608e363 --- /dev/null +++ b/transpiler/src/test/java/sources/generics/MyArrayList.java @@ -0,0 +1,39 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.generics; + +public class MyArrayList implements MyList { + + @Override + public void add(E elem) { + + } + + @Override + public void add(int index, E elem) { + + } + + @Override + public void remove(E elem) { + + } + + @Override + public void remove(int index) { + + } +} diff --git a/transpiler/src/test/java/sources/generics/MyHashMap.java b/transpiler/src/test/java/sources/generics/MyHashMap.java new file mode 100755 index 0000000..8eddf9a --- /dev/null +++ b/transpiler/src/test/java/sources/generics/MyHashMap.java @@ -0,0 +1,34 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.generics; + +public class MyHashMap implements MyMap { + + @Override + public void put(K key, V value) { + + } + + @Override + public V get(K key) { + return null; + } + + @Override + public void remove(K key) { + + } +} diff --git a/transpiler/src/test/java/sources/generics/MyList.java b/transpiler/src/test/java/sources/generics/MyList.java new file mode 100755 index 0000000..b05075f --- /dev/null +++ b/transpiler/src/test/java/sources/generics/MyList.java @@ -0,0 +1,24 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.generics; + +public interface MyList { + + void add(E elem); + void add(int index, E elem); + void remove(E elem); + void remove(int index); +} \ No newline at end of file diff --git a/transpiler/src/test/java/sources/generics/MyMap.java b/transpiler/src/test/java/sources/generics/MyMap.java new file mode 100755 index 0000000..b4a4099 --- /dev/null +++ b/transpiler/src/test/java/sources/generics/MyMap.java @@ -0,0 +1,23 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.generics; + +public interface MyMap { + + void put(K key, V value); + V get(K key); + void remove(K key); +} \ No newline at end of file diff --git a/transpiler/src/test/java/sources/generics/UseGeneric.java b/transpiler/src/test/java/sources/generics/UseGeneric.java new file mode 100755 index 0000000..614a0c6 --- /dev/null +++ b/transpiler/src/test/java/sources/generics/UseGeneric.java @@ -0,0 +1,34 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.generics; + +public class UseGeneric { + + MyList strList; + MyMap map; + + public UseGeneric() { + this.strList = new MyArrayList<>(); + this.map = new MyHashMap<>(); + } + + public void arrayAsGenType(MyList list) { + } + + public static int LEVELA = 0; + public static int LEVELB = LEVELA; + public static String LEVEL = new String("" + LEVELA); +} diff --git a/transpiler/src/test/java/sources/strings/ClassFields.java b/transpiler/src/test/java/sources/strings/ClassFields.java new file mode 100755 index 0000000..220051c --- /dev/null +++ b/transpiler/src/test/java/sources/strings/ClassFields.java @@ -0,0 +1,22 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.strings; + +public class ClassFields { + String str = new String("foo"); + String str2 = String.join(", ", new String[]{"a", "b", "c"}); + public String[] values = new String[0]; +} \ No newline at end of file diff --git a/transpiler/src/test/java/sources/strings/InFunction.java b/transpiler/src/test/java/sources/strings/InFunction.java new file mode 100755 index 0000000..428fea6 --- /dev/null +++ b/transpiler/src/test/java/sources/strings/InFunction.java @@ -0,0 +1,55 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.strings; + +public class InFunction { + + private String str; + private String str2; + + public void foo() { + String str = new String("foo"); + String str2 = String.join(", ", new String[] { "a", "b", "c" }); + String str3 = str2.trim(); + } + + public void bar() { + this.str = this.str2.concat(this.str); + String s = getString(); + String s2 = getString().replace('o', 'a'); + String s3 = this.getF().getF().getString(); + + s3.startsWith("a"); + + String[] tt = new String[]{"f1", "f2"}; + essay(new String[]{"f1", "f2"}); + + } + + public String getString() { + return "potato"; + } + + public InFunction getF() { + return this; + } + + + public void essay(String[] res) { + + } + +} \ No newline at end of file diff --git a/transpiler/src/test/java/sources/strings/Primitive.java b/transpiler/src/test/java/sources/strings/Primitive.java new file mode 100755 index 0000000..99f413c --- /dev/null +++ b/transpiler/src/test/java/sources/strings/Primitive.java @@ -0,0 +1,54 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.strings; + +public class Primitive { + + String s = "a" + "b" + "c"; + static String s2 = "a" + "b" + "c"; + + private static Primitive p = newPrim(); + + private static Primitive newPrim() { + Primitive p = new Primitive(); + if(s2 instanceof String) { + s2 = s2 + "d"; + } + return p; + } + + + /** + * {@native ts + * return "bbb"; + * } + */ + public String funct(String t) { + return "aaa"; + } + + + /** + * @native ts + * return "bbbb"; + */ + public String funct2(String y) { + return "aaaa"; + } + + + +} diff --git a/transpiler/src/test/java/sources/varargs/MyClass.java b/transpiler/src/test/java/sources/varargs/MyClass.java new file mode 100644 index 0000000..b739201 --- /dev/null +++ b/transpiler/src/test/java/sources/varargs/MyClass.java @@ -0,0 +1,47 @@ +/** + * Copyright 2017 The Java2TypeScript Authors. All rights reserved. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sources.varargs; + +/** + * Created by gnain on 06/12/16. + */ +public class MyClass { + + + private String[] args; + + MyClass(String ...cargs) { + this.args = cargs; + } + + public void tt() { + MyClass c = new MyClass(args); + c.tt2(args); + String[] newArgs = new String[]{"a", "b"}; + c.tt2(newArgs); + c.tt2(createVarArgs()); + } + + public void tt2(String... its) { + + } + + public String[] createVarArgs() { + return new String[0]; + } + + +} diff --git a/transpiler/src/test/resources/arrays/output.ts b/transpiler/src/test/resources/arrays/output.ts new file mode 100644 index 0000000..07c8983 --- /dev/null +++ b/transpiler/src/test/resources/arrays/output.ts @@ -0,0 +1,44 @@ +export class DoubleArray { + public arrayD: Array = new Array(1); + public arrayI: Array; + public arrayD2: Array>> = new Array>>(10); + private _values: Array; + public c: any; + constructor() { + this._values = new Array(10); + for(let _values_d1 = 0; _values_d1 < 10; _values_d1++){ + this._values[_values_d1] = new Float64Array(10); + }; + } + public set(): void { + let d: number = java.lang.Double.POSITIVE_INFINITY; + let d2: number = java.lang.Double.NEGATIVE_INFINITY; + let centroids: Array = new Array(1); + for(let centroids_d1 = 0; centroids_d1 < 1; centroids_d1++){ + centroids[centroids_d1] = new Float64Array(2); + }; + this.arrayD = new Array(1); + for(let arrayD_d1 = 0; arrayD_d1 < 1; arrayD_d1++){ + this.arrayD[arrayD_d1] = new Float64Array(2); + }; + this.arrayI = new Array(1); + this.arrayD2 = new Array>>(20); + for(let arrayD2_d1 = 0; arrayD2_d1 < 20; arrayD2_d1++){ + this.arrayD2[arrayD2_d1] = new Array>(19); + for(let arrayD2_d2 = 0; arrayD2_d2 < 19; arrayD2_d2++){ + this.arrayD2[arrayD2_d1][arrayD2_d2] = new Array(18); + for(let arrayD2_d3 = 0; arrayD2_d3 < 18; arrayD2_d3++){ + this.arrayD2[arrayD2_d1][arrayD2_d2][arrayD2_d3] = new Float64Array(17); + } + } + }; + let _back_colors: boolean[] = []; + } + public sortTest(): void { + let arr: Int32Array = new Int32Array([0, 1, 2, 3, 4]); + arr.sort(); + for (let i: number = 0; i < 10; i++) { + junit.Assert.assertEquals(2.,3.,1.); + } + } +} \ No newline at end of file diff --git a/transpiler/src/test/resources/base/output.ts b/transpiler/src/test/resources/base/output.ts new file mode 100644 index 0000000..7ce13db --- /dev/null +++ b/transpiler/src/test/resources/base/output.ts @@ -0,0 +1,41 @@ +export class BaseElements { + public printAll(a: number): void { + for (let i: number = 0; i < 3; i++) { + console.log("hey !"); + } + for (let i: number = 0; i < 3; i++) + console.log("hey !"); + + let i: number = 0; + while (i < 3) { + console.log("hey !"); + } + do { + console.log("hey !"); + } while (i < 3); + switch (i) { + case 1: + console.log("hey !"); + case 2: { + console.log("hey !"); + } + case 3: + case 4: { + console.log("hey !"); + }break; + } + if (i == 2) { + console.log("hey !"); + } else if (i == 3) { + console.log("hey !"); + } else { + console.log("hey !"); + } + + if (i == 2) + console.log("hey !"); + else + console.log("hey !"); + + } +} \ No newline at end of file diff --git a/transpiler/src/test/resources/closures/output.ts b/transpiler/src/test/resources/closures/output.ts new file mode 100644 index 0000000..329aa15 --- /dev/null +++ b/transpiler/src/test/resources/closures/output.ts @@ -0,0 +1,72 @@ +export interface ClosureInterface { + method(): void; +} +export interface ClosureInterfaceWithParam { + methodParam(b: boolean): void; +} +export interface ClosureInterfaceWithParamAndResult { + methodParam(b: boolean): boolean; +} +export class Closures { + private ci: ()=>void = ()=>{ + }; + private ci2: ()=>void = ()=>(console.log("super !!")); + private cip: (b: boolean)=>void = (b)=>{ + console.log("Another"); + console.log("super !!"); + }; + private cipr: (b: boolean)=>boolean = (b)=>(b && true); + private fci: ()=>void = ()=>{ + }; + private fci2: ()=>void = ()=>(console.log("super !!")); + private fcip: (b: boolean)=>void = (b)=>{ + console.log("Another"); + console.log("super !!"); + }; + private fcipr: (b: boolean)=>boolean = (b)=>(b && true); + constructor() { + this.localMethod((() => {let r:any=()=>{};r.methodParam=(bool)=>(bool);return r;})()); + this.localMethod((() => {let r:any=()=>{};r.methodParam=(bool)=>{ + return bool; + };return r;})()); + this.localMethod((() => {let r:any=()=>{};r.methodParam=(bool)=>{ + return bool; + };return r;})()); + this.localMethod(((() => {let r:any=()=>{};r.methodParam=(bool)=>{ + return bool; + };return r;})())); + this.localMethod2((() => {let r:any=()=>{};r.methodParam=(bool)=>(bool);return r;})(), true); + this.functionalLocalMethod((bool)=>(bool)); + this.functionalLocalMethod((bool)=>{ + return bool; + }); + this.functionalLocalMethod((bool)=>{ + return bool; + }); + this.functionalLocalMethod(((bool)=>{ + return bool; + })); + this.functionalLocalMethod2((bool)=>(bool), true); + } + private localMethod(clos: ClosureInterfaceWithParamAndResult): void { + clos.methodParam(false); + } + private localMethod2(clos: ClosureInterfaceWithParamAndResult, c: boolean): void { + clos.methodParam(false); + } + private functionalLocalMethod(clos: FunctionalClosureInterfaceWithParamAndResult): void { + clos(false); + } + private functionalLocalMethod2(clos: FunctionalClosureInterfaceWithParamAndResult, c: boolean): void { + clos(false); + } +} +export interface FunctionalClosureInterface { + (): void; +} +export interface FunctionalClosureInterfaceWithParam { + (b: boolean): void; +} +export interface FunctionalClosureInterfaceWithParamAndResult { + (b: boolean): boolean; +} \ No newline at end of file diff --git a/transpiler/src/test/resources/enums/output.ts b/transpiler/src/test/resources/enums/output.ts new file mode 100644 index 0000000..4692ed1 --- /dev/null +++ b/transpiler/src/test/resources/enums/output.ts @@ -0,0 +1,3 @@ +export enum TestEnum { + VALUE1, VALUE2, VALUE_A +} \ No newline at end of file diff --git a/transpiler/src/test/resources/extend/output.ts b/transpiler/src/test/resources/extend/output.ts new file mode 100644 index 0000000..f8aea08 --- /dev/null +++ b/transpiler/src/test/resources/extend/output.ts @@ -0,0 +1,6 @@ +export class ExClass { + public getHello(): string { + return "hello"; + } + sayHello(){ console.log("hello"); } +} \ No newline at end of file diff --git a/transpiler/src/test/resources/generics/output.ts b/transpiler/src/test/resources/generics/output.ts new file mode 100755 index 0000000..3bcea9b --- /dev/null +++ b/transpiler/src/test/resources/generics/output.ts @@ -0,0 +1,36 @@ +export class MyArrayList implements MyList { + public add(elem: E): void {} + public add(index: number, elem: E): void {} + public remove(elem: E): void {} + public remove(index: number): void {} +} +export class MyHashMap implements MyMap { + public put(key: K, value: V): void {} + public get(key: K): V { + return null; + } + public remove(key: K): void {} +} +export interface MyList { + add(elem: E): void; + add(index: number, elem: E): void; + remove(elem: E): void; + remove(index: number): void; +} +export interface MyMap { + put(key: K, value: V): void; + get(key: K): V; + remove(key: K): void; +} +export class UseGeneric { + public strList: MyList; + public map: MyMap; + public static LEVELA: number = 0; + public static LEVELB: number = UseGeneric.LEVELA; + public static LEVEL: string = "" + UseGeneric.LEVELA; + constructor() { + this.strList = new MyArrayList(); + this.map = new MyHashMap(); + } + public arrayAsGenType(list: MyList): void {} +} \ No newline at end of file diff --git a/transpiler/src/test/resources/strings/output.ts b/transpiler/src/test/resources/strings/output.ts new file mode 100755 index 0000000..050c965 --- /dev/null +++ b/transpiler/src/test/resources/strings/output.ts @@ -0,0 +1,48 @@ +export class ClassFields { + public str: string = "foo"; + public str2: string = java.lang.String.join(", ", ["a", "b", "c"]); + public values: string[] = new Array(0); +} +export class InFunction { + private str: string; + private str2: string; + public foo(): void { + let str: string = "foo"; + let str2: string = java.lang.String.join(", ", ["a", "b", "c"]); + let str3: string = str2.trim(); + } + public bar(): void { + this.str = this.str2 + this.str; + let s: string = this.getString(); + let s2: string = this.getString().replace('o', 'a'); + let s3: string = this.getF().getF().getString(); + (s3.lastIndexOf("a", 0) === 0); + let tt: string[] = ["f1", "f2"]; + this.essay(["f1", "f2"]); + } + public getString(): string { + return "potato"; + } + public getF(): InFunction { + return this; + } + public essay(res: string[]): void {} +} +export class Primitive { + public s: string = "a" + "b" + "c"; + public static s2: string = "a" + "b" + "c"; + private static p: Primitive = Primitive.newPrim(); + private static newPrim(): Primitive { + let p: Primitive = new Primitive(); + if (typeof(Primitive.s2) === "string") { + Primitive.s2 = Primitive.s2 + "d"; + } + return p; + } + public funct(t: string): string { + return "bbb"; + } + public funct2(y: string): string { + return "bbbb"; + } +} \ No newline at end of file diff --git a/transpiler/src/test/resources/varargs/output.ts b/transpiler/src/test/resources/varargs/output.ts new file mode 100644 index 0000000..bb70e51 --- /dev/null +++ b/transpiler/src/test/resources/varargs/output.ts @@ -0,0 +1,17 @@ +export class MyClass { + private args: string[]; + constructor(...cargs: string[]) { + this.args = cargs; + } + public tt(): void { + let c: sources.varargs.MyClass = new sources.varargs.MyClass(...this.args); + c.tt2(...this.args); + let newArgs: string[] = ["a", "b"]; + c.tt2(...newArgs); + c.tt2(...this.createVarArgs()); + } + public tt2(...its: string[]): void {} + public createVarArgs(): string[] { + return new Array(0); + } +} \ No newline at end of file