master 2535780bdb31 cached
18 files
337.5 KB
87.2k tokens
71 symbols
1 requests
Download .txt
Showing preview only (349K chars total). Download the full file or copy to clipboard to get everything.
Repository: emacs-typescript/typescript.el
Branch: master
Commit: 2535780bdb31
Files: 18
Total size: 337.5 KB

Directory structure:
gitextract_b8dm76p3/

├── .github/
│   └── workflows/
│       └── build.yml
├── .gitignore
├── Dockerfile
├── Eask
├── LICENSE
├── Makefile
├── README.md
├── test-files/
│   ├── indentation-reference-document.ts
│   ├── list-items-indent-comma-first.ts
│   ├── list-items-indent-default.ts
│   ├── switch-case-indent-default.ts
│   └── switch-case-indent-disabled.ts
├── typescript-mode-general-tests.el
├── typescript-mode-jsdoc-tests.el
├── typescript-mode-lexical-binding-tests.el
├── typescript-mode-test-utilities.el
├── typescript-mode-tests.el
└── typescript-mode.el

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/workflows/build.yml
================================================
name: Build & Test

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        experimental: [false]
        emacs-version: [26.3, 27.2, 28.2, 29.4, 30.2]
        include:
        - emacs-version: snapshot
          experimental: true
          os: ubuntu-latest
        - emacs-version: snapshot
          experimental: true
          os: windows-latest
    continue-on-error: ${{ matrix.experimental }}

    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v6

      - uses: jcs090218/setup-emacs@master
        with:
          version: ${{ matrix.emacs-version }}

      - uses: emacs-eask/setup-eask@master
        with:
          version: 'snapshot'

      - name: Run a multi-line script
        run: |
          emacs --version
          make build
          make test


================================================
FILE: .gitignore
================================================

# Created by https://www.gitignore.io/api/emacs,windows,linux

### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*

# Org-mode
.org-id-locations
*_archive

# flymake-mode
*_flymake.*

# eshell files
/eshell/history
/eshell/lastdir

# elpa packages
/elpa/

# reftex files
*.rel

# AUCTeX auto folder
/auto/

# eask packages
.eask/
dist/

# Flycheck
flycheck_*.el

# server auth directory
/server/

# projectiles files
.projectile

# directory configuration
.dir-locals.el

### Linux ###

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/emacs,windows,linux

# ELPA-generated files.
/typescript-mode-autoloads.el
/typescript-mode-pkg.el


================================================
FILE: Dockerfile
================================================
FROM ubuntu:bionic

RUN apt-get update && \
  apt-get install -y \
  make curl python git emacs

RUN curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python
ENV PATH="/root/.cask/bin:${PATH}"

RUN mkdir -p /typescript-mode
COPY . /typescript-mode
WORKDIR /typescript-mode

CMD ["make", "test"]


================================================
FILE: Eask
================================================
(package "typescript-mode"
         "0.4"
         "Major mode for editing typescript")

(website-url "http://github.com/ananthakumaran/typescript.el")
(keywords "typescript" "languages")

(package-file "typescript-mode.el")

(files "*.el")

(source "gnu")
(source "melpa")

(depends-on "emacs" "24.3")

(setq network-security-level 'low)  ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 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 <http://www.gnu.org/licenses/>.

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:

    <program>  Copyright (C) <year>  <name of author>
    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
<http://www.gnu.org/licenses/>.

  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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.


================================================
FILE: Makefile
================================================
EMACS ?= emacs
EASK ?= eask
ELS = \
  typescript-mode.el \
  typescript-mode-test-utilities.el \
  typescript-mode-general-tests.el \
  typescript-mode-jsdoc-tests.el \
  typescript-mode-tests.el
ELCS = $(ELS:.el=.elc)

clean:
	rm -f $(ELCS)

build: clean
	$(EASK) compile

test:
	+ $(EMACS) -Q -batch -L . -l typescript-mode-tests.el -f ert-run-tests-batch-and-exit

# end


================================================
FILE: README.md
================================================
# typescript.el

![Build & Test](https://github.com/emacs-typescript/typescript.el/workflows/Build%20&%20Test/badge.svg)
[![MELPA](https://melpa.org/packages/typescript-mode-badge.svg)](https://melpa.org/#/typescript-mode)
[![MELPA Stable](https://stable.melpa.org/packages/typescript-mode-badge.svg)](https://stable.melpa.org/#/typescript-mode)

`typescript.el` is a major-mode for editing [Typescript](http://www.typescriptlang.org/)-files in [GNU Emacs](https://www.gnu.org/software/emacs/).

`typescript.el` is a self-contained, lightweight and minimalist major-mode
focused on providing basic font-lock/syntax-highlighting and
indentation for Typescript syntax, without any external dependencies.

Output from `tsc` and `tslint` is also handled seamlessly through
`compilation-mode`.

## A short note on development HALT

As the both the JavaScript and TypeScript languages have evolved to become ever more complex, so has the
Elisp codebase for `typescript-mode` trying to correctly handle them.

We've been at the point for quite some time where it has become increasingly obvious that the current code-base
simply cannot continue growing. It will be slow. It will be complex. It will be buggy. It will be head-ache inducing
to wrap our heads around it, and ... I guess we're already there.

Apart from occasional PRs getting merged, the current `typescript-mode` code isn't being developed because almost nobody
wants to work code of this complexity.

*Essentially all major development of `typescript-mode` has come to a halt.*

## Good news though!

Emacs 29 will ship with support for a parser-library called tree-sitter, and will actually have in-tree
support for TypeScript!  So now you can just use the provided `typescript-ts-mode` and get
better support for TypeScript than `typescript.el` ever provided. This new mode also supports TSX.

Development of TypeScript-support will from now on continue in Emacs core, rather than this repo.
We hope you'll like the new experience.

# Installation

`typescript.el` can be installed from source directly using your
favourite approach or framework, or from MELPA and MELPA Stable as a
package.

To install typescript.el simply type `M-x package-install<RET>typescript-mode<RET>`.

# Customization

To customize `typescript.el` just type the following: `M-x customize-group<RET>typescript<RET>`.

You can add any other customization you like to `typescript-mode-hook`
in your `init.el` file. `typescript.el` also handles `prog-mode-hook`
on versions of Emacs which supports it.

# Support for Compilation Mode

This mode automatically adds support for `compilation-mode` so that if
you run `M-x compile<ret>tsc<ret>` the error messages are correctly
parsed.

However, the error messages produced by `tsc` when its `pretty` flag
is turned on include ANSI color escapes, which by default
`compilation-mode` does not interpret. In order to get the escapes
parsed, you can use:

```elisp
(require 'ansi-color)
(defun colorize-compilation-buffer ()
  (ansi-color-apply-on-region compilation-filter-start (point-max)))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
```

Or, if you prefer, you can configure `tsc` with the `pretty` flag set
to `false`: `tsc --pretty false`. However, doing this does more than
just turning off the colors. It also causes `tsc` to produce less
elaborate error messages.

# Contributing

To run the tests you can run `make test`.

If you prefer, you may run the tests via the provided `Dockerfile`.

```bash
docker build -t typescript-mode .
docker run --rm -v $(pwd):/typescript-mode typescript-mode
```

# Other Typescript-packages of interest

While `typescript.el` may *not* provide a full kitchen-sink, the good
news is that there's other packages which do!

More advanced features can be provided by using these additional
packages:

* [lsp-mode](https://github.com/emacs-lsp/lsp-mode) - A standards-based
  code-completion and refactoring backend, based on the
  [Language Server Protocol (LSP)](https://langserver.org/).

* [tide](https://github.com/ananthakumaran/tide/) - TypeScript
  Interactive Development Environment for Emacs
* [ts-comint](https://github.com/josteink/ts-comint) - a Typescript REPL
  in Emacs.

Initializing these with `typescript.el` will then become a matter of
creating your own `typescript-mode-hook` in your `init.el` file.


================================================
FILE: test-files/indentation-reference-document.ts
================================================
/// <reference types="node" />
/// <reference path="shared.ts" />
/// <reference path="session.ts" />
// used in fs.writeSync
/* tslint:disable:no-null-keyword */

/*
 * this file is a butchered copy of TypeScript's tsserver.ts file
 * made to contain the most important syntactical elements
 * of TypeScript to verify indentation-code.
 *
 * It will not build, and that's NOT a problem!
 */

// namespaces indent.
namespace ts.server {

    const net: {
        connect(options: { port: number }, onConnect?: () => void): NodeSocket
    } = require("net");

    // functions indent.
    function getGlobalTypingsCacheLocation() {
        const obj = {
            case: 1,
            default: 2
        };
    }

    // interfaces and classes indent.
    interface NodeChildProcess {
        send(message: any, sendHandle?: any): void;
        on(message: "message" | "exit", f: (m: any) => void): void;
        kill(): void;
        pid: number;
    }

    export type SomeType = string | number;

    class Logger implements ts.server.Logger {
        private firstInGroup = true;

        // parameter-lists are currently not indented like tsserver wants it to...
        // constructor(private readonly logFilename: string,
        //     private readonly traceToConsole: boolean,
        //     private readonly level: LogLevel) {
        // }

        // function-typed class-members indent.
        constructor(private readonly logFilename: string) {
            console.log("yes");
        }

        static padStringRight(str: string, padding: string) {
            return (str + padding).slice(0, padding.length);
        }

        close() {
            if (this.fd >= 0) {
                fs.close(this.fd);
            }
        }
    }

    // object initialization/parameter-lists indent.
    const ioSession = new IOSession(
        sys,
        cancellationToken,
        eventPort,
        /*canUseEvents*/ eventPort === undefined,
        useSingleInferredProject,
        disableAutomaticTypingAcquisition,
        getGlobalTypingsCacheLocation(),
        telemetryEnabled,
        logger);
    process.on("uncaughtException", function (err: Error) {
        ioSession.logError(err, "unknown");
    });

    // Generators as methods.
    class WithAGeneratorFirst {
        *blah() {
        }
    }

    class WithAGeneratorAfterAProperty {
        public foo: string = "1";

        *blah() {
        }
    }

    class WithAGeneratorAfterAnotherMethod {
        foo() {
        }

        *blah() {
        }
    }

    class WithSpaceAfterAsterisk  {
        bar() {
        }

        * oops() {
        }
    }


    class WithSpaceAfterParens  {
        bar() {
        }

        *oops () {
        }
    }

    class WithArguments  {
        bar() {
        }

        *oops(foo: number, bar: string) {
        }
    }

    // Some continued expressions
    {
        const a = 1 *
            2 /
            3 +
            4 -
            5 %
            6;

        const b = 1 >
            2;

        const c = 1 <
            2;

        const d = 1 &
            2 |
            3;

        const e = b ?
            2 :
            3;

        const e2 = b ?
            { a: 1 } :
            3;

        const f = window
            .document;

        const g = f
            instanceof Object;

        const h = "q"
            in [1, 2];

    }

    {
        // Object with fields that are keyword names.
        const a = {
            in: 1,
            IN: 1,
            instanceof: 1,
            instanceOf: 1,
        };

        // Objects with methods that are keyword names.  At the top of
        // the object declaration, and after a function declaration.
        class One {
            instanceOf(): void {
            }

            in(): void {}
        }

        // After a field declaration.
        class Two {
            foo: boolean = true;

            instanceOf(): void {
            }
        }
    }

    // Spread syntax
    {
        const a = { a: 1, b: 2 };
        const b = {
            ...a,
            a: 3,
        };
        const c = [1, 2];
        const d = [
            "a",
            ...c
        ];

        function foo(a: string,
                     b: number,
                     ...rest: any[]) {
        }
    }

    {
        // Regular expressions in lists.

        // List objects...
        const a = [
            /abc/,
            /def/
        ];

        const z =
            /abcd/;

        // Argument lists...
        function foo(a: RegExp, b: RegExp): void {
        }

        foo(
            /abc/,
            /def/);
    }
}

// Tests for return value annotations.

// Unannotated.
function moo(x: any,
             f: string) {
    return null;
}

// No parens around return type.
function moo2(x: any,
              f: string): (a: number) => void {
    return null;
}

// Parens around return type.
function foo(x: any,
             f: string): ((a: number) => void) {
    return null;
}

class Moo {}

// Type guard.
function foo2(x: any,
              f: string): x is Moo {
    return x.something === 1;
}

// Usage of generic in return type.
function foo3(a: number,
              b: number): Array<Array<(a: number) => void>> {
    return [];
}

// Curly brackets in return type.
function bar(a: number,
             b: number): { z(): string } {
    return {
        z() { return "a"; }
    };
}

// The sequence ): in the return type.
function bif(a: number,
             b: number): "abc):d" {
    return "abc):d";
}

// Generic and union in return type. This case was constructed from
// a specific bug in the indentation code.
function bif2(a: number,
              b: number): Array<number> | number {
    return 1;
}

// Array shorthand.
function bif3(a: number,
              b: number): number[] {
    return [1];
}

// Array shorthand in union.
function bif4(a: number,
              b: number): number[] | number {
    return [1];
}

// Array shorthand in union, with spaces.
function bif5(a: number,
              b: number): number[   ] | number {
    return [1];
}

// Comment where the return type would appear.
function gogo(a: number,
              b: number) /* foo */ {
}

// Function call in the list of arguments.
function foo5(x: any,
              f: string = bif(1, 2)): ((a: number) => void) {
    return null;
}

// Dotted name in return type.
function foo6(x: any,
              f: number): ts.server.SomeType {
    return "string";
}

// First parameter has function signature.
function foo7(x: (a: string, b: string) => Array<number>,
              b: number): void {
}

// Second parameter has function signature.
function foo7b(a: string,
               x: (a: number, b: number) => Array<number>): void {
}

function foo8(): void {
    // Arrow function in first parameter.
    foo7((a: string): Array<number> => {
        return [1];
    },
         1);

    // Arrow function in first parameter, line break in parameters.
    foo7((a: string,
          b: string): Array<number> => {
        return [1];
    },
         1);

    // Arrow function in second parameter.
    foo7b("1",
          (a: number, b: number): Array<number> => {
              return [1];
          });

    // Arrow function in second parameter, line break in parameters.
    foo7b("1",
          (a: number,
           b: number): Array<number> => {
              return [1];
          });
}

// Arrow function assignment, line break in parameters.
const foo9 = (a: string,
              b: string): Array<number> => {
    return [1];
}

// Arrow function assignment.
const foo10 = (a: string, b: string): Array<number> => {
    return [1];
}

// Arrow function assignment, parenthesized.
const foo11 = ((a: string, b: string): Array<number> => {
    return [1];
});

function foo12(): void {
    // Function in first parameter.
    foo7(function (a: string): Array<number> {
        return [1];
    },
         1);

    // Function in first parameter, line break in parameters.
    foo7(function (a: string,
                   b: string): Array<number> {
        return [1];
    },
         1);

    // Arrow function in second parameter.
    foo7b("1",
          function (a: number, b: number): Array<number> {
              return [1];
          });

    // Arrow function in second parameter, line break in parameters.
    foo7b("1",
          function (a: number,
                    b: number): Array<number> {
              return [1];
          });

    // Same cases as above but named.

    // Function in first parameter.
    foo7(function _mip(a: string): Array<number> {
        return [1];
    },
         1);

    // Function in first parameter, line break in parameters.
    foo7(function _mip(a: string,
                       b: string): Array<number> {
        return [1];
    },
         1);

    // Arrow function in second parameter.
    foo7b("1",
          function _mip(a: number, b: number): Array<number> {
              return [1];
          });

    // Arrow function in second parameter, line break in parameters.
    foo7b("1",
          function _mip(a: number,
                        b: number): Array<number> {
              return [1];
          });

    // Same cases as above but generators.

    // Function in first parameter.
    foo7(function *(a: string): Array<number> {
        return [1];
    },
         1);

    // Function in first parameter, line break in parameters.
    foo7(function *(a: string,
                    b: string): Array<number> {
        return [1];
    },
         1);

    // Arrow function in second parameter.
    foo7b("1",
          function *(a: number, b: number): Array<number> {
              return [1];
          });

    // Arrow function in second parameter, line break in parameters.
    foo7b("1",
          function *(a: number,
                     b: number): Array<number> {
              return [1];
          });

    // Check that JavaScript objects are still handled right. Whether
    // in the 1st or subsequent position of a call.
    function smurf(a: {}, b: {}) {}
    smurf({
        a: {},
    },
          {
        a: {},
    });

    smurf({
        a: {},
    }, {
        a: {},
    });
}

// Number literals in the return type annotation.
function foo13(something: string,
               somethingElse: string): 0b1 | 0 | -1 | 0o2 | 0x3f {
    return 0;
}

// No spaces between numbers and type union symbols. (Also changed the
// notation to uppercase where possible.)
function foo14(something: string,
               somethingElse: string): 0B1|0|-1|0O2|0X3F {
    return 0;
}

const a =
    1; // Blah
const b = 2;

function blipblop(): void {
    {
        const q = 1;
    }
}

// The following section deals with distinguishing the purpose of the symbol >
// when it appears at the end of a line.
// cf. https://github.com/ananthakumaran/typescript.el/issues/81
{

    var a, b, c, d, e, f, l, o, t, x, z
    type z      = {} // Zero argument
    type o<A>   = {} // One  argument
    type t<A,B> = {} // Two  arguments

    // greater-than operator
    x = b >
        c
    // looks like a<b,c> but is greater-than operator
    x = t < z , z >
        f()
    // looks almost the same but this time, it's a type
    type x = t < z , z >
    f()
    // looks almost the same but this time, it's a type
    x = a as t < z , z >
    f()
    // tricky, this is greater-than, because "number" is a keyword
    a = b as number < z , z >
        f()

    // Next one is ambiguous! It could be read as:
    // (b as t) < z, z > f()
    // or
    // b as (t < z , z >) \n f()
    // It turns out that when t is not a keyword, TypeScript always chooses the
    // latter, and complains if you attempted the former
    a = b as t < z , z >
    f()

    l = [
        // operator at end of line
        a >
            b,
        // operator alone on line
        a
            >
            b,
        // end of 1st line is type argument, 2nd is operator
        a as b < c , d >
            >
            d
    ]

    // properly-closed parameterized type, followed by operator
    g = a as o < z > >
        b

    // Good case
    class Q<X> {
        q: string = "a"
    }

    type a<X> =
        Q<X>
    const blah = 1

    // Problem cases
    interface Something {
        a: string;
        b: string;
        c: -5;
    }

    class Fluff<X extends Something> {
    }

    // Example of = and - in a type parameter.
    type c<X extends Something = { a: string; b: string; c: -5; more: string }>
        = Fluff<X>
    const moo = 1

    // Example of + in a type parameter.
    type d<X extends Something = { +readonly [P in keyof Something]: Something[P] }>
        = Fluff<X>
    const moo2 = 1

    class Foo {
        a : O<Z>
        public readonly a : O<Z>
        public b : O<Z>
        private c : O<Z>
        private d : O<Z>
    }

    type Foo {
        readonly a : O<Z>
        b : O<Z>
        readonly b : O<Z>
        c : { }
        d : O<Z>
    }

    interface Foo {
        a : O<Z>
        b : { }
    }

    a = a ? a < a : a >
        a

    a = a ? a : a < a || a >
        a

    a = a ? a < a : a >
        a
    // ^ This test is the same as two above, but a bad guess could answer differently.

    type Foo { }
    a = a ? a < a : a >
        a

    class Foo { }
    a = a ? a < a : a >
        a

    type A = B<import('../file').T>
    foo

    type A = import('../file').B<import('../file').C>
    foo

}

container.each(x => x)
something() // No reason for this to be indented! (cf. issue #83)

// Method calls that look like braceless keywords should not indent!
function test() {
    return (
        f.catch()
    )
    return (
        f.do()
    )
    return (
        f.each()
    )
    return (
        f.else()
    )
    return (
        f.if()
    )
    return (
        f.finally()
    )
    return (
        f.then()
    )
}

// https://github.com/emacs-typescript/typescript.el/issues/107
let $img: JQuery<HTMLImageElement>
if (variable != null) {
    //
}

let $img2: JQuery<HTMLImageElement> = null
if (variable != null) {
    //
}

// The following block deals with strings of member expressions on so-called
// "fluent" APIs.
interface Fnord {
    log(...args: any[]): this;
    blah(): this;
}

let fnord: Fnord = {} as any;

{
    fnord
        .log("sdf")
        .blah();

    const m =
        fnord
            .log()
            .blah();

    const b = { q: 1, f: 2}

    const x =
        fnord
            .log({ a: b.q, z: b.f })
            .blah();

    (async () => {
        const x = (
            await (fnord as any)
                .log(1));
    })();
}

fnord
    .log("sdf")
    .blah();

const m =
    fnord
        .log()
        .blah();

fnord
    .log("sdf")

const q =
    fnord
        .log();

// This is a continued expression in parentheses.
const blip999 = (window.location.href === "fnord" ?
    "a" :
    "b");

// The following case is purposely not correct TS code. It tests against an
// infinite loop that would occur when the mode was asked to indent such
// incorrect syntax.
if (true) {
    .bleh();
}

const m =
    fnord<string, number>()
        .log<number, string>()
        .blah();

// This next expression is purposely not correct TS code. The missing parens
// after fnord would trigger an infinite loop in earlier implementations.
const m =
    fnord<string, unknown>
        .log<number, string>()
        .blah();

) {
    1 + 2; // Indenting this line would cause an infinite loop
}


================================================
FILE: test-files/list-items-indent-comma-first.ts
================================================
const arr =
    [ 'one'
    , 'two'
    , 'three' ];

const obj =
    { a: 111
    , b: 222
    , c: 333 };

const depth = { arr: [ 'one'
                     , 'two'
                     , 'three' ]
              , obj: { a: 111
                     , b: 222
                     , c: 333 }
              , func_call: Object.assign
              ( {}
              , { x: 1
                , y: 2
                , z: 3 }
              , { i: 'i', j: 'j' } ) };


================================================
FILE: test-files/list-items-indent-default.ts
================================================
const arr =
    [ 'one'
      , 'two'
      , 'three' ];

const obj =
    { a: 111
      , b: 222
      , c: 333 };

const depth = { arr: [ 'one'
                       , 'two'
                       , 'three' ]
                , obj: { a: 111
                         , b: 222
                         , c: 333 }
                , func_call: Object.assign
                ( {}
                  , { x: 1
                      , y: 2
                      , z: 3 }
                  , { i: 'i', j: 'j' } ) };


================================================
FILE: test-files/switch-case-indent-default.ts
================================================
function indentTest(): any {
    const obj = {
        case: 1,
        default: 2
    };

    // This function was specifically added to test for a reversion in
    // the code that indents switch statements.
    function turnip(): void {
    }

    switch (process.platform) {
        case "moo":
            break;
        case "win32": {
            const basePath = process.env.LOCALAPPDATA ||
                process.env.APPDATA;
            return combinePaths(normalizeSlashes(basePath), "Microsoft/TypeScript");
        }
        case "darwin":
            const objCase = {
                case: 1,
                default: 2
            };
        case "linux":
        case "android": {
            const cacheLocation = getNonWindowsCacheLocation(process.platform === "darwin");
            return combinePaths(cacheLocation, "typescript");
        }
        default:
            const objDefault = {
                case: 1,
                default: 2
            };
            Debug.fail(`unsupported platform '${process.platform}'`);
            return;
    }
}


================================================
FILE: test-files/switch-case-indent-disabled.ts
================================================
function getGlobalTypingsCacheLocation() {
    const obj = {
        case: 1,
        default: 2
    };
    switch (process.platform) {
    case "win32": {
        const basePath = process.env.LOCALAPPDATA ||
            process.env.APPDATA;
        return combinePaths(normalizeSlashes(basePath), "Microsoft/TypeScript");
    }
    case "darwin":
        const objCase = {
            case: 1,
            default: 2
        };
    case "linux":
    case "android": {
        const cacheLocation = getNonWindowsCacheLocation(process.platform === "darwin");
        return combinePaths(cacheLocation, "typescript");
    }
    default:
        const objDefault = {
            case: 1,
            default: 2
        };
        Debug.fail(`unsupported platform '${process.platform}'`);
        return;
    }
}


================================================
FILE: typescript-mode-general-tests.el
================================================
;;; typescript-mode-general-tests --- This file contains general tests for typescript-mode.el

;;; Commentary:
;; To know how to run the tests, see typescript-mode-tests.el

;;; Code:

(require 'ert)
(require 'typescript-mode)
(require 'cl-lib)
(require 'typescript-mode-test-utilities)

(defun typescript-test-get-doc ()
  (buffer-substring-no-properties (point-min) (point-max)))

(defun typescript-test-indent-all ()
  (delete-trailing-whitespace)
  (indent-region (point-min) (point-max) nil)
  (untabify (point-min) (point-max)))

(ert-deftest auto-mode-alist-ts ()
  (find-file (make-temp-file load-file-name nil ".ts"))
  (should (string-equal "typescript-mode" major-mode)))

(ert-deftest auto-mode-alist-tsx ()
  (find-file (make-temp-file load-file-name nil ".tsx"))
  (should (string-equal "typescript-mode" major-mode)))

(ert-deftest indentation-reference-document-is-reflowed-correctly ()
  (with-temp-buffer
    (insert-file-contents "test-files/indentation-reference-document.ts")
    ;; double ensure mode is active
    (typescript-mode)

    (let ((test-reference (typescript-test-get-doc)))
      (typescript-test-indent-all)
      (should (string-equal test-reference
                            (typescript-test-get-doc)))
      (let ((typescript-indent-switch-clauses nil))
        (typescript-test-indent-all)
        (should (string-equal test-reference
                              (typescript-test-get-doc)))))))

(ert-deftest switch-case-indent-default ()
  (with-temp-buffer
    (insert-file-contents "test-files/switch-case-indent-default.ts")
    (typescript-mode)
    (let ((test-reference (typescript-test-get-doc)))
      (typescript-test-indent-all)
      (should (string-equal test-reference
                            (typescript-test-get-doc))))))

(ert-deftest switch-case-indent-disabled ()
  (with-temp-buffer
    (insert-file-contents "test-files/switch-case-indent-disabled.ts")
    (let ((typescript-indent-switch-clauses nil))
      (typescript-mode)
      (let ((test-reference (typescript-test-get-doc)))
        (typescript-test-indent-all)
        (should (string-equal test-reference
                              (typescript-test-get-doc)))))))

(ert-deftest list-items-indent-default ()
  (with-temp-buffer
    (insert-file-contents "test-files/list-items-indent-default.ts")
    (typescript-mode)
    (let ((test-reference (typescript-test-get-doc)))
      (typescript-test-indent-all)
      (should (string= test-reference (typescript-test-get-doc))))))

(ert-deftest list-items-indent-default-not-comma-first ()
  (with-temp-buffer
    (insert-file-contents "test-files/list-items-indent-comma-first.ts")
    (typescript-mode)
    (let ((test-reference (typescript-test-get-doc)))
      (typescript-test-indent-all)
      (should-not (string= test-reference (typescript-test-get-doc))))))

(ert-deftest list-items-indent-comma-first ()
  (with-temp-buffer
    (insert-file-contents "test-files/list-items-indent-comma-first.ts")
    (typescript-mode)
    (let ((test-reference (typescript-test-get-doc))
          (typescript-indent-list-items nil))
      (typescript-test-indent-all)
      (should (string= test-reference (typescript-test-get-doc))))))

(ert-deftest list-items-indent-comma-first-not-default ()
  (with-temp-buffer
    (insert-file-contents "test-files/list-items-indent-default.ts")
    (typescript-mode)
    (let ((test-reference (typescript-test-get-doc))
          (typescript-indent-list-items nil))
      (typescript-test-indent-all)
      (should-not (string= test-reference (typescript-test-get-doc))))))

(defun get-all-matched-strings (to-match)
  (let (result)
    (dotimes (x (/ (length (match-data)) 2))
      (setq result (nconc result (list (match-string x to-match)))))
    result))

(ert-deftest typescript-tslint-report-regexp-matches ()
  "typescript-tslint-report-regexp matches a line that does not
have a rule name or a severity."
  (let* ((to-match
          "src/modules/authenticator.ts[1, 83]: ' should be \"")
         (match (string-match typescript-tslint-report-regexp
                              to-match))
         (matches (and match (get-all-matched-strings to-match))))
    (should match)
    (should-not (nth 1 matches))
    (should-not (nth 2 matches))
    (should (string-equal (nth 3 matches)
                          "src/modules/authenticator.ts"))
    (should (string-equal (nth 4 matches) "1"))
    (should (string-equal (nth 5 matches) "83"))))

(ert-deftest typescript-tslint-report-regexp-matches-with-name ()
  "typescript-tslint-report-regexp matches a line that has
a rule name, no severity."
  (let* ((to-match
          "(quotemark) src/modules/authenticator.ts[1, 83]: ' should be \"")
         (match (string-match typescript-tslint-report-regexp
                              to-match))
         (matches (and match (get-all-matched-strings to-match))))
    (should match)
    (should-not (nth 1 matches))
    (should (string-equal (nth 2 matches) "(quotemark) "))
    (should (string-equal (nth 3 matches)
                          "src/modules/authenticator.ts"))
    (should (string-equal (nth 4 matches) "1"))
    (should (string-equal (nth 5 matches) "83"))))

(ert-deftest typescript-tslint-report-regexp-matches-with-error ()
  "typescript-tslint-report-regexp matches a line that has
a severity set to ERROR, no rule name."
  (let* ((to-match
          "ERROR: src/modules/authenticator.ts[1, 83]: ' should be \"")
         (match (string-match typescript-tslint-report-regexp
                              to-match))
         (matches (and match (get-all-matched-strings to-match))))
    (should match)
    (should-not (nth 1 matches))
    (should-not (nth 2 matches))
    (should (string-equal (nth 3 matches)
                          "src/modules/authenticator.ts"))
    (should (string-equal (nth 4 matches) "1"))
    (should (string-equal (nth 5 matches) "83"))))

(ert-deftest typescript-tslint-report-regexp-matches-with-warning ()
  "typescript-tslint-report-regexp matches a line that has
a severity set to WARNING, no rule name."
  (let* ((to-match
          "WARNING: src/modules/authenticator.ts[1, 83]: ' should be \"")
         (match (string-match typescript-tslint-report-regexp
                              to-match))
         (matches (and match (get-all-matched-strings to-match))))
    (should match)
    (should (string-equal (nth 1 matches) "WARNING"))
    (should-not (nth 2 matches))
    (should (string-equal (nth 3 matches)
                          "src/modules/authenticator.ts"))
    (should (string-equal (nth 4 matches) "1"))
    (should (string-equal (nth 5 matches) "83"))))

(ert-deftest typescript--number-literal-re-matches-numbers ()
  "`typescript--number-literal-re' matches numbers."
  (dolist (to-match '("NaN" "Infinity" "-Infinity" "-1" "1" "0.1" ".1" "-.1" "8e23"
                      "9E-2" ".1e23" "0b1" "-0B1" "0o7" "-0O13" "0xaf" "-0XAF"))
    (should (string-match typescript--number-literal-re to-match))
    ;; The regular expression does not begin with ^ and end with $ so
    ;; we need to check ourselves that the whole string is matched.
    (should (string-equal (match-string 0 to-match) to-match))))

(ert-deftest typescript--number-literal-re-does-not-match-non-numbers ()
  "`typescript--number-literal-re' does not match non-numbers."
  (dolist (to-match '("NaNa" "Inf" "1." "." "0xPQ" "e" "2.3e2.4"))
    ;; For the same reason as for the positive test above, what we want is either no match
    ;; or a match that fails to match the whole string.
    (should-not (and (string-match typescript--number-literal-re to-match)
                     (string-equal (match-string 0 to-match) to-match)))))

(ert-deftest correctly-indents-lines-with-wide-chars ()
  "Otsuka Ai and other multi-char users should be a happy to write typescript."

  (with-temp-buffer
    (ignore-errors (typescript-mode))
    (insert "let x = '大塚愛'")
    (let ((pos1 (current-column)))
      (typescript-indent-line)
      (let ((pos2 (current-column)))
        (should (= pos1 pos2))))))

(ert-deftest correctly-indents-lines-with-tabs ()
  (with-temp-buffer
    (ignore-errors (typescript-mode))

    (insert "class Example {")
    (newline-and-indent)
    (insert "constructor() {")
    (newline-and-indent)
    (insert "const a = new Promise")

    (should (= 29 (current-column)))
    (typescript-indent-line)
    (should (= 29 (current-column)))

    ;; verify tab was used
    (move-beginning-of-line nil)
    (should (= 0 (current-column)))
    (forward-char 1)
    (should (= 8 (current-column)))))

(ert-deftest correctly-indents-dot-dot-after-exclamation ()
  (with-temp-buffer
    (ignore-errors (typescript-mode))
    (insert "situation('8/8/8/8/8/8/8/R3K2R w - - 0 1')?.")
    (forward-char -1)
    (newline-and-indent)
    (should (= 4 (current-column)))))

(ert-deftest indentation-does-not-hang-on-multiline-string ()
  "Testcase for https://github.com/ananthakumaran/typescript.el/issues/20"

  (with-temp-buffer
    (typescript-mode)

    (insert "let multiLineString = \"line 1")
    (newline-and-indent)
    (insert "// and so we continue")
    (newline-and-indent)
    ;; completing and not locking up is test-success!
    ))

(ert-deftest typescript--forward-expression-on-multiline-indented-string ()
  "Testcase for https://github.com/emacs-typescript/typescript.el/issues/105"

  (with-temp-buffer
    (typescript-mode)

    (insert
"fetch('http://localhost:8529/_db/_system/land', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Accept: 'application/json',
  },
  body: JSON.stringify({
    query: `{
      query GetElement {
        element(id: \"0000\") {
          collection
          id
          name
          description
        }
      }
    }`,
  }),
})
  .then(r => r.json())
  .then(data => console.log('data returned:', data));")

    (goto-char (point-min))
    (typescript--forward-expression)
    ;; completing and not locking up is test-success!
    ;; Should there be a time-out? Or it is handled by external tool?

    ;; Check that `typescript--forward-expression' jumped to the right position.
    (should (= 434 (point)))))

(defun test-re-search (searchee contents offset)
  (with-temp-buffer
    (typescript-mode)

    (insert contents)
    (goto-char (- (point-max) offset))

    (should (= 5 (typescript--re-search-backward-inner searchee nil 1)))))

(ert-deftest re-search-backwards-skips-single-line-strings ()
  (test-re-search "token" "let token = \"token in string-thing\";" 2))

(ert-deftest re-search-backwards-skips-multi-line-strings ()
  (test-re-search "token" "let token = \"token in\n multi-line token string\";" 2))

(ert-deftest re-search-backwards-skips-single-line-comments ()
  (test-re-search "token" "let token; // token in comment" 0))

(ert-deftest re-search-backwards-skips-multi-line-comments ()
  (test-re-search "token" "let token; /* token in \nmulti-line token comment" 0))

(setq font-lock-contents
 " * @param {Something} bar A parameter. References [[moo]] and [[foo]].
 * @param second May hold ``x`` or ``y``.")

(ert-deftest font-lock/interface-builtin-key-context-unfontify ()
  "Builtins should not be fontified when they are in object or
interface key context."
  (test-with-fontified-buffer
      "interface Foo { type: number; unknown: string; foo: boolean }"
    (should (eq (get-face-at "type") 'default))
    (should (eq (get-face-at "unknown") 'default)))

  (test-with-fontified-buffer
      "const x = { type: 4; unknown: 'bar'; foo: true }"
    (should (eq (get-face-at "type") 'default))
    (should (eq (get-face-at "unknown") 'default))))

(ert-deftest font-lock/documentation-in-documentation-comments ()
  "Documentation in documentation comments should be fontified as
documentation."
  (font-lock-test
   (concat "/**\n" font-lock-contents "\n*/")
   '((1 . font-lock-comment-delimiter-face)
     (5 . font-lock-comment-face)
     ("@param" . typescript-jsdoc-tag)
     ("{Something}" . typescript-jsdoc-type)
     ("bar" . typescript-jsdoc-value)
     ("\\[\\[moo\\]\\]" . typescript-jsdoc-value)
     ("\\[\\[foo\\]\\]" . typescript-jsdoc-value)
     ("``x``" . typescript-jsdoc-value)
     ("``y``" . typescript-jsdoc-value))))

(ert-deftest font-lock/no-documentation-in-non-documentation-comments ()
  "Documentation tags that are not in documentation comments
should not be fontified as documentation."
  (test-with-fontified-buffer
   (concat "/*\n" font-lock-contents "\n*/\n")
   (let ((loc 3))
     ;; Make sure we start with the right face.
     (should (eq (get-face-at loc) font-lock-comment-face))
     (should (eq (text-property-not-all loc (point-max) 'face font-lock-comment-face)
                 (1- (point-max)))))))

(ert-deftest font-lock/no-documentation-in-strings ()
  "Documentation tags that are not in strings should not be
fontified as documentation."
  (test-with-fontified-buffer
   (concat "const x = \"/**" font-lock-contents "*/\";")
   (let ((loc (search-forward "\"")))
     ;; Make sure we start with the right face.
     (should (eq (get-face-at loc) font-lock-string-face))
     ;; Make sure the face does not change later.
     (should (eq (text-property-not-all loc (point-max) 'face font-lock-string-face)
                 (1- (point-max)))))))

(ert-deftest font-lock/immediate-doc ()
  "Tests that it is not necessary to have the documentation tag on a
new line after the start of '/**'."
  (font-lock-test
   ;; We have 4 comments here because we need to cover the multiple
   ;; regexes that deal with the different types of jsdoc tags.
   "/** @type {foo} */\n
/** @alias bar */\n
/** @author me */\n
/** @param meow */"
   '((1 . font-lock-comment-delimiter-face)
     ("@type" . typescript-jsdoc-tag)
     ("{foo}" . typescript-jsdoc-type)
     ("@alias" . typescript-jsdoc-tag)
     ("bar" . typescript-jsdoc-value)
     ("@author" . typescript-jsdoc-tag)
     ("me" . font-lock-comment-face)
     ("@param" . typescript-jsdoc-tag)
     ("meow" . typescript-jsdoc-value))))

(ert-deftest font-lock/function-definition-prefixes ()
  "Tests that function names are highlighted in definitions, even
when prefixed with module modifiers."
  (font-lock-test
   "function basicDefn(x0: xty0, y0: yty0): ret0 {}\n
export function exportedDefn(x1: xty1, y1: yty1): ret1 {}\n
export default function exportedDefaultDefn(x2: xty2, y2: yty2): ret2 {}\n
declare function declareFunctionDefn(x3: xty3, y3: yty3): ret3;"
    '(("basicDefn" . font-lock-function-name-face)
      ("exportedDefn" . font-lock-function-name-face)
      ("exportedDefaultDefn" . font-lock-function-name-face)
      ("declareFunctionDefn" . font-lock-function-name-face)
      (("x0" "x1" "x2" "x3") . font-lock-variable-name-face)
      (("\\by0" "\\by1" "\\by2" "\\by3") . font-lock-variable-name-face)
      (("ret0" "ret1" "ret2" "ret3") . nil))))

(ert-deftest font-lock/level-four ()
  "Tests the level four font lock highlights."
  (font-lock-test
   "@decorator\n
class Foo<T> extends Bar {\n
private async innerExecuteAsync<TResponse extends Response, TValue>(endpoint: string, data?: any): Promise<TResponse> {\n
innerExecuteAsync(x: string, y: boolean, z: number, j?: any): Promise<FResponse> {\n
console.log(this.methodCall());\n
snake_cased_function(1, 2, 3)"
    '(("@decorator" . font-lock-function-call-face)
      ("Foo" . font-lock-type-face)
      ("private" . typescript-access-modifier-face)
      ("innerExecuteAsync" . font-lock-function-name-face)
      (("TResponse" "FResponse" "Response" "TValue") . font-lock-type-face)
      ("console" . font-lock-type-face)
      ("this" . typescript-this-face)
      ("methodCall" . font-lock-function-call-face)
      ("snake_cased_function" . font-lock-function-call-face)
      (("string" "boolean" "number" "any") . typescript-primitive-face)
      (("endpoint" "data") . font-lock-variable-name-face)
      (("<" ">" ",") . nil))))

(ert-deftest font-lock/method-call-with-keyword-name ()
  "If the name of the method is a keyword, it should still be highlighted as function."
  (test-with-fontified-buffer
      "const app = express();
app.get()
app.post()
app.delete()
if (true) {}
// for (abc) {}"
    (should (eq (get-face-at "get") 'font-lock-function-call-face))
    (should (eq (get-face-at "post") 'font-lock-function-call-face))
    (should (eq (get-face-at "delete") 'font-lock-function-call-face))
    (should (eq (get-face-at "if") 'font-lock-keyword-face))
    (should (eq (get-face-at "for") 'font-lock-comment-face))))

(ert-deftest font-lock/generics ()
  "Tests that type hints within generics are highlighted properly."
  (font-lock-test
   "const map = new Map<string, number>()\n
function foo<Z, Y, Z & Y, Z | Y | Z, Y<X<X, Y>>>()\n"
   '((("string" "number") . typescript-primitive-face)
      ("foo" . font-lock-function-name-face)
      (("Z" "Y" "X") . font-lock-type-face)
      (("<" ">" "," "&" "|") . nil))))

(ert-deftest font-lock/tsx ()
  "Tests that tsx blocks are not considered generics by virtue of the <."
  (font-lock-test
   "<div>test</div>"
   '((("div" . nil)))))

(ert-deftest font-lock/regexp ()
  "Regular expressions should be fontified as string constant."
  (let ((content "=/foo/ (/bar/ ,/baz/ :/buzz/"))
    (font-lock-test content
                    '(("=" . nil) ("/foo/" . font-lock-string-face)
                      ("(" . nil) ("/bar/" . font-lock-string-face)
                      ("," . nil) ("/baz/" . font-lock-string-face)
                      (":" . nil) ("/buzz/" . font-lock-string-face))))
  ;; Make sure that escaped forward slashes are handled too.
  (font-lock-test "var a = /flip\\/flop/;"
                  '(("=" . nil)
                    (("/flip" "\\\\" "/" "flop/") . font-lock-string-face)
                    (";" . nil)))
  ;; Make sure a forward slash in a character class is handled fine.
  ;; It must not terminate the regular expression.
  (font-lock-test "var a = /[/]/;"
                  '(("=" . nil)
                    (("/" "\\[/" "\\]/") . font-lock-string-face)
                    (";" . nil)))
  ;; Make sure an open bracket in a character class does not
  ;; throw off fontification.
  (font-lock-test "var a = /[[]/;"
                  '(("=" . nil)
                    (("/" "\\[\\[\\]" "/") . font-lock-string-face)
                    (";" . nil)))
  ;; A sequence of two forward slashes is never a regex, so there is
  ;; no such thing as an \"empty regex\" when we use the forward slash
  ;; notation.
  (font-lock-test "=//g something // comment"
                  '(("g something" . font-lock-comment-face))))

(ert-deftest font-lock/yield ()
  "`yield' and `yield*' should be fontified as keywords."
  (font-lock-test
   "function* gen(x0: xty0, y0: yty0): ret0 {
    yield 123;
    yield* subIter;
}"
   '(("yield 123" . font-lock-keyword-face)
     ("yield\\*" . font-lock-keyword-face)
     ("\\* subIter" . font-lock-keyword-face))))

(ert-deftest font-lock/yielder ()
  "`yielder' should not be fontified as a keyword."
  (font-lock-test
   "function* gen(x0: xty0, y0: yty0): ret0 {
    const yielder = 123;
    yield abc;
    return yielder;
}"
   '(("yielder =" . font-lock-variable-name-face)
     ("yielder;" . nil))))

(ert-deftest font-lock/text-after-trailing-regexp-delim-should-not-be-fontified ()
  "Text after trailing regular expression delimiter should not be fontified."
  (test-with-fontified-buffer
   "=/foo/g something // comment"
   (should (eq (get-face-at "g something") nil)))
  (test-with-fontified-buffer
   "=/foo\\bar/g something // comment"
   (should (eq (get-face-at "g something") nil)))
  (test-with-fontified-buffer
   "=/foo\\\\bar/g something // comment"
   (should (eq (get-face-at "g something") nil)))
  (test-with-fontified-buffer
   "=/foo\\\\/g something // comment"
   (should (eq (get-face-at "g something") nil))))

(ert-deftest font-lock/type-names ()
  "Type names should be highlighted in definitions."
  ;; Typical case.
  (test-with-fontified-buffer
      "export class Foo extends Bar implements Qux {}"
    (should (eq (get-face-at "Foo") 'font-lock-type-face))
    (should (eq (get-face-at "Bar") 'font-lock-type-face))
    (should (eq (get-face-at "Qux") 'font-lock-type-face)))
  (test-with-fontified-buffer
      "export class Foo extends Bar implements Qux, Ajx {}"
    (should (eq (get-face-at "Foo") 'font-lock-type-face))
    (should (eq (get-face-at "Bar") 'font-lock-type-face))
    (should (eq (get-face-at "Qux") 'font-lock-type-face))
    (should (eq (get-face-at ",") 'nil))
    (should (eq (get-face-at "Ajx") 'font-lock-type-face)))
  (test-with-fontified-buffer
      "export class Foo extends Bar implements Qux, Ajx, Psd {}"
    (should (eq (get-face-at "Foo") 'font-lock-type-face))
    (should (eq (get-face-at "Bar") 'font-lock-type-face))
    (should (eq (get-face-at "Qux") 'font-lock-type-face))
    (should (eq (get-face-at ",") 'nil))
    (should (eq (get-face-at "Ajx") 'font-lock-type-face))
    (should (eq (get-face-at ",") 'nil))
    (should (eq (get-face-at "Psd") 'font-lock-type-face)))
  ;; Ensure we require symbol boundaries.
  (test-with-fontified-buffer
      "Notclass Foo"
    (should-not (eq (get-face-at "Foo") 'font-lock-type-face)))
  ;; Other common ways of defining types.
  (test-with-fontified-buffer
      "interface Thing {}"
    (should (eq (get-face-at "Thing") 'font-lock-type-face)))
  (test-with-fontified-buffer
      "enum Thing {}"
    (should (eq (get-face-at "Thing") 'font-lock-type-face)))
  (test-with-fontified-buffer
      "type Thing = number;"
    (should (eq (get-face-at "Thing") 'font-lock-type-face))))

(ert-deftest font-lock/fontify-type-guard ()
  "The type guard syntax

    var is Type

should be fontified as variable, keyword and type."
  (test-with-fontified-buffer
      "function test(var: unknown): var is RetType {\n}"
    (should (eq (get-face-at 30) 'font-lock-variable-name-face))
    (should (eq (get-face-at "is") 'font-lock-keyword-face))
    (should (eq (get-face-at "RetType") 'font-lock-type-face))))


(ert-deftest font-lock/type-names-level4 ()
  "Typenames should be highlighted in declarations"

  (test-with-fontified-buffer
      "function test(var1: Type1, var2: Type2): RetType {\n}"
    (should-not (eq (get-face-at "var1") 'font-lock-type-face))
    (should (eq (get-face-at "Type1") 'font-lock-type-face))
    (should-not (eq (get-face-at "var2") 'font-lock-type-face))
    (should (eq (get-face-at "Type2") 'font-lock-type-face))
    (should (eq (get-face-at "RetType") 'font-lock-type-face)))

  (test-with-fontified-buffer
      "class foo { test(var1: Type1, var2: Type2): RetType {\n} }"
    (should-not (eq (get-face-at "var1") 'font-lock-type-face))
    (should (eq (get-face-at "Type1") 'font-lock-type-face))
    (should-not (eq (get-face-at "var2") 'font-lock-type-face))
    (should (eq (get-face-at "Type2") 'font-lock-type-face))
    (should (eq (get-face-at "RetType") 'font-lock-type-face)))

  (test-with-fontified-buffer
      "let a: SomeType;"
    (should (eq (get-face-at "SomeType") 'font-lock-type-face)))
  (test-with-fontified-buffer
      "private b: SomeType;"
    (should (eq (get-face-at "SomeType") 'font-lock-type-face)))
  (test-with-fontified-buffer
      "private someArray: SomeType[];"
    (should (eq (get-face-at "SomeType") 'font-lock-type-face)))
  (test-with-fontified-buffer
      "private generic: SomeType<Foo>;"
    (should (eq (get-face-at "SomeType") 'font-lock-type-face))
    (should (eq (get-face-at "Foo") 'font-lock-type-face)))

  (test-with-fontified-buffer
      "private genericArray: SomeType<Foo>[];"
    (should (eq (get-face-at "SomeType") 'font-lock-type-face))
    (should (eq (get-face-at "Foo") 'font-lock-type-face)))

  (test-with-fontified-buffer
      "private genericArray2: SomeType<Foo[]>;"
    (should (eq (get-face-at "SomeType") 'font-lock-type-face))
    (should (eq (get-face-at "Foo") 'font-lock-type-face)))

  (test-with-fontified-buffer
      "private genericArray3: SomeType<Foo[]>[];"
    (should (eq (get-face-at "SomeType") 'font-lock-type-face))
    (should (eq (get-face-at "Foo") 'font-lock-type-face)))

  (test-with-fontified-buffer
      "const f: () => SomeType = () => {}"
    (should (eq (get-face-at "SomeType") 'font-lock-type-face))))

(ert-deftest font-lock/type-names-level4-namespaces ()
  "Namespaced Typenames should be highlighted in declarations"
  (test-with-fontified-buffer
      "private b: Namespaced.ClassName;"
    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
    (should (eq (get-face-at "ClassName") 'font-lock-type-face)))
  (test-with-fontified-buffer
      "function test(var1: Namespaced.ClassName): RetType {\n}"
    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
    (should (eq (get-face-at "ClassName") 'font-lock-type-face)))

  (test-with-fontified-buffer
      "class Foo { test(var1: Namespaced.ClassName): RetType {\n}"
    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
    (should (eq (get-face-at "ClassName") 'font-lock-type-face)))

  (test-with-fontified-buffer
      "function test(var1: Type): Namespaced.ClassName {\n}"
    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
    (should (eq (get-face-at "ClassName") 'font-lock-type-face)))

  (test-with-fontified-buffer
      "class Foo { test(var1: Type): Namespaced.ClassName {\n}"
    (should (eq (get-face-at "Namespaced") 'font-lock-type-face))
    (should (eq (get-face-at "ClassName") 'font-lock-type-face))))

(ert-deftest font-lock/funargs--function--multiline-with-types ()
  "Variables should be highlighted in multiline declarations with types."
  (test-with-fontified-buffer
      "function test(
var1: Promise<U1, V1>,
var2: (xxx: Foo) => Bar,
var3: Type3,
): RetType {\n}"
    (should (eq (get-face-at "var1") 'font-lock-variable-name-face))
    (should (eq (get-face-at "var2") 'font-lock-variable-name-face))
    (should (eq (get-face-at "var3") 'font-lock-variable-name-face))
    (should (eq (get-face-at "xxx") 'font-lock-variable-name-face))
    (should (eq (get-face-at "Promise") 'font-lock-type-face))
    (should (eq (get-face-at "U1") 'font-lock-type-face))
    (should (eq (get-face-at "Foo") 'font-lock-type-face))
    (should (eq (get-face-at "Type3") 'font-lock-type-face))))

(ert-deftest font-lock/funargs--function--multiline-without-types ()
  "Variables should be highlighted in multiline declarations without types."
  (test-with-fontified-buffer
      "function test(
var1,
var2,
): RetType {\n}"
    (should (eq (get-face-at "var1") 'font-lock-variable-name-face))
    (should (eq (get-face-at "var2") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--function--multiline-hanging-paren ()
  "Variables should be highlighted in multiline declarations with hanging paren."
  (test-with-fontified-buffer
   "function test(
var1,
var2): RetType {\n}"
   (should (eq (get-face-at "var1") 'font-lock-variable-name-face))
   (should (eq (get-face-at "var2") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--function--multiline-ending-comma-hanging-paren ()
  "Variables should be highlighted in multiline declarations with hanging paren and trailing comma."
  (test-with-fontified-buffer
   "function test(
var1,
var2,): RetType {\n}"
   (should (eq (get-face-at "var1") 'font-lock-variable-name-face))
   (should (eq (get-face-at "var2") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--function--singleline-ending-comma-no-hanging-paren ()
  "Variables should be highlighted in singleline declarations with no hanging paren and trailing comma."
  (test-with-fontified-buffer
      "function test(var1,var2,
): RetType {\n}"
   (should (eq (get-face-at "var1") 'font-lock-variable-name-face))
   (should (eq (get-face-at "var2") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--function--singleline-with-types ()
  "Variables should be highlighted in singleline declarations with types."
  (test-with-fontified-buffer
      "function test(var1: Foo, var2: Bar,): RetType {\n}"
   (should (eq (get-face-at "var1") 'font-lock-variable-name-face))
   (should (eq (get-face-at "var2") 'font-lock-variable-name-face))
   (should (eq (get-face-at "Foo") 'font-lock-type-face))
   (should (eq (get-face-at "Bar") 'font-lock-type-face))))

(ert-deftest font-lock/funargs--function--singleline-ending-comma-hanging-paren ()
  "Variables should be highlighted in singleline declarations with hanging paren and trailing comma."
  (test-with-fontified-buffer
   "function test(var1,var2,): RetType {\n}"
   (should (eq (get-face-at "var1") 'font-lock-variable-name-face))
   (should (eq (get-face-at "var2") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--function--keywords-as-variables ()
  "Keywords when used as variables should have variable face"
  (test-with-fontified-buffer
      "function test(type, unknown): void {}"
    (should (eq (get-face-at "type") 'font-lock-variable-name-face))
    (should (eq (get-face-at "unknown") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--keywords-as-variables ()
  "Keywords when used as variables should have variable face"
  (test-with-fontified-buffer
      "const test = (type, unknown): void => {}"
    (should (eq (get-face-at "type") 'font-lock-variable-name-face))
    (should (eq (get-face-at "unknown") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--single-line--no-type ()
  (test-with-fontified-buffer
      "const test = (aaa, bbb, ccc): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--single-line--no-type--no-return-type ()
  (test-with-fontified-buffer
      "const test = (aaa, bbb, ccc) => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--single-line--no-type--trailing-comma ()
  (test-with-fontified-buffer
      "const test = (aaa, bbb, ccc,): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--single-line--no-type--optional ()
  (test-with-fontified-buffer
      "const test = (aaa, bbb?): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb?") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--multiline--no-type ()
  (test-with-fontified-buffer
      "const test = (aaa, bbb,
ccc, ddd): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--multiline--no-type--newline-after-last ()
  (test-with-fontified-buffer
      "const test = (aaa, bbb,
ccc, ddd
): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--multiline--no-type--newline-before-first ()
  (test-with-fontified-buffer
      "const test = (
aaa, bbb,
ccc, ddd
): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--multiline--no-type--with-comment ()
  (test-with-fontified-buffer
      "const test = (
aaa, bbb, // comment
ccc, ddd  // comment
): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--single--mixed-type--newline-before-first ()
  (test-with-fontified-buffer
      "const test = (aaa, bbb: Promise, ccc: number, ddd): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ccc") 'font-lock-variable-name-face))
    (should (eq (get-face-at "ddd") 'font-lock-variable-name-face))
    (should (eq (get-face-at "Promise") 'font-lock-type-face))
    (should (eq (get-face-at "number") 'typescript-primitive-face))))

(ert-deftest font-lock/funargs--arrow--single--with-type--complex-type ()
  (test-with-fontified-buffer
      "const test = (aaa: Promise<U, V, (xxx: A) => Foo>, bbb): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "xxx") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--arrow--multiline--with-type--newline-before-first-after-last ()
  (test-with-fontified-buffer
      "const test = (
aaa: Foo,
bbb: Bar
): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "Foo") 'font-lock-type-face))
    (should (eq (get-face-at "Bar") 'font-lock-type-face))))

(ert-deftest font-lock/funargs--arrow--multiline--with-type--newline-before-first-after-last--hanging-comma ()
  (test-with-fontified-buffer
      "const test = (
aaa: Foo,
bbb: Bar,
): void => {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "Foo") 'font-lock-type-face))
    (should (eq (get-face-at "Bar") 'font-lock-type-face))))

(ert-deftest font-lock/backticks--expr-fontification--with-variable ()
  (test-with-fontified-buffer
      "const x = `hello ${world}`"
    (should (eq (get-face-at "${") 'font-lock-keyword-face))
    (should (eq (get-face-at "world") 'default))
    (should (eq (get-face-at "}") 'font-lock-keyword-face))))

(ert-deftest font-lock/backticks--expr-fontification--not-in-regular-string ()
  (test-with-fontified-buffer
      "const x = 'hello ${world}'"
    (should (eq (get-face-at "${") 'font-lock-string-face))
    (should (eq (get-face-at "world") 'font-lock-string-face))
    (should (eq (get-face-at "}") 'font-lock-string-face))))

(ert-deftest font-lock/backticks--expr-fontification--with-funcall ()
  "For now function calls or any other expressions are fontified as
if a simple variable token in its entirety.  When/if this is
implemented better, this test should be adjusted to capture the
new functionality."
  (test-with-fontified-buffer
      "const x = `hello ${parseInt(foobar)}`"
    (should (eq (get-face-at "${") 'font-lock-keyword-face))
    (should (eq (get-face-at "parseInt(foobar)") 'default))
    (should (eq (get-face-at "}") 'font-lock-keyword-face))))

(ert-deftest font-lock/funargs--method--multiline--with-type ()
  (test-with-fontified-buffer
      "class Foo { foo(
aaa: Foo,
bbb: Bar,
): void {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "Foo") 'font-lock-type-face))
    (should (eq (get-face-at "Bar") 'font-lock-type-face))))

(ert-deftest font-lock/funargs--method--single-line--with-type ()
  (test-with-fontified-buffer
      "class Foo { foom(aaa: Foo,bbb: Bar,): void {}"
    (should (eq (get-face-at "foom") 'font-lock-function-name-face))
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))
    (should (eq (get-face-at "Foo") 'font-lock-type-face))
    (should (eq (get-face-at "Bar") 'font-lock-type-face))))

(ert-deftest font-lock/funargs--method--single-line--no-type ()
  (test-with-fontified-buffer
      "class Foo { foo(aaa, bbb): void {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--method--single-line--no-return-type ()
  (test-with-fontified-buffer
      "class Foo { foo(aaa, bbb) {}"
    (should (eq (get-face-at "aaa") 'font-lock-variable-name-face))
    (should (eq (get-face-at "bbb") 'font-lock-variable-name-face))))

(ert-deftest font-lock/funargs--method--no-fontification-in-ternary ()
  "Do not apply fontification on a function call inside a ternary
operator, which might look like method with return type
declaration."
  (test-with-fontified-buffer
      "true ? funcall(helloWorld) : false"
    (should (eq (get-face-at "helloWorld") nil))))

(ert-deftest font-lock/funargs--method--no-fontification-in-special-form ()
  "Do not apply fontification inside a special form paren-form,
such as inside of if/while/switch etc.  These look like method
declarations without a return type annotation but are not."
  (test-with-fontified-buffer
      "if (hello && world) { }"
    (should (eq (get-face-at "world") nil))))

(defun flyspell-predicate-test (search-for)
  "This function runs a test on
`typescript--flyspell-mode-predicate'.  `SEARCH-FOR' is a string
to search for in the current buffer before running
`typescript--flyspell-mode-predicate'.  This test checks that the
point has not moved.  It returns the value of returned by the
invocation of `typescript--flyspell-mode-predicate'."
  (search-forward search-for)
  (let ((point-before (point)))
    (prog1
        (typescript--flyspell-mode-predicate)
      ;; We should not have moved.
      (should (eq (point) point-before)))
  ))

(ert-deftest flyspell-mode-predicate-skips-what-it-should ()
  "Check that the custom flyspell predicate filters strings in
import... from...."
  (let (flyspell-generic-progmode-verify)
    (fset 'flyspell-generic-progmode-verify (lambda () t))
    ;; In the following searches we search for the starting quote of the strings
    ;; to avoid hitting keywords. Moreover, the end position of the search is important.
    ;; Flyspell puts point at the end of the word before calling the predicate. We must
    ;; replicate that behavior here.
    (test-with-fontified-buffer
     "import 'a';\nimport { x } from 'b';\nconst foo = 'c';import { x }\nfrom 'd';"
     (should-not (flyspell-predicate-test "'a"))
     (should-not (flyspell-predicate-test "'b"))
     (should (flyspell-predicate-test "'c"))
     (should-not (flyspell-predicate-test "'d")))
    (test-with-fontified-buffer
     ;; This is valid TypeScript.
     "const from = 'a';"
     (should (flyspell-predicate-test "'a")))
    (test-with-fontified-buffer
     ;; TypeScript does not allow a function named "import" but object
     ;; members may be named "import". So this *can* be valid
     ;; TypeScript.
     "x.import('a');"
     (should (flyspell-predicate-test "'a")))))


(ert-deftest typescript--move-to-end-of-plain-string ()
  "Unit tests for `typescript--move-to-end-of-plain-string'."
  (cl-flet
      ((should-fail ()
                    (let ((point-before (point)))
                      (should-not (typescript--move-to-end-of-plain-string))
                      (should (eq (point) point-before))))
       (should-not-fail (expected)
                        (let ((result (typescript--move-to-end-of-plain-string)))
                          (should (eq result expected))
                          (should (eq (point) expected)))))
    ;;
    ;; The tests below are structured as follows. For each case:
    ;;
    ;; 1. Move point to a new location in the buffer.
    ;;
    ;; 2. Check whether typescript--move-to-end-of-plain-string returns the value we expected
    ;;    and changes (point) when successful.
    ;;
    ;; Cases often start with a check right away: (point) equal to
    ;; (point-min) for those cases.
    ;;
    (dolist (delimiter '("'" "\""))
      (test-with-temp-buffer
       (replace-regexp-in-string "'" delimiter "const a = 'not terminated")
       (should-fail)
       (re-search-forward delimiter)
       (should-fail))
      (test-with-temp-buffer
       (replace-regexp-in-string "'" delimiter "const a = 'terminated'")
       (should-fail)
       ;; This checks that the function works when invoked on the start delimiter of
       ;; a terminated string.
       (re-search-forward delimiter)
       (should-not-fail (1- (point-max)))
       (goto-char (point-min))
       (re-search-forward "term")
       (should-not-fail (1- (point-max)))
       ;; This checks that the function works when invoked on the end delimiter of
       ;; a terminated string.
       (goto-char (1- (point-max)))
       (should-not-fail (1- (point-max))))
      (test-with-temp-buffer
       (replace-regexp-in-string "'" delimiter "const a = 'terminated aaa';\n
const b = 'not terminated bbb")
       (should-fail)
       (re-search-forward "term")
       (should-not-fail (save-excursion (re-search-forward "aaa")))
       (re-search-forward "const b")
       (should-fail)
       (re-search-forward "not terminated")
       (should-fail))
      ;; Case with escaped delimiter.
      (test-with-temp-buffer
       (replace-regexp-in-string "'" delimiter "const a = 'terminat\\'ed aaa';\n
 const b = 'not terminated bbb")
       (re-search-forward "term")
       (should-not-fail (save-excursion (re-search-forward "aaa"))))
      ;; Delimiters in comments.
      (test-with-temp-buffer
       (replace-regexp-in-string "'" delimiter "const a = 'terminated aaa';\n
// Comment 'or'\n
const b = 'not terminated bbb")
       (re-search-forward "term")
       (should-not-fail (save-excursion (re-search-forward "aaa")))
       (re-search-forward "Comment ")
       (should-fail)
       (forward-char)
       (should-fail)
       (re-search-forward "or")
       (should-fail)))
    ;; Ignores template strings.
    (test-with-temp-buffer
     "const a = `terminated aaa`"
     (re-search-forward "term")
     (should-fail))))

(ert-deftest typescript-convert-to-template ()
  "Unit tests for `typescript-convert-to-template'."
  (cl-flet
      ((should-do-nothing (str regexp)
                    (test-with-temp-buffer
                     str
                     (re-search-forward regexp)
                     (typescript-convert-to-template)
                     (should (string-equal (typescript-test-get-doc) str))))
       (should-modify (str delimiter regexp)
                    (test-with-temp-buffer
                     str
                     (re-search-forward regexp)
                     (typescript-convert-to-template)
                     (should (string-equal (typescript-test-get-doc)
                                           (replace-regexp-in-string delimiter "`" str))))))
    (dolist (delimiter '("'" "\""))
      (let ((str (replace-regexp-in-string "'" delimiter "const a = 'not terminated")))
        (dolist (move-to '("const" "not"))
          (should-do-nothing str move-to)))
      (let ((str (replace-regexp-in-string "'" delimiter "const a = 'terminated'")))
        (should-do-nothing str "const")
        (should-modify str delimiter delimiter)
        (should-modify str delimiter "term")
        (should-modify str delimiter "terminated"))
      ;; Delimiters in comments.
      (let ((str (replace-regexp-in-string "'" delimiter "const a = 'terminated aaa';\n
// Comment 'or'\n
const b = 'not terminated bbb")))
        (should-do-nothing str "Comment ")))
    ;; Ignores template strings.
    (let ((str "const a = `terminated aaa`"))
      (should-do-nothing str "terminated"))))

(ert-deftest typescript-autoconvert-to-template ()
  "Unit tests for `typescript-autoconvert-to-template'."
  (cl-flet
      ((should-do-nothing (str regexp)
                    (test-with-temp-buffer
                     str
                     (re-search-forward regexp)
                     (typescript-autoconvert-to-template)
                     (should (string-equal (typescript-test-get-doc) str))))
       (should-modify (str delimiter regexp)
                    (test-with-temp-buffer
                     str
                     (re-search-forward regexp)
                     (typescript-autoconvert-to-template)
                     (should (string-equal (typescript-test-get-doc)
                                           (replace-regexp-in-string delimiter "`" str))))))
    (dolist (delimiter '("'" "\""))
      (let ((str (replace-regexp-in-string "'" delimiter "const a = 'terminated'")))
        (should-do-nothing str "= ")
        (should-do-nothing str "terminated"))
      (let ((str (replace-regexp-in-string "'" delimiter "const a = '${foo}'")))
        (should-do-nothing str "= ")
        (should-modify str delimiter (concat "foo}" delimiter))))))

(ert-deftest typescript-autoconvert-to-template-is-invoked ()
  "Test that we call `typescript-autoconvert-to-template' as needed."
  (cl-flet
      ((should-do-nothing (str delimiter)
                    (test-with-temp-buffer
                     str
                     (goto-char (point-max))
                     (execute-kbd-macro delimiter)
                     (should (string-equal (typescript-test-get-doc) (concat str delimiter)))))
       (should-modify (str delimiter)
                    (test-with-temp-buffer
                     str
                     (goto-char (point-max))
                     (execute-kbd-macro delimiter)
                     (should (string-equal (typescript-test-get-doc)
                                           (replace-regexp-in-string delimiter "`" (concat str delimiter)))))))
    (dolist (delimiter '("'" "\""))
      (let ((str (replace-regexp-in-string "'" delimiter "const a = '${foo}")))
        (should-do-nothing str delimiter)
        (let ((typescript-autoconvert-to-template-flag t))
          (should-modify str delimiter))))))

;; compilation-mode tests

(ert-deftest recognizes-tsc-errors ()

  (dolist (test-case
           `(("test.ts(2,7): error TS2322: Type '2' is not assignable to type 'string'."
              ,typescript-tsc-error-regexp
              "test.ts")

             ("test.ts:2:7 - error TS2322: Type '2' is not assignable to type 'string'."
              ,typescript-tsc-pretty-error-regexp
              "test.ts")
             ))
    (let* ((text (car test-case))
           (regexp    (cadr test-case))
           (matched-file-name (cl-caddr test-case))
           (times     1))
      (with-temp-buffer
        (insert text)
        (goto-char (point-min))

        (re-search-forward regexp)
        (should
         (equal matched-file-name (match-string 1)))))))


(provide 'typescript-mode-general-tests)

;;; typescript-mode-general-tests.el ends here


================================================
FILE: typescript-mode-jsdoc-tests.el
================================================
;;; typescript-mode-jsdoc-tests --- This file contains JSDoc related tests for typescript-mode.el

;;; Commentary:
;; To understand the definition of JSDoc tag,
;; see  https://github.com/jsdoc3/jsdoc/blob/b21427343c7294bbf1f14c718a390f3e955e37cb/lib/jsdoc/tag.js#L153-L195
;; To know how to run the tests, see typescript-mode-tests.el

;;; Code:

(require 'ert)
(require 'typescript-mode)
(require 'typescript-mode-test-utilities)

(defun jsdoc-multiline-test (jsdoc-lines specs)
  "Perform a multi-line JSDoc test against specs.
`JSDOC-LINES' are converted into a multi-line JS comment, and
the comment is tested against `SPECS'.
For more information about how to write `SPECS', see `font-lock-test'."
  (let* ((unwrapped-comment-lines
          (mapcar (lambda (line) (concat " * " line "\n")) jsdoc-lines))
         (comment-lines
          (append '("/**\n") unwrapped-comment-lines '(" */"))))
    (font-lock-test
     (apply #'concat comment-lines)
     (cons
      '(1 . font-lock-comment-delimiter-face)
      specs))))

;; Internal tags (or essential tags)
;; See https://github.com/jsdoc3/jsdoc/blob/b21427343c7294bbf1f14c718a390f3e955e37cb/lib/jsdoc/tag/dictionary/definitions.js#L222-L256

(ert-deftest jsdoc/also-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @also tags and its alias."
  (jsdoc-multiline-test
   '(
     "@also"
     )
   '(
     ;; ("@also$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/also-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @also tags and its alias."
  (jsdoc-multiline-test
   '(
     "@also extra text"
     )
   '(
     ;; ("@also extra text" . typescript-jsdoc-tag)
     ("extra text" . font-lock-comment-face)
     ("text" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/also-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @also tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/description-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @description tags and its alias."
  (jsdoc-multiline-test
   '(
     "@description descriptionInSingleWord"
     "@description description about something"
     "@description"
     "multi-line description about other things"
     "@desc descInSingleWord"
     "@desc desc about something"
     "@desc"
     "multi-line desc about other things"
     )
   '(
     ("@description descriptionInSingleWord" . typescript-jsdoc-tag)
     ("descriptionInSingleWord" . font-lock-comment-face)
     ("@description description about something" . typescript-jsdoc-tag)
     ("description about something" . font-lock-comment-face)
     ("about something" . font-lock-comment-face)
     ("something" . font-lock-comment-face)
     ("@description$" . typescript-jsdoc-tag)
     ("multi-line description about other things" . font-lock-comment-face)
     ("@desc descInSingleWord" . typescript-jsdoc-tag)
     ("descInSingleWord" . font-lock-comment-face)
     ("@desc desc about something" . typescript-jsdoc-tag)
     ("desc about something" . font-lock-comment-face)
     ("about something" . font-lock-comment-face)
     ("something" . font-lock-comment-face)
     ("@desc$" . typescript-jsdoc-tag)
     ("multi-line desc about other things" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/description-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @description tags and its alias."
  (jsdoc-multiline-test
   '(
     "@description {DescriptionType}"
     "@desc {DescType}"
     )
   '(
     ("@description {DescriptionType}" . typescript-jsdoc-tag)
     ("{DescriptionType}" . font-lock-comment-face)
     ("@desc {DescType}" . typescript-jsdoc-tag)
     ("{DescType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/description-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @description tags and its alias."
  (jsdoc-multiline-test
   '(
     "@description"
     "@desc"
     )
   '(
     ;; ("@description$" . font-lock-comment-face)
     ;; ("@desc$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/kind-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @kind tags and its alias."
  (jsdoc-multiline-test
   '(
     "@kind class"
     "@kind constant"
     "@kind event"
     "@kind external"
     "@kind file"
     "@kind function"
     "@kind member"
     "@kind mixin"
     "@kind module"
     "@kind namespace"
     "@kind typedef"
     )
   '(
     ("@kind class" . typescript-jsdoc-tag)
     ("class" . typescript-jsdoc-value)
     ("@kind constant" . typescript-jsdoc-tag)
     ("constant" . typescript-jsdoc-value)
     ("@kind event" . typescript-jsdoc-tag)
     ("event" . typescript-jsdoc-value)
     ("@kind external" . typescript-jsdoc-tag)
     ("external" . typescript-jsdoc-value)
     ("@kind file" . typescript-jsdoc-tag)
     ("file" . typescript-jsdoc-value)
     ("@kind function" . typescript-jsdoc-tag)
     ("function" . typescript-jsdoc-value)
     ("@kind member" . typescript-jsdoc-tag)
     ("member" . typescript-jsdoc-value)
     ("@kind mixin" . typescript-jsdoc-tag)
     ("mixin" . typescript-jsdoc-value)
     ("@kind module" . typescript-jsdoc-tag)
     ("module" . typescript-jsdoc-value)
     ("@kind namespace" . typescript-jsdoc-tag)
     ("namespace" . typescript-jsdoc-value)
     ("@kind typedef" . typescript-jsdoc-tag)
     ("typedef" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/kind-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @kind tags and its alias."
  (jsdoc-multiline-test
   '(
     "@kind meaninglessKind"
     "@kind {KindType}"
     )
   '(
     ("@kind meaninglessKind" . typescript-jsdoc-tag)
     ("meaninglessKind" . typescript-jsdoc-value)
     ("@kind {KindType}" . typescript-jsdoc-tag)
     ("{KindType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/kind-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @kind tags and its alias."
  (jsdoc-multiline-test
   '(
     "@kind"
     )
   '(
     ("@kind$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/name-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @name tags and its alias."
  (jsdoc-multiline-test
   '(
     "@name someName"
     )
   '(
     ("@name someName" . typescript-jsdoc-tag)
     ("someName" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/name-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @name tags and its alias."
  (jsdoc-multiline-test
   '(
     "@name {NameType}"
     )
   '(
     ("@name {NameType}" . typescript-jsdoc-tag)
     ("{NameType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/name-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @name tags and its alias."
  (jsdoc-multiline-test
   '(
     "@name"
     )
   '(
     ("@name$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/undocumented-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @undocumented tags and its alias."
  (jsdoc-multiline-test
   '(
     "@undocumented"
     )
   '(
     ;; ("@undocumented" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/undocumented-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @undocumented tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/undocumented-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @undocumented tags and its alias."
  (jsdoc-multiline-test
   '(
     "@undocumented invalidValue"
     "@undocumented {InvalidType}"
     )
   '(
     ("@undocumented invalidValue" . font-lock-comment-face)
     ("invalidValue" . font-lock-comment-face)
     ("@undocumented {InvalidType}" . font-lock-comment-face)
     ("{InvalidType}" . font-lock-comment-face)
     )))

;; Basic tags
;; See https://github.com/jsdoc3/jsdoc/blob/b21427343c7294bbf1f14c718a390f3e955e37cb/lib/jsdoc/tag/dictionary/definitions.js#L260-L858
;; for details of following tag tests

(ert-deftest jsdoc/abstract-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @abstract tags and its alias."
  (jsdoc-multiline-test
   '(
     "@abstract"
     "@virtual"
     )
   '(
     ("@abstract" . typescript-jsdoc-tag)
     ("@virtual" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/abstract-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @abstract tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/abstract-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @abstract tags and its alias."
  (jsdoc-multiline-test
   '(
     "@abstract invalid extra value0"
     "@abstract {InvalidType0}"
     "@virtual invalid extra value1"
     "@virtual {InvalidType1}"
     )
   '(
     ("@abstract invalid extra value0" . typescript-jsdoc-tag)
     ("invalid extra value0" . font-lock-comment-face)
     ("extra value0" . font-lock-comment-face)
     ("value0" . font-lock-comment-face)
     ("@abstract {InvalidType0}" . typescript-jsdoc-tag)
     ("{InvalidType0}" . font-lock-comment-face)
     ("@virtual invalid extra value1" . typescript-jsdoc-tag)
     ("invalid extra value1" . font-lock-comment-face)
     ("extra value1" . font-lock-comment-face)
     ("value1" . font-lock-comment-face)
     ("@virtual {InvalidType1}" . typescript-jsdoc-tag)
     ("{InvalidType1}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/access-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @access tags and its alias."
  (jsdoc-multiline-test
   '(
     "@access package"
     "@access private"
     "@access protected"
     "@access public"
     )
   '(
     ("@access package" . typescript-jsdoc-tag)
     ("package" . typescript-jsdoc-value)
     ("@access private" . typescript-jsdoc-tag)
     ("private" . typescript-jsdoc-value)
     ("@access protected" . typescript-jsdoc-tag)
     ("protected" . typescript-jsdoc-value)
     ("@access public" . typescript-jsdoc-tag)
     ("public" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/access-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @access tags and its alias."
  (jsdoc-multiline-test
   '(
     "@access meaninglessAccess"
     "@access {AccessType}"
     )
   '(
     ("@access meaninglessAccess" . typescript-jsdoc-tag)
     ("meaninglessAccess" . typescript-jsdoc-value)
     ("@access {AccessType}" . typescript-jsdoc-tag)
     ("{AccessType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/access-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @access tags and its alias."
  (jsdoc-multiline-test
   '(
     "@access"
     )
   '(
     ("@access$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/alias-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @alias tags and its alias."
  (jsdoc-multiline-test
   '(
     "@alias exampleAlias0"
     "@alias somenamespace.exampleAlias1"
     )
   '(
     ("@alias exampleAlias0" . typescript-jsdoc-tag)
     ("exampleAlias0" . typescript-jsdoc-value)
     ("@alias somenamespace.exampleAlias1" . typescript-jsdoc-tag)
     ("somenamespace.exampleAlias1" . typescript-jsdoc-value)
     ("exampleAlias1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/alias-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @alias tags and its alias."
  (jsdoc-multiline-test
   '(
     "@alias multiple words"
     "@alias {AliasType}"
     )
   '(
     ("@alias multiple words" . typescript-jsdoc-tag)
     ("multiple words" . typescript-jsdoc-value)
     ;; ("words" . typescript-jsdoc-value)
     ("@alias {AliasType}" . typescript-jsdoc-tag)
     ("{AliasType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/alias-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @alias tags and its alias."
  (jsdoc-multiline-test
   '(
     "@alias"
     )
   '(
     ("@alias$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/async-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @async tags and its alias."
  (jsdoc-multiline-test
   '(
     "@async"
     )
   '(
     ("@async" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/async-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @async tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/async-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @async tags and its alias."
  (jsdoc-multiline-test
   '(
     "@async invalid extra value"
     "@async {InvalidType}"
     )
   '(
     ("@async invalid extra value" . typescript-jsdoc-tag)
     ("invalid extra value" . font-lock-comment-face)
     ("extra value" . font-lock-comment-face)
     ("value" . font-lock-comment-face)
     ("@async {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/augments-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @augments tags and its alias."
  (jsdoc-multiline-test
   '(
     "@augments ExampleAugmented0"
     "@augments {ExampleAugmented1}"
     "@extends ExampleExtended0"
     "@extends {ExampleExtended1}"
     )
   '(
     ("@augments ExampleAugmented0" . typescript-jsdoc-tag)
     ("ExampleAugmented0" . typescript-jsdoc-value)
     ("@augments {ExampleAugmented1}" . typescript-jsdoc-tag)
     ;; ("{ExampleAugmented1}" . typescript-jsdoc-type)
     ("@extends ExampleExtended0" . typescript-jsdoc-tag)
     ("ExampleExtended0" . typescript-jsdoc-value)
     ("@extends {ExampleExtended1}" . typescript-jsdoc-tag)
     ;; ("{ExampleExtended1}" . typescript-jsdoc-type)
     )))

(ert-deftest jsdoc/augments-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @augments tags and its alias."
  (jsdoc-multiline-test
   '(
     "@augments {ExampleAugmented0} extra augments value"
     "@extends {ExampleExtended0} extra extends value"
     )
   '(
     ("@augments {ExampleAugmented0} extra augments value" . typescript-jsdoc-tag)
     ;; ("{ExampleAugmented0} extra augments value" . typescript-jsdoc-type)
     ("extra augments value" . font-lock-comment-face)
     ("augments value" . font-lock-comment-face)
     ("value" . font-lock-comment-face)
     ("@extends {ExampleExtended0} extra extends value" . typescript-jsdoc-tag)
     ;; ("{ExampleExtended0} extra extends value" . typescript-jsdoc-type)
     ("extra extends value" . font-lock-comment-face)
     ("extends value" . font-lock-comment-face)
     ("value" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/augments-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @augments tags and its alias."
  (jsdoc-multiline-test
   '(
     "@augments"
     "@extends"
     )
   '(
     ("@augments$" . font-lock-comment-face)
     ;; ("@extends$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/author-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @author tags and its alias."
  (jsdoc-multiline-test
   '(
     "@author Exampleauthor"
     "@author Exampleauthor Withfamilyname"
     "@author Exampleauthor <example@author.email>"
     )
   '(
     ("@author Exampleauthor$" . typescript-jsdoc-tag)
     ;; ("Exampleauthor" . typescript-jsdoc-value)
     ("@author Exampleauthor Withfamilyname" . typescript-jsdoc-tag)
     ;; ("Exampleauthor Withfamilyname" . typescript-jsdoc-value)
     ;; ("Withfamilyname" . typescript-jsdoc-value)
     ("@author Exampleauthor <example@author.email>" . typescript-jsdoc-tag)
     ;; ("Exampleauthor <example@author.email>" . typescript-jsdoc-value)
     ;; ("<example@author.email>" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/author-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @author tags and its alias."
  (jsdoc-multiline-test
   '(
     "@author {AuthorType}"
     )
   '(
     ("@author {AuthorType}" . typescript-jsdoc-tag)
     ;; ("{AuthorType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/author-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @author tags and its alias."
  (jsdoc-multiline-test
   '(
     "@author"
     )
   '(
     ;; ("@author$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/borrows-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @borrows tags and its alias."
  (jsdoc-multiline-test
   '(
     "@borrows something0"
     "@borrows originalName as borrowedName"
     )
   '(
     ("@borrows something0" . typescript-jsdoc-tag)
     ("something0" . typescript-jsdoc-value)
     ("@borrows originalName as borrowedName" . typescript-jsdoc-tag)
     ("originalName as borrowedName" . typescript-jsdoc-value)
     ;; ("as borrowedName" . typescript-jsdoc-value)
     ;; ("borrowedName" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/borrows-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @borrows tags and its alias."
  (jsdoc-multiline-test
   '(
     "@borrows meaningless multiple words"
     "@borrows {BorrowType}"
     )
   '(
     ("@borrows meaningless multiple words" . typescript-jsdoc-tag)
     ("meaningless multiple words" . typescript-jsdoc-value)
     ;; ("multiple words" . typescript-jsdoc-value)
     ;; ("words" . typescript-jsdoc-value)
     ("@borrows {BorrowType}" . typescript-jsdoc-tag)
     ("{BorrowType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/borrows-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @borrows tags and its alias."
  (jsdoc-multiline-test
   '(
     "@borrows"
     "@borrows {InvalidType}"
     )
   '(
     ("@borrows$" . font-lock-comment-face)
     ;; ("@borrows {InvalidType}" . font-lock-comment-face)
     ;; ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/class-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @class tags and its alias."
  (jsdoc-multiline-test
   '(
     ;; See https://github.com/jsdoc3/jsdoc/blob/b21427343c7294bbf1f14c718a390f3e955e37cb/lib/jsdoc/tag/dictionary/definitions.js#L318-L340
     "@class"
     "@class ExampleClass"
     "@class Class tag for description0"
     "@class"
     "Class tag for description1"
     "@constructor"
     "@constructor ExampleClassConstructor"
     ;; You cannot use @constructor to describe class
     )
   '(
     ("@class$" . typescript-jsdoc-tag)
     ("@class ExampleClass" . typescript-jsdoc-tag)
     ;; ("ExampleClass" . typescript-jsdoc-value)
     ("@class Class tag for description0" . typescript-jsdoc-tag)
     ("Class tag for description0" . font-lock-comment-face)
     ("tag for description0" . font-lock-comment-face)
     ("for description0" . font-lock-comment-face)
     ("description0" . font-lock-comment-face)
     ("Class tag for description1" . font-lock-comment-face)
     ("tag for description1" . font-lock-comment-face)
     ("for description1" . font-lock-comment-face)
     ("description1" . font-lock-comment-face)
     ("@constructor" . typescript-jsdoc-tag)
     ;; ("ExampleClassConstructor" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/class-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @class tags and its alias."
  (jsdoc-multiline-test
   '(
     "@class {ClassType}"
     "@constructor {ConstructorType}"
     )
   '(
     ("@class {ClassType}" . typescript-jsdoc-tag)
     ;; ("{ClassType}" . typescript-jsdoc-value)
     ("@constructor {ConstructorType}" . typescript-jsdoc-tag)
     ;; ("{ConstructorType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/class-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @class tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/classdesc-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @classdesc tags and its alias."
  (jsdoc-multiline-test
   '(
     "@classdesc"
     "@classdesc This is class description0"
     "@classdesc"
     "This is class description1"
     )
   '(
     ("@classdesc$" . typescript-jsdoc-tag)
     ("@classdesc This is class description0" . typescript-jsdoc-tag)
     ("This is class description0" . font-lock-comment-face)
     ("is class description0" . font-lock-comment-face)
     ("class description0" . font-lock-comment-face)
     ("description0" . font-lock-comment-face)
     ("This is class description1" . font-lock-comment-face)
     ("is class description1" . font-lock-comment-face)
     ("class description1" . font-lock-comment-face)
     ("description1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/classdesc-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @classdesc tags and its alias."
  (jsdoc-multiline-test
   '(
     "@classdesc {ClassDescType}"
     )
   '(
     ("@classdesc {ClassDescType}" . typescript-jsdoc-tag)
     ("{ClassDescType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/classdesc-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @classdesc tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/constant-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @constant tags and its alias."
  (jsdoc-multiline-test
   '(
     "@constant"
     "@constant {ConstantType0}"
     "@constant constantName0"
     "@constant {ConstantType1} constantName1"
     "@const"
     "@const {ConstType0}"
     "@const constName0"
     "@const {ConstType1} constName1"
     )
   '(
     ("@constant$" . typescript-jsdoc-tag)
     ("@constant {ConstantType0}" . typescript-jsdoc-tag)
     ;; ("{ConstantType0}" . typescript-jsdoc-type)
     ("@constant constantName0" . typescript-jsdoc-tag)
     ;; ("constantName0" . typescript-jsdoc-value)
     ("@constant {ConstantType1} constantName1" . typescript-jsdoc-tag)
     ;; ("{ConstantType1} constantName1" . typescript-jsdoc-type)
     ;; ("constantName1" . typescript-jsdoc-value)
     ("@const$" . typescript-jsdoc-tag)
     ("@const {ConstType0}" . typescript-jsdoc-tag)
     ;; ("{ConstType0}" . typescript-jsdoc-type)
     ("@const constName0" . typescript-jsdoc-tag)
     ;; ("constName0" . typescript-jsdoc-value)
     ("@const {ConstType1} constName1" . typescript-jsdoc-tag)
     ;; ("{ConstType1} constName1" . typescript-jsdoc-type)
     ;; ("constName1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/constant-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @constant tags and its alias."
  (jsdoc-multiline-test
   '(
     "@constant extra value other than name for constant0"
     "@const extra value other than name for const0"
     )
   '(
     ("@constant extra value other than name for constant0" . typescript-jsdoc-tag)
     ;; ("extra value other than name for constant0" . typescript-jsdoc-value)
     ("value other than name for constant0" . font-lock-comment-face)
     ("other than name for constant0" . font-lock-comment-face)
     ("than name for constant0" . font-lock-comment-face)
     ("name for constant0" . font-lock-comment-face)
     ("for constant0" . font-lock-comment-face)
     ("constant0" . font-lock-comment-face)
     ("@const extra value other than name for const0" . typescript-jsdoc-tag)
     ;; ("extra value other than name for const0" . typescript-jsdoc-value)
     ("value other than name for const0" . font-lock-comment-face)
     ("other than name for const0" . font-lock-comment-face)
     ("than name for const0" . font-lock-comment-face)
     ("name for const0" . font-lock-comment-face)
     ("for const0" . font-lock-comment-face)
     ("const0" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/constant-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @constant tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/constructs-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @constructs tags and its alias."
  (jsdoc-multiline-test
   '(
     "@constructs"
     "@constructs className"
     "@constructs {@thisClass}"
     )
   '(
     ("@constructs$" . typescript-jsdoc-tag)
     ("@constructs className" . typescript-jsdoc-tag)
     ;; ("className" . typescript-jsdoc-value)
     ("@constructs {@thisClass}" . typescript-jsdoc-tag)
     ;; ("{@thisClass}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/constructs-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @constructs tags and its alias."
  (jsdoc-multiline-test
   '(
     "@constructs className and extra description"
     "@constructs {ClassType}"
     )
   '(
     ("@constructs className and extra description" . typescript-jsdoc-tag)
     ;; ("className and extra description" . typescript-jsdoc-value)
     ("and extra description" . font-lock-comment-face)
     ("extra description" . font-lock-comment-face)
     ("description" . font-lock-comment-face)
     ("@constructs {ClassType}" . typescript-jsdoc-tag)
     ;; ("{ClassType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/constructs-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @constructs tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/copyright-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @copyright tags and its alias."
  (jsdoc-multiline-test
   '(
     "@copyright Some copyright texts"
     )
   '(
     ("@copyright Some copyright texts" . typescript-jsdoc-tag)
     ("Some copyright texts" . font-lock-comment-face)
     ("copyright texts" . font-lock-comment-face)
     ("texts" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/copyright-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @copyright tags and its alias."
  (jsdoc-multiline-test
   '(
     "@copyright {InvalidType}"
     )
   '(
     ("@copyright {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/copyright-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @copyright tags and its alias."
  (jsdoc-multiline-test
   '(
     "@copyright"
     )
   '(
     ;; ("@copyright$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/default-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @default tags and its alias."
  (jsdoc-multiline-test
   '(
     "@default"
     "@default 5"
     "@default true"
     "@defaultvalue"
     "@defaultvalue null"
     "@defaultvalue \"abc\""
     )
   '(
     ("@default$" . typescript-jsdoc-tag)
     ("@default 5" . typescript-jsdoc-tag)
     ;; ("5" . typescript-jsdoc-value)
     ("@default true" . typescript-jsdoc-tag)
     ;; ("true" . typescript-jsdoc-value)
     ("@defaultvalue$" . typescript-jsdoc-tag)
     ("@defaultvalue null" . typescript-jsdoc-tag)
     ;; ("null" . typescript-jsdoc-value)
     ("@defaultvalue \"abc\"" . typescript-jsdoc-tag)
     ;; ("\"abc\"" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/default-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @default tags and its alias."
  (jsdoc-multiline-test
   '(
     "@default multiple values for default0"
     "@default {DefaultType}"
     "@defaultvalue multiple values for defaultvalue0"
     "@defaultvalue {DefaultValueType}"
     )
   '(
     ("@default multiple values for default0" . typescript-jsdoc-tag)
     ;; ("multiple values for default0" . typescript-jsdoc-value)
     ;; ("values for default0" . typescript-jsdoc-value)
     ;; ("for default0" . typescript-jsdoc-value)
     ;; ("default0" . typescript-jsdoc-value)
     ("@default {DefaultType}" . typescript-jsdoc-tag)
     ;; ("{DefaultType}" . typescript-jsdoc-value)
     ("@defaultvalue multiple values for defaultvalue0" . typescript-jsdoc-tag)
     ;; ("multiple values for defaultvalue0" . typescript-jsdoc-value)
     ;; ("values for defaultvalue0" . typescript-jsdoc-value)
     ;; ("for defaultvalue0" . typescript-jsdoc-value)
     ;; ("defaultvalue0" . typescript-jsdoc-value)
     ("@defaultvalue {DefaultValueType}" . typescript-jsdoc-tag)
     ;; ("{DefaultValueType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/default-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @default tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/deprecated-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @deprecated tags and its alias."
  (jsdoc-multiline-test
   '(
     "@deprecated"
     "@deprecated Some explanations about deprecation"
     )
   '(
     ("@deprecated$" . typescript-jsdoc-tag)
     ("@deprecated Some explanations about deprecation" . typescript-jsdoc-tag)
     ("Some explanations about deprecation" . font-lock-comment-face)
     ("explanations about deprecation" . font-lock-comment-face)
     ("about deprecation" . font-lock-comment-face)
     ("deprecation" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/deprecated-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @deprecated tags and its alias."
  (jsdoc-multiline-test
   '(
     "@deprecated {DeprecatedType}"
     )
   '(
     ("@deprecated {DeprecatedType}" . typescript-jsdoc-tag)
     ("{DeprecatedType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/deprecated-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @deprecated tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/enum-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @enum tags and its alias."
  (jsdoc-multiline-test
   '(
     "@enum"
     "@enum {EnumItemType}"
     )
   '(
     ("@enum$" . typescript-jsdoc-tag)
     ("@enum {EnumItemType}" . typescript-jsdoc-tag)
     ("{EnumItemType}" . typescript-jsdoc-type)
     )))

(ert-deftest jsdoc/enum-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @enum tags and its alias."
  (jsdoc-multiline-test
   '(
     "@enum meaningless description0"
     "@enum {EnumItemType} meaningless description1"
     )
   '(
     ("@enum meaningless description0" . typescript-jsdoc-tag)
     ("meaningless description0" . font-lock-comment-face)
     ("description0" . font-lock-comment-face)
     ("@enum {EnumItemType} meaningless description1" . typescript-jsdoc-tag)
     ("{EnumItemType} meaningless description1" . typescript-jsdoc-type)
     ("meaningless description1" . font-lock-comment-face)
     ("description1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/enum-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @enum tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/event-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @event tags and its alias."
  (jsdoc-multiline-test
   '(
     "@event"
     "@event SomeClass#exampleEvent"
     )
   '(
     ("@event$" . typescript-jsdoc-tag)
     ("@event SomeClass#exampleEvent" . typescript-jsdoc-tag)
     ;; ("SomeClass#exampleEvent" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/event-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @event tags and its alias."
  (jsdoc-multiline-test
   '(
     "@event justText"
     "@event {EventType}"
     )
   '(
     ("@event justText" . typescript-jsdoc-tag)
     ;; ("justText" . typescript-jsdoc-value)
     ("@event {EventType}" . typescript-jsdoc-tag)
     ;; ("{EventType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/event-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @event tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/example-tag-in-multiline-doc-comment-with-meaninglful-cases ()
  "Test for meaningful and valid usage of @example tags and its alias."
  (jsdoc-multiline-test
   '(
     "@example inlineExample with multiple terms0"
     "@example"
     "With multiline and multiple terms1"
     )
   '(
     ("@example inlineExample with multiple terms" . typescript-jsdoc-tag)
     ;; ("inlineExample with multiple terms" . typescript-jsdoc-value)
     ;; ("with multiple terms" . typescript-jsdoc-value)
     ;; ("multiple terms" . typescript-jsdoc-value)
     ;; ("terms" . typescript-jsdoc-value)
     ("@example$" . typescript-jsdoc-tag)
     ;; ("With multiline and multiple terms1" . typescript-jsdoc-value)
     ;; ("multiline and multiple terms1" . typescript-jsdoc-value)
     ;; ("and multiple terms1" . typescript-jsdoc-value)
     ;; ("multiple terms1" . typescript-jsdoc-value)
     ;; ("terms1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/example-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @example tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/example-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @example tags and its alias."
  (jsdoc-multiline-test
   '(
     "@example"
     )
   '(
     ;; ("@example$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/exports-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @exports tags and its alias."
  (jsdoc-multiline-test
   '(
     "@exports some/module"
     )
   '(
     ("@exports some/module" . typescript-jsdoc-tag)
     ;; ("some/module" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/exports-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @exports tags and its alias."
  (jsdoc-multiline-test
   '(
     "@exports justText"
     "@exports {ExportType}"
     )
   '(
     ("@exports justText" . typescript-jsdoc-tag)
     ;; ("justText" . typescript-jsdoc-value)
     ("@exports {ExportType}" . typescript-jsdoc-tag)
     ;; ("{ExportType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/exports-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @exports tags and its alias."
  (jsdoc-multiline-test
   '(
     "@exports"
     )
   '(
     ;; ("@exports$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/external-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @external tags and its alias."
  (jsdoc-multiline-test
   '(
     "@external"
     "@external String"
     "@external \"jQuery.fn\""
     "@external {ExternalType0}"
     "@external {ExternalType1} ExternalValue"
     "@host"
     "@host Boolean"
     "@host \"jQuery.fn.pluginNamespace\""
     "@host {HostType0}"
     "@host {HostType1} HostValue"
     )
   '(
     ;; ("@external$" . typescript-jsdoc-tag)
     ("@external String" . typescript-jsdoc-tag)
     ("String" . typescript-jsdoc-value)
     ("@external \"jQuery.fn\"" . typescript-jsdoc-tag)
     ("\"jQuery.fn\"" . typescript-jsdoc-value)
     ("@external {ExternalType0}" . typescript-jsdoc-tag)
     ;; ("{ExternalType0}" . typescript-jsdoc-type)
     ("@external {ExternalType1} ExternalValue" . typescript-jsdoc-tag)
     ;; ("{ExternalType1} ExternalValue" . typescript-jsdoc-type)
     ;; ("ExternalValue" . typescript-jsdoc-value)
     ;; ("@host$" . typescript-jsdoc-tag)
     ("@host Boolean" . typescript-jsdoc-tag)
     ("Boolean" . typescript-jsdoc-value)
     ("@host \"jQuery.fn.pluginNamespace\"" . typescript-jsdoc-tag)
     ("\"jQuery.fn.pluginNamespace\"" . typescript-jsdoc-value)
     ("@host {HostType0}" . typescript-jsdoc-tag)
     ;; ("{HostType0}" . typescript-jsdoc-type)
     ("@host {HostType1} HostValue" . typescript-jsdoc-tag)
     ;; ("{HostType1} HostValue" . typescript-jsdoc-type)
     ;; ("HostValue" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/external-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @external tags and its alias."
  (jsdoc-multiline-test
   '(
     "@external multiple words0"
     "@host multiple words1"
     )
   '(
     ("@external multiple words0" . typescript-jsdoc-tag)
     ("multiple words0" . typescript-jsdoc-value)
     ;; ("words0" . typescript-jsdoc-value)
     ("@host multiple words1" . typescript-jsdoc-tag)
     ("multiple words1" . typescript-jsdoc-value)
     ;; ("words1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/external-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @external tags and its alias."
  (jsdoc-multiline-test
   '(
     "@external"
     )
   '(
     ;; ("@external$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/file-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @file tags and its alias."
  (jsdoc-multiline-test
   '(
     "@file"
     "@file description for file0"
     "@fileoverview"
     "@fileoverview description for file1"
     "@overview"
     "@overview description for file2"
     )
   '(
     ("@file$" . typescript-jsdoc-tag)
     ("@file description for file0" . typescript-jsdoc-tag)
     ("description for file0" . font-lock-comment-face)
     ("for file0" . font-lock-comment-face)
     ("file0" . font-lock-comment-face)
     ("@fileoverview$" . typescript-jsdoc-tag)
     ("@fileoverview description for file1" . typescript-jsdoc-tag)
     ("description for file1" . font-lock-comment-face)
     ("for file1" . font-lock-comment-face)
     ("file1" . font-lock-comment-face)
     ("@overview$" . typescript-jsdoc-tag)
     ("@overview description for file2" . typescript-jsdoc-tag)
     ("description for file2" . font-lock-comment-face)
     ("for file2" . font-lock-comment-face)
     ("file2" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/file-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @file tags and its alias."
  (jsdoc-multiline-test
   '(
     "@file {FileType}"
     "@fileoverview {FileOverviewType}"
     "@overview {OverviewType}"
     )
   '(
     ("@file {FileType}" . typescript-jsdoc-tag)
     ("{FileType}" . font-lock-comment-face)
     ("@fileoverview {FileOverviewType}" . typescript-jsdoc-tag)
     ("{FileOverviewType}" . font-lock-comment-face)
     ("@overview {OverviewType}" . typescript-jsdoc-tag)
     ("{OverviewType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/file-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @file tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/fires-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @fires tags and its alias."
  (jsdoc-multiline-test
   '(
     "@fires SomeClass#eventName0"
     "@emits SomeClass#eventName1"
     )
   '(
     ("@fires SomeClass#eventName0" . typescript-jsdoc-tag)
     ("SomeClass#eventName0" . typescript-jsdoc-value)
     ("@emits SomeClass#eventName1" . typescript-jsdoc-tag)
     ("SomeClass#eventName1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/fires-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @fires tags and its alias."
  (jsdoc-multiline-test
   '(
     "@fires just text"
     "@fires {FiresType}"
     "@emits any text"
     "@emits {EmitsType}"
     )
   '(
     ("@fires just text" . typescript-jsdoc-tag)
     ("just text" . typescript-jsdoc-value)
     ("text" . font-lock-comment-face)
     ("@fires {FiresType}" . typescript-jsdoc-tag)
     ("{FiresType}" . typescript-jsdoc-value)
     ("@emits any text" . typescript-jsdoc-tag)
     ("any text" . typescript-jsdoc-value)
     ("text" . font-lock-comment-face)
     ("@emits {EmitsType}" . typescript-jsdoc-tag)
     ("{EmitsType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/fires-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @fires tags and its alias."
  (jsdoc-multiline-test
   '(
     "@fires"
     "@emits"
     )
   '(
     ("@fires$" . font-lock-comment-face)
     ("@emits$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/function-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @function tags and its alias."
  (jsdoc-multiline-test
   '(
     "@function"
     "@function functionName"
     "@func"
     "@func funcName"
     "@method"
     "@method methodName"
     )
   '(
     ("@function$" . typescript-jsdoc-tag)
     ("@function functionName" . typescript-jsdoc-tag)
     ("functionName" . typescript-jsdoc-value)
     ("@func$" . typescript-jsdoc-tag)
     ("@func funcName" . typescript-jsdoc-tag)
     ("funcName" . typescript-jsdoc-value)
     ("@method$" . typescript-jsdoc-tag)
     ("@method methodName" . typescript-jsdoc-tag)
     ("methodName" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/function-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @function tags and its alias."
  (jsdoc-multiline-test
   '(
     "@function multiple words for function0"
     "@function {FunctionType}"
     "@func multiple words for func0"
     "@func {FuncType}"
     "@method multiple words for method0"
     "@method {MethodType}"
     )
   '(
     ("@function multiple words for function0" . typescript-jsdoc-tag)
     ("multiple words for function0" . typescript-jsdoc-value)
     ("words for function0" . font-lock-comment-face)
     ("for function0" . font-lock-comment-face)
     ("function0" . font-lock-comment-face)
     ("@function {FunctionType}" . typescript-jsdoc-tag)
     ("{FunctionType}" . typescript-jsdoc-value)
     ("@func multiple words for func0" . typescript-jsdoc-tag)
     ("multiple words for func0" . typescript-jsdoc-value)
     ("words for func0" . font-lock-comment-face)
     ("for func0" . font-lock-comment-face)
     ("func0" . font-lock-comment-face)
     ("@func {FuncType}" . typescript-jsdoc-tag)
     ("{FuncType}" . typescript-jsdoc-value)
     ("@method multiple words for method0" . typescript-jsdoc-tag)
     ("multiple words for method0" . typescript-jsdoc-value)
     ("words for method0" . font-lock-comment-face)
     ("for method0" . font-lock-comment-face)
     ("method0" . font-lock-comment-face)
     ("@method {MethodType}" . typescript-jsdoc-tag)
     ("{MethodType}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/function-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @function tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/generator-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @generator tags and its alias."
  (jsdoc-multiline-test
   '(
     "@generator"
     )
   '(
     ("@generator$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/generator-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @generator tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/generator-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @generator tags and its alias."
  (jsdoc-multiline-test
   '(
     "@generator invalid extra values"
     "@generator {InvalidType}"
     )
   '(
     ("@generator invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@generator {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/global-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @global tags and its alias."
  (jsdoc-multiline-test
   '(
     "@global"
     )
   '(
     ("@global$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/global-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @global tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/global-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @global tags and its alias."
  (jsdoc-multiline-test
   '(
     "@global invalid extra values"
     "@global {InvalidType}"
     )
   '(
     ("@global invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@global {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/hideconstructor-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @hideconstructor tags and its alias."
  (jsdoc-multiline-test
   '(
     "@hideconstructor"
     )
   '(
     ("@hideconstructor$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/hideconstructor-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @hideconstructor tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/hideconstructor-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @hideconstructor tags and its alias."
  (jsdoc-multiline-test
   '(
     "@hideconstructor invalid extra values"
     "@hideconstructor {InvalidType}"
     )
   '(
     ("@hideconstructor invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@hideconstructor {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/ignore-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @ignore tags and its alias."
  (jsdoc-multiline-test
   '(
     "@ignore"
     )
   '(
     ("@ignore$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/ignore-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @ignore tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/ignore-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @ignore tags and its alias."
  (jsdoc-multiline-test
   '(
     "@ignore invalid extra values"
     "@ignore {InvalidType}"
     )
   '(
     ("@ignore invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@ignore {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/implements-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @implements tags and its alias."
  (jsdoc-multiline-test
   '(
     "@implements SomeInterface"
     "@implements {OtherInterface}"
     )
   '(
     ("@implements SomeInterface" . typescript-jsdoc-tag)
     ;; ("SomeInterface" . typescript-jsdoc-value)
     ("@implements {OtherInterface}" . typescript-jsdoc-tag)
     ("{OtherInterface}" . typescript-jsdoc-type)
     )))

(ert-deftest jsdoc/implements-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @implements tags and its alias."
  (jsdoc-multiline-test
   '(
     "@implements {Interface0} Interface1"
     )
   '(
     ("@implements {Interface0} Interface1" . typescript-jsdoc-tag)
     ("{Interface0} Interface1" . typescript-jsdoc-type)
     ("Interface1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/implements-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @implements tags and its alias."
  (jsdoc-multiline-test
   '(
     "@implements"
     )
   '(
     ;; ("@implements$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/inheritdoc-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @inheritdoc tags and its alias."
  (jsdoc-multiline-test
   '(
     "@inheritdoc"
     )
   '(
     ("@inheritdoc$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/inheritdoc-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @inheritdoc tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/inheritdoc-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @inheritdoc tags and its alias."
  (jsdoc-multiline-test
   '(
     "@inheritdoc invalid extra values"
     "@inheritdoc {InvalidType}"
     )
   '(
     ("@inheritdoc invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@inheritdoc {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/inner-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @inner tags and its alias."
  (jsdoc-multiline-test
   '(
     "@inner"
     )
   '(
     ("@inner$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/inner-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @inner tags and its alias."
  (jsdoc-multiline-test
   '(
     "@inner extra values"
     "@inner {InnerType}"
     )
   '(
     ("@inner extra values" . typescript-jsdoc-tag)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@inner {InnerType}" . typescript-jsdoc-tag)
     ("{InnerType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/inner-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @inner tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/instance-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @instance tags and its alias."
  (jsdoc-multiline-test
   '(
     "@instance"
     )
   '(
     ("@instance$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/instance-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @instance tags and its alias."
  (jsdoc-multiline-test
   '(
     "@instance extra values"
     "@instance {InstanceType}"
     )
   '(
     ("@instance extra values" . typescript-jsdoc-tag)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@instance {InstanceType}" . typescript-jsdoc-tag)
     ("{InstanceType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/instance-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @instance tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/interface-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @interface tags and its alias."
  (jsdoc-multiline-test
   '(
     "@interface"
     "@interface InterfaceName"
     )
   '(
     ("@interface$" . typescript-jsdoc-tag)
     ("@interface InterfaceName" . typescript-jsdoc-tag)
     ;; ("InterfaceName" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/interface-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @interface tags and its alias."
  (jsdoc-multiline-test
   '(
     "@interface extra values"
     "@interface {InterfaceType0}"
     "@interface {InterfaceType1} AndName"
     )
   '(
     ("@interface extra values" . typescript-jsdoc-tag)
     ;; ("extra values" . typescript-jsdoc-value)
     ("values" . font-lock-comment-face)
     ("@interface {InterfaceType0}" . typescript-jsdoc-tag)
     ;; ("{InterfaceType0}" . typescript-jsdoc-value)
     ("@interface {InterfaceType1} AndName" . typescript-jsdoc-tag)
     ;; ("{InterfaceType1} AndName" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/interface-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @interface tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/lends-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @lends tags and its alias."
  (jsdoc-multiline-test
   '(
     "@lends"
     "@lends Something"
     "@lends Something.deeper"
     )
   '(
     ("@lends$" . typescript-jsdoc-tag)
     ("@lends Something" . typescript-jsdoc-tag)
     ;; ("Something" . typescript-jsdoc-value)
     ("@lends Something.deeper" . typescript-jsdoc-tag)
     ;; ("Something.deeper" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/lends-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @lends tags and its alias."
  (jsdoc-multiline-test
   '(
     "@lends {LendsType0}"
     "@lends {LendsType1} With.some.path"
     )
   '(
     ("@lends {LendsType0}" . typescript-jsdoc-tag)
     ;; ("{LendsType0}" . nil)
     ("@lends {LendsType1} With.some.path" . typescript-jsdoc-tag)
     ;; ("{LendsType1} With.some.path" . nil)
     ;; ("With.some.path" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/lends-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @lends tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/license-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @license tags and its alias."
  (jsdoc-multiline-test
   '(
     "@license Some-License-Name"
     "@license"
     "Some long license texts"
     )
   '(
     ("@license Some-License-Name" . typescript-jsdoc-tag)
     ("Some-License-Name" . font-lock-comment-face)
     ("@license$" . typescript-jsdoc-tag)
     ("Some long license texts" . font-lock-comment-face)
     ("long license texts" . font-lock-comment-face)
     ("license texts" . font-lock-comment-face)
     ("texts" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/license-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @license tags and its alias."
  (jsdoc-multiline-test
   '(
     "@license {LicenseType0}"
     "@license {LicenseType1} With more text"
     )
   '(
     ("@license {LicenseType0}" . typescript-jsdoc-tag)
     ("{LicenseType0}" . font-lock-comment-face)
     ("@license {LicenseType1} With more text" . typescript-jsdoc-tag)
     ("{LicenseType1} With more text" . font-lock-comment-face)
     ("With more text" . font-lock-comment-face)
     ("more text" . font-lock-comment-face)
     ("text" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/license-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @license tags and its alias."
  (jsdoc-multiline-test
   '(
     "@license"
     )
   '(
     ;; ("@license$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/listens-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @listens tags and its alias."
  (jsdoc-multiline-test
   '(
     "@listens event:nameOfEvent"
     )
   '(
     ("@listens event:nameOfEvent" . typescript-jsdoc-tag)
     ("event:nameOfEvent" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/listens-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @listens tags and its alias."
  (jsdoc-multiline-test
   '(
     "@listens extra text0"
     "@listens {ListenType0}"
     "@listens {ListenType1} and text1"
     )
   '(
     ("@listens extra text0" . typescript-jsdoc-tag)
     ("extra text0" . typescript-jsdoc-value)
     ;; ("text0" . typescript-jsdoc-value)
     ("@listens {ListenType0}" . typescript-jsdoc-tag)
     ("{ListenType0}" . typescript-jsdoc-value)
     ("@listens {ListenType1} and text1" . typescript-jsdoc-tag)
     ("{ListenType1} and text1" . typescript-jsdoc-value)
     ;; ("and text1" . typescript-jsdoc-value)
     ;; ("text1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/listens-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @listens tags and its alias."
  (jsdoc-multiline-test
   '(
     "@listens"
     )
   '(
     ("@listens$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/member-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @member tags and its alias."
  (jsdoc-multiline-test
   '(
     "@member"
     "@member {MemberType0}"
     "@member memberName0"
     "@member {MemberType1} memberName1"
     "@var"
     "@var {VarType0}"
     "@var varName0"
     "@var {VarType1} varName1"
     )
   '(
     ;; ("@member$" . typescript-jsdoc-tag)
     ("@member {MemberType0}" . typescript-jsdoc-tag)
     ;; ("{MemberType0}" . typescript-jsdoc-type)
     ("@member memberName0" . typescript-jsdoc-tag)
     ("memberName0" . typescript-jsdoc-value)
     ("@member {MemberType1} memberName1" . typescript-jsdoc-tag)
     ;; ("{MemberType1} memberName1" . typescript-jsdoc-type)
     ;; ("memberName1" . typescript-jsdoc-value)
     ;; ("@var$" . typescript-jsdoc-tag)
     ("@var {VarType0}" . typescript-jsdoc-tag)
     ;; ;; ("{VarType0}" . typescript-jsdoc-type)
     ("@var varName0" . typescript-jsdoc-tag)
     ("varName0" . typescript-jsdoc-value)
     ("@var {VarType1} varName1" . typescript-jsdoc-tag)
     ;; ("{VarType1} varName1" . typescript-jsdoc-type)
     ;; ("varName1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/member-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @member tags and its alias."
  (jsdoc-multiline-test
   '(
     "@member extra value0"
     "@var extra value1"
     )
   '(
     ("@member extra value0" . typescript-jsdoc-tag)
     ("extra value0" . typescript-jsdoc-value)
     ("value0" . font-lock-comment-face)
     ("@var extra value1" . typescript-jsdoc-tag)
     ("extra value1" . typescript-jsdoc-value)
     ("value1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/member-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @member tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/memberof-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @memberof tags and its alias."
  (jsdoc-multiline-test
   '(
     "@memberof SomeClass0"
     "@memberof SomeClass1#"
     "@memberof <global>"
     "@memberof! OtherClass0"
     "@memberof! OtherClass1#"
     ;; "@memberof! <global>" is valid, but it is hard to test.
     )
   '(
     ("@memberof SomeClass0" . typescript-jsdoc-tag)
     ("SomeClass0" . typescript-jsdoc-value)
     ("@memberof SomeClass1#" . typescript-jsdoc-tag)
     ("SomeClass1#" . typescript-jsdoc-value)
     ("@memberof <global>" . typescript-jsdoc-tag)
     ("<global>" . typescript-jsdoc-value)
     ;; ("@memberof! OtherClass0" . typescript-jsdoc-tag)
     ;; ("OtherClass0" . typescript-jsdoc-value)
     ;; ("@memberof! OtherClass1#" . typescript-jsdoc-tag)
     ;; ("OtherClass1#" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/memberof-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @memberof tags and its alias."
  (jsdoc-multiline-test
   '(
     "@memberof extra text0"
     "@memberof {MemberOfType0}"
     "@memberof {MemberOfType1} and text1"
     "@memberof! again string0"
     "@memberof! {MemberOfForcedType0}"
     "@memberof! {MemberOfForcedType1} and more string1"
     )
   '(
     ("@memberof extra text0" . typescript-jsdoc-tag)
     ("extra text0" . typescript-jsdoc-value)
     ;; ("text0" . typescript-jsdoc-value)
     ("@memberof {MemberOfType0}" . typescript-jsdoc-tag)
     ("{MemberOfType0}" . typescript-jsdoc-value)
     ("@memberof {MemberOfType1} and text1" . typescript-jsdoc-tag)
     ("{MemberOfType1} and text1" . typescript-jsdoc-value)
     ;; ("and text1" . typescript-jsdoc-value)
     ;; ("text1" . typescript-jsdoc-value)
     ;; ("@memberof! again string0" . typescript-jsdoc-tag)
     ;; ("again string0" . typescript-jsdoc-value)
     ;; ("string0" . typescript-jsdoc-value)
     ;; ("@memberof! {MemberOfForcedType0}" . typescript-jsdoc-tag)
     ;; ("{MemberOfForcedType0}" . typescript-jsdoc-value)
     ;; ("@memberof! {MemberOfForcedType1} and more string1" . typescript-jsdoc-tag)
     ;; ("{MemberOfForcedType1} and more string1" . typescript-jsdoc-value)
     ;; ("and more string1" . typescript-jsdoc-value)
     ;; ("more string1" . typescript-jsdoc-value)
     ;; ("string1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/memberof-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @memberof tags and its alias."
  (jsdoc-multiline-test
   '(
     "@memberof"
     "@memberof!"
     )
   '(
     ("@memberof$" . font-lock-comment-face)
     ("@memberof!$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/mixes-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @mixes tags and its alias."
  (jsdoc-multiline-test
   '(
     "@mixes OtherObject"
     )
   '(
     ("@mixes OtherObject" . typescript-jsdoc-tag)
     ("OtherObject" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/mixes-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @mixes tags and its alias."
  (jsdoc-multiline-test
   '(
     "@mixes extra text0"
     "@mixes {MixesType0}"
     "@mixes {MixesType1} and text1"
     )
   '(
     ("@mixes extra text0" . typescript-jsdoc-tag)
     ("extra text0" . typescript-jsdoc-value)
     ("text0" . font-lock-comment-face)
     ("@mixes {MixesType0}" . typescript-jsdoc-tag)
     ("{MixesType0}" . typescript-jsdoc-value)
     ("@mixes {MixesType1} and text1" . typescript-jsdoc-tag)
     ("{MixesType1} and text1" . typescript-jsdoc-value)
     ("and text1" . font-lock-comment-face)
     ("text1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/mixes-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @mixes tags and its alias."
  (jsdoc-multiline-test
   '(
     "@mixes"
     )
   '(
     ("@mixes$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/mixin-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @mixin tags and its alias."
  (jsdoc-multiline-test
   '(
     "@mixin"
     "@mixin MixinName"
     )
   '(
     ("@mixin$" . typescript-jsdoc-tag)
     ("@mixin MixinName" . typescript-jsdoc-tag)
     ;; ("MixinName" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/mixin-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @mixin tags and its alias."
  (jsdoc-multiline-test
   '(
     "@mixin and extra text0"
     "@mixin {MixinType0}"
     "@mixin {MixinType1} with more text1"
     )
   '(
     ("@mixin and extra text0" . typescript-jsdoc-tag)
     ;; ("and extra text0" . typescript-jsdoc-value)
     ("extra text0" . font-lock-comment-face)
     ("text0" . font-lock-comment-face)
     ("@mixin {MixinType0}" . typescript-jsdoc-tag)
     ;; ("{MixinType0}" . typescript-jsdoc-value)
     ("@mixin {MixinType1} with more text1" . typescript-jsdoc-tag)
     ;; ("{MixinType1} with more text1" . typescript-jsdoc-value)
     ("with more text1" . font-lock-comment-face)
     ("more text1" . font-lock-comment-face)
     ("text1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/mixin-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @mixin tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

;; @modified tag is not yet released (It is a new tag of JSDoc 3.6.0)
(ert-deftest jsdoc/modifies-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @modifies tags and its alias."
  (jsdoc-multiline-test
   '(
     "@modifies"
     "@modifies {ModifiedType}"
     )
   '(
     ;; ("@modifies$" . typescript-jsdoc-tag)
     ;; ("@modifies {ModifiedType}" . typescript-jsdoc-tag)
     ;; ("{ModifiedType}" . typescript-jsdoc-type)
     )))

(ert-deftest jsdoc/modifies-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @modifies tags and its alias."
  (jsdoc-multiline-test
   '(
     "@modifies name0"
     "@modifies {ModifiedType} and name1"
     )
   '(
     ;; ("@modifies name0" . typescript-jsdoc-tag)
     ;; ("name0" . font-lock-comment-face)
     ;; ("@modifies {ModifiedType} and name1" . typescript-jsdoc-tag)
     ;; ("{ModifiedType} and name1" . typescript-jsdoc-type)
     ;; ("and name1" . font-lock-comment-face)
     ;; ("name1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/modifies-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @modifies tags and its alias."
  (jsdoc-multiline-test
   '(
     "@modifies"
     )
   '(
     ("@modifies$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/module-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @module tags and its alias."
  (jsdoc-multiline-test
   '(
     "@module"
     "@module ModuleName0"
     "@module {ModuleType0}"
     "@module {ModuleType1} ModuleName1"
     )
   '(
     ;; ("@module$" . typescript-jsdoc-tag)
     ("@module ModuleName0" . typescript-jsdoc-tag)
     ("ModuleName0" . typescript-jsdoc-value)
     ("@module {ModuleType0}" . typescript-jsdoc-tag)
     ;; ("{ModuleType0}" . typescript-jsdoc-type)
     ("@module {ModuleType1} ModuleName1" . typescript-jsdoc-tag)
     ;; ("{ModuleType1} ModuleName1" . typescript-jsdoc-type)
     ;; ("ModuleName1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/module-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @module tags and its alias."
  (jsdoc-multiline-test
   '(
     "@module with multiple words0"
     "@module {ModuleType} with multiple words1"
     )
   '(
     ("@module with multiple words0" . typescript-jsdoc-tag)
     ("with multiple words0" . typescript-jsdoc-value)
     ("multiple words0" . font-lock-comment-face)
     ("words0" . font-lock-comment-face)
     ("@module {ModuleType} with multiple words1" . typescript-jsdoc-tag)
     ;; ("{ModuleType} with multiple words1" . typescript-jsdoc-type)
     ;; ("with multiple words1" . typescript-jsdoc-value)
     ("multiple words1" . font-lock-comment-face)
     ("words1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/module-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @module tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/namespace-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @namespace tags and its alias."
  (jsdoc-multiline-test
   '(
     "@namespace"
     "@namespace Namespace0"
     "@namespace {NamespaceType0}"
     "@namespace {NamespaceType1} Namespace1"
     )
   '(
     ;; ("@namespace$" . typescript-jsdoc-tag)
     ("@namespace Namespace0" . typescript-jsdoc-tag)
     ("Namespace0" . typescript-jsdoc-value)
     ("@namespace {NamespaceType0}" . typescript-jsdoc-tag)
     ;; ("{NamespaceType0}" . typescript-jsdoc-type)
     ("@namespace {NamespaceType1} Namespace1" . typescript-jsdoc-tag)
     ;; ("{NamespaceType1} Namespace1" . typescript-jsdoc-type)
     ;; ("Namespace1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/namespace-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @namespace tags and its alias."
  (jsdoc-multiline-test
   '(
     "@namespace with multiple words0"
     "@namespace {NamespaceType} with multiple words1"
     )
   '(
     ("@namespace with multiple words0" . typescript-jsdoc-tag)
     ("with multiple words0" . typescript-jsdoc-value)
     ("multiple words0" . font-lock-comment-face)
     ("words0" . font-lock-comment-face)
     ("@namespace {NamespaceType} with multiple words1" . typescript-jsdoc-tag)
     ;; ("{NamespaceType} with multiple words1" . typescript-jsdoc-type)
     ;; ("with multiple words1" . typescript-jsdoc-value)
     ("multiple words1" . font-lock-comment-face)
     ("words1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/namespace-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @namespace tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/package-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @package tags and its alias."
  (jsdoc-multiline-test
   '(
     "@package"
     )
   '(
     ("@package$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/package-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @package tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/package-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @package tags and its alias."
  (jsdoc-multiline-test
   '(
     "@package invalid extra values"
     "@package {InvalidType}"
     )
   '(
     ("@package invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@package {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/param-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @param tags and its alias."
  (jsdoc-multiline-test
   '(
     "@param"
     "@param {ParamType0}"
     "@param paramName0"
     "@param {ParamType1} paramName1"
     "@param {ParamType2} paramName2 with paramDescription2"
     "@arg"
     "@arg {ArgType0}"
     "@arg argName0"
     "@arg {ArgType1} argName1"
     "@arg {ArgType2} argName2 with argDescription2"
     "@argument"
     "@argument {ArgumentType0}"
     "@argument argumentName0"
     "@argument {ArgumentType1} argumentName1"
     "@argument {ArgumentType2} argumentName2 with argumentDescription2"
     )
   '(
     ("@param$" . typescript-jsdoc-tag)
     ("@param {ParamType0}" . typescript-jsdoc-tag)
     ;; ("{ParamType0}" . typescript-jsdoc-type)
     ("@param paramName0" . typescript-jsdoc-tag)
     ("paramName0" . typescript-jsdoc-value)
     ("@param {ParamType1} paramName1" . typescript-jsdoc-tag)
     ("{ParamType1} paramName1" . typescript-jsdoc-type)
     ("paramName1" . typescript-jsdoc-value)
     ("@param {ParamType2} paramName2 with paramDescription2" . typescript-jsdoc-tag)
     ("{ParamType2} paramName2 with paramDescription2" . typescript-jsdoc-type)
     ("paramName2 with paramDescription2" . typescript-jsdoc-value)
     ("with paramDescription2" . font-lock-comment-face)
     ("paramDescription2" . font-lock-comment-face)
     ("@arg$" . typescript-jsdoc-tag)
     ("@arg {ArgType0}" . typescript-jsdoc-tag)
     ;; ("{ArgType0}" . typescript-jsdoc-type)
     ("@arg argName0" . typescript-jsdoc-tag)
     ("argName0" . typescript-jsdoc-value)
     ("@arg {ArgType1} argName1" . typescript-jsdoc-tag)
     ("{ArgType1} argName1" . typescript-jsdoc-type)
     ("argName1" . typescript-jsdoc-value)
     ("@arg {ArgType2} argName2 with argDescription2" . typescript-jsdoc-tag)
     ("{ArgType2} argName2 with argDescription2" . typescript-jsdoc-type)
     ("argName2 with argDescription2" . typescript-jsdoc-value)
     ("with argDescription2" . font-lock-comment-face)
     ("argDescription2" . font-lock-comment-face)
     ("@argument$" . typescript-jsdoc-tag)
     ("@argument {ArgumentType0}" . typescript-jsdoc-tag)
     ;; ("{ArgumentType0}" . typescript-jsdoc-type)
     ("@argument argumentName0" . typescript-jsdoc-tag)
     ("argumentName0" . typescript-jsdoc-value)
     ("@argument {ArgumentType1} argumentName1" . typescript-jsdoc-tag)
     ("{ArgumentType1} argumentName1" . typescript-jsdoc-type)
     ("argumentName1" . typescript-jsdoc-value)
     ("@argument {ArgumentType2} argumentName2 with argumentDescription2" . typescript-jsdoc-tag)
     ("{ArgumentType2} argumentName2 with argumentDescription2" . typescript-jsdoc-type)
     ("argumentName2 with argumentDescription2" . typescript-jsdoc-value)
     ("with argumentDescription2" . font-lock-comment-face)
     ("argumentDescription2" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/param-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @param tags and its alias."
  (jsdoc-multiline-test
   '(
     "@param extra value0"
     "@arg extra value1"
     "@argument extra value2"
     )
   '(
     ("@param extra value0" . typescript-jsdoc-tag)
     ("extra value0" . typescript-jsdoc-value)
     ("value0" . font-lock-comment-face)
     ("@arg extra value1" . typescript-jsdoc-tag)
     ("extra value1" . typescript-jsdoc-value)
     ("value1" . font-lock-comment-face)
     ("@argument extra value2" . typescript-jsdoc-tag)
     ("extra value2" . typescript-jsdoc-value)
     ("value2" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/param-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @param tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/private-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @private tags and its alias."
  (jsdoc-multiline-test
   '(
     "@private"
     )
   '(
     ("@private$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/private-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @private tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/private-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @private tags and its alias."
  (jsdoc-multiline-test
   '(
     "@private invalid extra values"
     "@private {InvalidType}"
     )
   '(
     ("@private invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@private {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/property-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @property tags and its alias."
  (jsdoc-multiline-test
   '(
     "@property {PropertyType0}"
     "@property propertyName0"
     "@property {PropertyType1} propertyName1"
     "@property {PropertyType2} propertyName2 with propertyDescription2"
     "@prop"
     "@prop {PropType0}"
     "@prop propName0"
     "@prop {PropType1} propName1"
     "@prop {PropType2} propName2 with propDescription2"
     )
   '(
     ("@property {PropertyType0}" . typescript-jsdoc-tag)
     ;; ("{PropertyType0}" . typescript-jsdoc-type)
     ("@property propertyName0" . typescript-jsdoc-tag)
     ("propertyName0" . typescript-jsdoc-value)
     ("@property {PropertyType1} propertyName1" . typescript-jsdoc-tag)
     ("{PropertyType1} propertyName1" . typescript-jsdoc-type)
     ("propertyName1" . typescript-jsdoc-value)
     ("@property {PropertyType2} propertyName2 with propertyDescription2" . typescript-jsdoc-tag)
     ("{PropertyType2} propertyName2 with propertyDescription2" . typescript-jsdoc-type)
     ("propertyName2 with propertyDescription2" . typescript-jsdoc-value)
     ("with propertyDescription2" . font-lock-comment-face)
     ("propertyDescription2" . font-lock-comment-face)
     ("@prop {PropType0}" . typescript-jsdoc-tag)
     ;; ("{PropType0}" . typescript-jsdoc-type)
     ("@prop propName0" . typescript-jsdoc-tag)
     ("propName0" . typescript-jsdoc-value)
     ("@prop {PropType1} propName1" . typescript-jsdoc-tag)
     ("{PropType1} propName1" . typescript-jsdoc-type)
     ("propName1" . typescript-jsdoc-value)
     ("@prop {PropType2} propName2 with propDescription2" . typescript-jsdoc-tag)
     ("{PropType2} propName2 with propDescription2" . typescript-jsdoc-type)
     ("propName2 with propDescription2" . typescript-jsdoc-value)
     ("with propDescription2" . font-lock-comment-face)
     ("propDescription2" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/property-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @property tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/property-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @property tags and its alias."
  (jsdoc-multiline-test
   '(
     "@property"
     "@prop"
     )
   '(
     ;; ("@property$" . font-lock-comment-face)
     ;; ("@prop$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/protected-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @protected tags and its alias."
  (jsdoc-multiline-test
   '(
     "@protected"
     )
   '(
     ("@protected$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/protected-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @protected tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/protected-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @protected tags and its alias."
  (jsdoc-multiline-test
   '(
     "@protected invalid extra values"
     "@protected {InvalidType}"
     )
   '(
     ("@protected invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@protected {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/public-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @public tags and its alias."
  (jsdoc-multiline-test
   '(
     "@public"
     )
   '(
     ("@public$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/public-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @public tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/public-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @public tags and its alias."
  (jsdoc-multiline-test
   '(
     "@public invalid extra values"
     "@public {InvalidType}"
     )
   '(
     ("@public invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@public {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/readonly-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @readonly tags and its alias."
  (jsdoc-multiline-test
   '(
     "@readonly"
     )
   '(
     ("@readonly$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/readonly-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @readonly tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/readonly-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @readonly tags and its alias."
  (jsdoc-multiline-test
   '(
     "@readonly invalid extra values"
     "@readonly {InvalidType}"
     )
   '(
     ("@readonly invalid extra values" . typescript-jsdoc-tag)
     ("invalid extra values" . font-lock-comment-face)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@readonly {InvalidType}" . typescript-jsdoc-tag)
     ("{InvalidType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/requires-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @requires tags and its alias."
  (jsdoc-multiline-test
   '(
     "@requires SomeModuleName"
     "@requires module:path/to/module"
     "@requires {@link something}"
     )
   '(
     ("@requires SomeModuleName" . typescript-jsdoc-tag)
     ("SomeModuleName" . typescript-jsdoc-value)
     ("@requires module:path/to/module" . typescript-jsdoc-tag)
     ("module:path/to/module" . typescript-jsdoc-value)
     ("@requires {@link something}" . typescript-jsdoc-tag)
     ("{@link something}" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/requires-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @requires tags and its alias."
  (jsdoc-multiline-test
   '(
     "@requires extra text0"
     "@requires {RequiresType0}"
     "@requires {RequiresType1} and text1"
     )
   '(
     ("@requires extra text0" . typescript-jsdoc-tag)
     ("extra text0" . typescript-jsdoc-value)
     ("text0" . font-lock-comment-face)
     ("@requires {RequiresType0}" . typescript-jsdoc-tag)
     ("{RequiresType0}" . typescript-jsdoc-value)
     ("@requires {RequiresType1} and text1" . typescript-jsdoc-tag)
     ("{RequiresType1} and text1" . typescript-jsdoc-value)
     ("and text1" . font-lock-comment-face)
     ("text1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/requires-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @requires tags and its alias."
  (jsdoc-multiline-test
   '(
     "@requires"
     )
   '(
     ;; ("@requires$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/returns-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @returns tags and its alias."
  (jsdoc-multiline-test
   '(
     "@returns description for returned value0"
     "@returns {ReturnType1} description for returned value1"
     "@return description for returned value2"
     "@return {ReturnType3} description for returned value3"
     )
   '(
     ("@returns description for returned value0" . typescript-jsdoc-tag)
     ("description for returned value0" . font-lock-comment-face)
     ("for returned value0" . font-lock-comment-face)
     ("returned value0" . font-lock-comment-face)
     ("value0" . font-lock-comment-face)
     ("@returns {ReturnType1} description for returned value1" . typescript-jsdoc-tag)
     ("{ReturnType1} description for returned value1" . typescript-jsdoc-type)
     ("description for returned value1" . font-lock-comment-face)
     ("for returned value1" . font-lock-comment-face)
     ("returned value1" . font-lock-comment-face)
     ("value1" . font-lock-comment-face)
     ("@return description for returned value2" . typescript-jsdoc-tag)
     ("description for returned value2" . font-lock-comment-face)
     ("for returned value2" . font-lock-comment-face)
     ("returned value2" . font-lock-comment-face)
     ("value2" . font-lock-comment-face)
     ("@return {ReturnType3} description for returned value3" . typescript-jsdoc-tag)
     ("{ReturnType3} description for returned value3" . typescript-jsdoc-type)
     ("description for returned value3" . font-lock-comment-face)
     ("for returned value3" . font-lock-comment-face)
     ("returned value3" . font-lock-comment-face)
     ("value3" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/returns-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @returns tags and its alias."
  (jsdoc-multiline-test
   '(
     )
   '(
     )))

(ert-deftest jsdoc/returns-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @returns tags and its alias."
  (jsdoc-multiline-test
   '(
     "@returns"
     "@return"
     )
   '(
     ;; ("@returns$" . font-lock-comment-face)
     ;; ("@return$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/see-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @see tags and its alias."
  (jsdoc-multiline-test
   '(
     "@see someName.path"
     "@see {@link something}"
     "@see any other text"
     )
   '(
     ;; ("@see someName.path" . typescript-jsdoc-tag)
     ;; ("someName.path" . typescript-jsdoc-value)
     ;; ("@see {@link something}" . typescript-jsdoc-tag)
     ;; ("{@link something}" . typescript-jsdoc-value)
     ;; ("@see any other text" . typescript-jsdoc-tag)
     ;; ("any other text" . typescript-jsdoc-value)
     ;; ("other text" . typescript-jsdoc-value)
     ;; ("text" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/see-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @see tags and its alias."
  (jsdoc-multiline-test
   '(
     "@see {SeeType0}"
     "@see {SeeType1} and text1"
     )
   '(
     ;; ("@see {SeeType0}" . typescript-jsdoc-tag)
     ;; ("{SeeType0}" . typescript-jsdoc-value)
     ;; ("@see {SeeType1} and text1" . typescript-jsdoc-tag)
     ;; ("{SeeType1} and text1" . typescript-jsdoc-value)
     ;; ("and text1" . typescript-jsdoc-value)
     ;; ("text1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/see-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @see tags and its alias."
  (jsdoc-multiline-test
   '(
     "@see"
     )
   '(
     ("@see$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/since-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @since tags and its alias."
  (jsdoc-multiline-test
   '(
     "@since 1.0.1"
     )
   '(
     ("@since 1.0.1" . typescript-jsdoc-tag)
     ("1.0.1" . typescript-jsdoc-value)
     )))

(ert-deftest jsdoc/since-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @since tags and its alias."
  (jsdoc-multiline-test
   '(
     "@since some extra text0"
     "@since {SinceType0}"
     "@since {SinceType1} and text1"
     )
   '(
     ("@since some extra text0" . typescript-jsdoc-tag)
     ("some extra text0" . typescript-jsdoc-value)
     ("extra text0" . font-lock-comment-face)
     ("text0" . font-lock-comment-face)
     ("@since {SinceType0}" . typescript-jsdoc-tag)
     ("{SinceType0}" . typescript-jsdoc-value)
     ("@since {SinceType1} and text1" . typescript-jsdoc-tag)
     ("{SinceType1} and text1" . typescript-jsdoc-value)
     ("and text1" . font-lock-comment-face)
     ("text1" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/since-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @since tags and its alias."
  (jsdoc-multiline-test
   '(
     "@since"
     )
   '(
     ("@since$" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/static-tag-in-multiline-doc-comment-with-meaningful-cases ()
  "Test for meaningful and valid usage of @static tags and its alias."
  (jsdoc-multiline-test
   '(
     "@static"
     )
   '(
     ("@static$" . typescript-jsdoc-tag)
     )))

(ert-deftest jsdoc/static-tag-in-multiline-doc-comment-with-meaningless-cases ()
  "Test for meaningless though valid usage of @static tags and its alias."
  (jsdoc-multiline-test
   '(
     "@static extra values"
     "@static {StaticType}"
     )
   '(
     ("@static extra values" . typescript-jsdoc-tag)
     ("extra values" . font-lock-comment-face)
     ("values" . font-lock-comment-face)
     ("@static {StaticType}" . typescript-jsdoc-tag)
     ("{StaticType}" . font-lock-comment-face)
     )))

(ert-deftest jsdoc/static-tag-in-multiline-doc-comment-with-invalid-cases ()
  "Test for invalid usage of @static tags and its alias."
  (jsdoc-mult
Download .txt
gitextract_b8dm76p3/

├── .github/
│   └── workflows/
│       └── build.yml
├── .gitignore
├── Dockerfile
├── Eask
├── LICENSE
├── Makefile
├── README.md
├── test-files/
│   ├── indentation-reference-document.ts
│   ├── list-items-indent-comma-first.ts
│   ├── list-items-indent-default.ts
│   ├── switch-case-indent-default.ts
│   └── switch-case-indent-disabled.ts
├── typescript-mode-general-tests.el
├── typescript-mode-jsdoc-tests.el
├── typescript-mode-lexical-binding-tests.el
├── typescript-mode-test-utilities.el
├── typescript-mode-tests.el
└── typescript-mode.el
Download .txt
SYMBOL INDEX (71 symbols across 3 files)

FILE: test-files/indentation-reference-document.ts
  function getGlobalTypingsCacheLocation (line 23) | function getGlobalTypingsCacheLocation() {
  type NodeChildProcess (line 31) | interface NodeChildProcess {
  type SomeType (line 38) | type SomeType = string | number;
  class Logger (line 40) | class Logger implements ts.server.Logger {
    method constructor (line 50) | constructor(private readonly logFilename: string) {
    method padStringRight (line 54) | static padStringRight(str: string, padding: string) {
    method close (line 58) | close() {
  class WithAGeneratorFirst (line 81) | class WithAGeneratorFirst {
    method blah (line 82) | *blah() {
  class WithAGeneratorAfterAProperty (line 86) | class WithAGeneratorAfterAProperty {
    method blah (line 89) | *blah() {
  class WithAGeneratorAfterAnotherMethod (line 93) | class WithAGeneratorAfterAnotherMethod {
    method foo (line 94) | foo() {
    method blah (line 97) | *blah() {
  class WithSpaceAfterAsterisk (line 101) | class WithSpaceAfterAsterisk  {
    method bar (line 102) | bar() {
    method oops (line 105) | * oops() {
  class WithSpaceAfterParens (line 110) | class WithSpaceAfterParens  {
    method bar (line 111) | bar() {
    method oops (line 114) | *oops () {
  class WithArguments (line 118) | class WithArguments  {
    method bar (line 119) | bar() {
    method oops (line 122) | *oops(foo: number, bar: string) {
  class One (line 175) | class One {
    method instanceOf (line 176) | instanceOf(): void {
    method in (line 179) | in(): void {}
  class Two (line 183) | class Two {
    method instanceOf (line 186) | instanceOf(): void {
  function foo (line 204) | function foo(a: string,
  function foo (line 223) | function foo(a: RegExp, b: RegExp): void {
  function moo (line 235) | function moo(x: any,
  function moo2 (line 241) | function moo2(x: any,
  function foo (line 247) | function foo(x: any,
  class Moo (line 252) | class Moo {}
  function foo2 (line 255) | function foo2(x: any,
  function foo3 (line 261) | function foo3(a: number,
  function bar (line 267) | function bar(a: number,
  function bif (line 275) | function bif(a: number,
  function bif2 (line 282) | function bif2(a: number,
  function bif3 (line 288) | function bif3(a: number,
  function bif4 (line 294) | function bif4(a: number,
  function bif5 (line 300) | function bif5(a: number,
  function gogo (line 306) | function gogo(a: number,
  function foo5 (line 311) | function foo5(x: any,
  function foo6 (line 317) | function foo6(x: any,
  function foo7 (line 323) | function foo7(x: (a: string, b: string) => Array<number>,
  function foo7b (line 328) | function foo7b(a: string,
  function foo8 (line 332) | function foo8(): void {
  function foo12 (line 376) | function foo12(): void {
  function foo13 (line 477) | function foo13(something: string,
  function foo14 (line 484) | function foo14(something: string,
  function blipblop (line 493) | function blipblop(): void {
  type z (line 505) | type z      = {} // Zero argument
  type o (line 506) | type o<A>   = {} // One  argument
  type t (line 507) | type t<A,B> = {} // Two  arguments
  type x (line 516) | type x = t < z , z >
  class Q (line 553) | class Q<X> {
  type a (line 557) | type a<X> =
  type Something (line 562) | interface Something {
  class Fluff (line 568) | class Fluff<X extends Something> {
  type c (line 572) | type c<X extends Something = { a: string; b: string; c: -5; more: string }>
  type d (line 577) | type d<X extends Something = { +readonly [P in keyof Something]: Somethi...
  class Foo (line 581) | class Foo {
  type Foo (line 597) | interface Foo {
  class Foo (line 616) | class Foo { }
  type A (line 620) | type A = B<import('../file').T>
  type A (line 623) | type A = import('../file').B
  function test (line 632) | function test() {
  type Fnord (line 669) | interface Fnord {

FILE: test-files/switch-case-indent-default.ts
  function indentTest (line 1) | function indentTest(): any {

FILE: test-files/switch-case-indent-disabled.ts
  function getGlobalTypingsCacheLocation (line 1) | function getGlobalTypingsCacheLocation() {
Condensed preview — 18 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (364K chars).
[
  {
    "path": ".github/workflows/build.yml",
    "chars": 1106,
    "preview": "name: Build & Test\n\non:\n  push:\n    branches: [ master ]\n  pull_request:\n    branches: [ master ]\n  # Allows you to run "
  },
  {
    "path": ".gitignore",
    "chars": 1255,
    "preview": "\n# Created by https://www.gitignore.io/api/emacs,windows,linux\n\n### Emacs ###\n# -*- mode: gitignore; -*-\n*~\n\\#*\\#\n/.emac"
  },
  {
    "path": "Dockerfile",
    "chars": 312,
    "preview": "FROM ubuntu:bionic\n\nRUN apt-get update && \\\n  apt-get install -y \\\n  make curl python git emacs\n\nRUN curl -fsSL https://"
  },
  {
    "path": "Eask",
    "chars": 429,
    "preview": "(package \"typescript-mode\"\n         \"0.4\"\n         \"Major mode for editing typescript\")\n\n(website-url \"http://github.com"
  },
  {
    "path": "LICENSE",
    "chars": 35147,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "Makefile",
    "chars": 374,
    "preview": "EMACS ?= emacs\nEASK ?= eask\nELS = \\\n  typescript-mode.el \\\n  typescript-mode-test-utilities.el \\\n  typescript-mode-gener"
  },
  {
    "path": "README.md",
    "chars": 4362,
    "preview": "# typescript.el\n\n![Build & Test](https://github.com/emacs-typescript/typescript.el/workflows/Build%20&%20Test/badge.svg)"
  },
  {
    "path": "test-files/indentation-reference-document.ts",
    "chars": 15547,
    "preview": "/// <reference types=\"node\" />\n/// <reference path=\"shared.ts\" />\n/// <reference path=\"session.ts\" />\n// used in fs.writ"
  },
  {
    "path": "test-files/list-items-indent-comma-first.ts",
    "chars": 463,
    "preview": "const arr =\n    [ 'one'\n    , 'two'\n    , 'three' ];\n\nconst obj =\n    { a: 111\n    , b: 222\n    , c: 333 };\n\nconst depth"
  },
  {
    "path": "test-files/list-items-indent-default.ts",
    "chars": 509,
    "preview": "const arr =\n    [ 'one'\n      , 'two'\n      , 'three' ];\n\nconst obj =\n    { a: 111\n      , b: 222\n      , c: 333 };\n\ncon"
  },
  {
    "path": "test-files/switch-case-indent-default.ts",
    "chars": 1079,
    "preview": "function indentTest(): any {\n    const obj = {\n        case: 1,\n        default: 2\n    };\n\n    // This function was spec"
  },
  {
    "path": "test-files/switch-case-indent-disabled.ts",
    "chars": 809,
    "preview": "function getGlobalTypingsCacheLocation() {\n    const obj = {\n        case: 1,\n        default: 2\n    };\n    switch (proc"
  },
  {
    "path": "typescript-mode-general-tests.el",
    "chars": 47373,
    "preview": ";;; typescript-mode-general-tests --- This file contains general tests for typescript-mode.el\n\n;;; Commentary:\n;; To kno"
  },
  {
    "path": "typescript-mode-jsdoc-tests.el",
    "chars": 108288,
    "preview": ";;; typescript-mode-jsdoc-tests --- This file contains JSDoc related tests for typescript-mode.el\n\n;;; Commentary:\n;; To"
  },
  {
    "path": "typescript-mode-lexical-binding-tests.el",
    "chars": 780,
    "preview": ";; -*- lexical-binding: t -*-\n;;; typescript-mode-lexical-binding-tests --- This file contains test for typescript-mode."
  },
  {
    "path": "typescript-mode-test-utilities.el",
    "chars": 2051,
    "preview": ";;; typescript-mode-test-utilities --- This file contains test utilities for typescript-mode.el\n\n;;; Commentary:\n;; See "
  },
  {
    "path": "typescript-mode-tests.el",
    "chars": 474,
    "preview": ";;; typescript-mode-tests --- This file contains automated tests for typescript-mode.el\n\n;;; Commentary:\n;; Run tests us"
  },
  {
    "path": "typescript-mode.el",
    "chars": 125232,
    "preview": ";;; typescript-mode.el --- Major mode for editing typescript  -*- lexical-binding: t -*-\n\n;; ---------------------------"
  }
]

About this extraction

This page contains the full source code of the emacs-typescript/typescript.el GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 18 files (337.5 KB), approximately 87.2k tokens, and a symbol index with 71 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!