Showing preview only (594K chars total). Download the full file or copy to clipboard to get everything.
Repository: basarat/typescript-for-professionals
Branch: master
Commit: 52cdad939e31
Files: 355
Total size: 511.1 KB
Directory structure:
gitextract_p7mixzv5/
├── .gitignore
├── LICENCE.md
├── README.md
├── advanced-typescript/
│ └── 150 native node support/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── demo/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── app.ts
│ │ ├── example.js
│ │ ├── feature.ts
│ │ └── index.ts
│ └── tsconfig.json
└── typescript/
├── 01 intro/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 02 instance/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 03 primitive/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 04 arrays/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 05 objects/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 06 functions/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 07 structural/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 08 classes/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 09 target/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 10 generics/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 11 any and unknown/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── examples.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 12 migration/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── examples.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 13 universal utilities/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── examples.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 14 frontend/
│ └── README.md
├── 15 assertion/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ ├── index.ts
│ │ └── index.tsx
│ └── tsconfig.json
├── 16 casting/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ ├── index.ts
│ │ └── index.tsx
│ └── tsconfig.json
├── 17 modules/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── index.ts
│ │ └── utils.ts
│ └── tsconfig.json
├── 18 declarations/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 20 async await/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── better.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 21 ts-node/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 22 const/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 23 this/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 24 readonly/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 25 union/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 26 literal/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 27 narrowing/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 28 discriminating/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 29 parameter properties/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 30 strict/
│ ├── .vscode/
│ │ └── settings.json
│ ├── false/
│ │ ├── false.ts
│ │ └── tsconfig.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── true/
│ ├── true.ts
│ └── tsconfig.json
├── 31 null undefined/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 32 intersection/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 33 optional/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 34 non-null/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 35 interface/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── interface.ts
│ │ └── type.ts
│ └── tsconfig.json
├── 36 declaration merging/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 37 types vs interfaces/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── interfaces.ts
│ │ └── types.ts
│ └── tsconfig.json
├── 38 never/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 39 implements/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 40 definite/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 41 type guard/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 42 assert/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 43 overloads/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 44 call signature/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 45 abstract/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 46 index/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 47 readonly array/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 48 double assertion/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 49 this/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 50 generic constraint/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 51 typeof/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 52 lookup/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 53 keyof/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 54 conditional/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 55 infer/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 56 mapped/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 57 mapped type modifiers/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 58 as const/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 59 override/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── another.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 60 pick/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 61 object/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 62 noUncheckedIndexAccess/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 63 satisfies/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 64 PropertyKey/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 65 thisType/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 66 Awaited/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 67 intrinsic string/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 68 mapped type as clause/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 69 union vs intersection venn diagrams/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
└── 70 enums are bad/
├── .vscode/
│ ├── extensions.json
│ └── settings.json
├── package.json
├── src/
│ ├── app.ts
│ ├── index.ts
│ └── initiateLogin.ts
└── tsconfig.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Logs
npm-debug.log*
# Output
lib/
# NPM Dependency
node_modules/
package-lock.json
# TypeScript cache
*.tsbuildinfo
================================================
FILE: LICENCE.md
================================================
Attribution 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More_considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution 4.0 International Public License ("Public License"). To the
extent this Public License may be interpreted as a contract, You are
granted the Licensed Rights in consideration of Your acceptance of
these terms and conditions, and the Licensor grants You such rights in
consideration of benefits the Licensor receives from making the
Licensed Material available under these terms and conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
d. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
g. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
i. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part; and
b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's
License You apply must not prevent recipients of the Adapted
Material from complying with this Public License.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public
licenses. Notwithstanding, Creative Commons may elect to apply one of
its public licenses to material it publishes and in those instances
will be considered the “Licensor.” The text of the Creative Commons
public licenses is dedicated to the public domain under the CC0 Public
Domain Dedication. Except for the limited purpose of indicating that
material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.
================================================
FILE: README.md
================================================
[](https://www.youtube.com/channel/UCGD_0i6L48hucTiiyhb5QzQ)
# The course
You can find it on [BooleanArt](https://www.booleanart.com/courses). My objective has always been to help people ❤️
# Usage: What you do
Open the lesson folder relevant to you. Run `npm i`. Play with it 🌹
# Usage: What I do
```
cd demo
npm i
```
Now write the code specific to the lesson. Once done, move all the files to the folder relevant to the lesson ❤️
================================================
FILE: advanced-typescript/150 native node support/.vscode/extensions.json
================================================
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
]
}
================================================
FILE: advanced-typescript/150 native node support/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: advanced-typescript/150 native node support/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc --watch",
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^20.14.8",
"typescript": "5.8.0-beta"
}
}
================================================
FILE: advanced-typescript/150 native node support/src/index.ts
================================================
function log(message: string) {
console.log(message);
}
log("Native NodeJS Support!");
type LoginMode = 'app' | 'email' | 'social';
================================================
FILE: advanced-typescript/150 native node support/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */
/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "libReplacement": true, /* Enable lib replacement. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
"erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
================================================
FILE: demo/.vscode/extensions.json
================================================
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
]
}
================================================
FILE: demo/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: demo/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc --watch",
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^20.14.8",
"typescript": "5.9.3"
}
}
================================================
FILE: demo/src/app.ts
================================================
// import { initiateLogin } from './initiateLogin';
// import { LoginMode } from './index';
// initiateLogin('app'); // Error
// initiateLogin(LoginMode.app);
================================================
FILE: demo/src/example.js
================================================
const fun = () => { };
Object.setPrototypeOf(fun, { debug: 'fancy' });
console.log(fun.debug); // fancy
console.log(Object.hasOwn(fun, 'debug')); // false
================================================
FILE: demo/src/feature.ts
================================================
initializationWithSideEffects();
function initializationWithSideEffects() {
specialConstant = 42;
console.log("Side effects have occurred!");
}
export let specialConstant: number;
================================================
FILE: demo/src/index.ts
================================================
import defer * as feature from "./feature";
setTimeout(() => {
console.log(feature.specialConstant);
}, 1000);
================================================
FILE: demo/tsconfig.json
================================================
{
// Visit https://aka.ms/tsconfig to read more about this file
"compilerOptions": {
// File Layout
// "rootDir": "./src",
// "outDir": "./dist",
// Environment Settings
// See also https://aka.ms/tsconfig/module
"module": "esnext",
"target": "esnext",
"types": [],
// For nodejs:
// "lib": ["esnext"],
// "types": ["node"],
// and npm install -D @types/node
// Other Outputs
"sourceMap": true,
"declaration": true,
"declarationMap": true,
// Stricter Typechecking Options
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
// Style Options
// "noImplicitReturns": true,
// "noImplicitOverride": true,
// "noUnusedLocals": true,
// "noUnusedParameters": true,
// "noFallthroughCasesInSwitch": true,
// "noPropertyAccessFromIndexSignature": true,
// Recommended Options
"strict": true,
"jsx": "react-jsx",
"verbatimModuleSyntax": false,
"isolatedModules": true,
"noUncheckedSideEffectImports": true,
"moduleDetection": "force",
"skipLibCheck": true,
}
}
================================================
FILE: typescript/01 intro/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/01 intro/src/index.ts
================================================
let message: string = 'Hello world';
message += ' again';
console.log(message);
================================================
FILE: typescript/01 intro/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/02 instance/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/02 instance/src/index.ts
================================================
let regexp: RegExp = new RegExp('ab+c');
let array: Array<number> = [1, 2, 3];
let set: Set<number> = new Set([1, 2, 3]);
/** A first in first out collection */
class Queue<T> {
private data: Array<T> = [];
push(item: T) { this.data.push(item); }
pop(): T | undefined { return this.data.shift(); }
}
let queue: Queue<number> = new Queue();
================================================
FILE: typescript/02 instance/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/03 primitive/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/03 primitive/src/index.ts
================================================
let isPresent: boolean = false;
let magic: number = 66.6;
let hello: string = 'world';
let notDefined: undefined = undefined;
let notPresent: null = null;
let penta: symbol = Symbol('star');
let biggy: bigint = 24n;
================================================
FILE: typescript/03 primitive/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/04 arrays/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/04 arrays/src/index.ts
================================================
// Array
let array: number[] = [1, 2, 3];
// Usage
array = [1];
array = [1, 2, 3, 4, 5];
array = ['hello']; // Error
// Tuple
let tuple: [number, number] = [0, 0];
// Usage
tuple = [1, 1];
tuple = [2, 6];
tuple = [5]; // Error: must be 2 items
tuple = [5, 4, 3]; // Error: must be 2 items
tuple = ['elite', 1337]; // Error: must be number
================================================
FILE: typescript/04 arrays/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/05 objects/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/05 objects/src/index.ts
================================================
type Point = { x: number, y: number };
let center: Point = {
x: 0,
y: 0,
};
let unit: Point = {
x: 1,
y: 1,
};
================================================
FILE: typescript/05 objects/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/06 functions/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/06 functions/src/index.ts
================================================
type Add = (a: number, b: number) => number;
let add: Add;
add = function (a: number, b: number): number {
return a + b;
};
add = (a, b) => a + b;
================================================
FILE: typescript/06 functions/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/07 structural/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/07 structural/src/index.ts
================================================
type Point2D = { x: number, y: number };
type Point3D = { x: number, y: number, z: number };
let point2D: Point2D = { x: 0, y: 10 };
let point3D: Point3D = { x: 0, y: 10, z: 20 };
/** Extra info ok */
point2D = point3D;
function takesPoint2D(point: Point2D) { /** ... */ }
takesPoint2D(point3D);
/** Error: missing info */
point3D = point2D;
function takesPoint3D(point: Point3D) { /** ... */ }
takesPoint3D(point2D);
================================================
FILE: typescript/07 structural/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/08 classes/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/08 classes/src/index.ts
================================================
class Animal {
protected name: string;
constructor(name: string) {
this.name = name;
}
public move(distanceInMeters: number): void {
console.log(`${this.name} moved ${distanceInMeters}m.`);
}
}
let cat = new Animal('Cat');
cat.move(10);
cat.name = 'Dog';
class Bird extends Animal {
fly(distanceInMeters: number) {
console.log(`${this.name} flew ${distanceInMeters}m.`);
}
}
================================================
FILE: typescript/08 classes/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/09 target/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/09 target/src/index.ts
================================================
class Animal {
private name: string;
constructor(name: string) {
this.name = name;
}
move(distanceInMeters: number) {
console.log(`${this.name} moved ${distanceInMeters}m.`);
}
}
================================================
FILE: typescript/09 target/tsconfig.json
================================================
{
"compilerOptions": {
"target": "ES5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/10 generics/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/10 generics/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/10 generics/src/index.ts
================================================
/** A FIFO (First In First Out) collection */
class Queue<T> {
data = [];
push(item: T) { this.data.push(item); }
pop(): T { return this.data.shift(); }
}
const queue = new Queue<number>();
queue.push(123);
queue.push(456);
console.log(queue.pop().toPrecision(1));
console.log(queue.pop().toPrecision(1));
================================================
FILE: typescript/10 generics/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/11 any and unknown/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/11 any and unknown/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/11 any and unknown/src/examples.ts
================================================
function loadString(): any {
return 'some string ';
}
function loadNumber(): any {
return 123.456;
}
================================================
FILE: typescript/11 any and unknown/src/index.ts
================================================
function log(value: unknown) {
if (typeof value == 'number') {
console.log(value.toFixed(2));
} else {
console.log(value);
}
}
log(123.456);
log('Hello world');
================================================
FILE: typescript/11 any and unknown/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/12 migration/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/12 migration/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/12 migration/src/examples.ts
================================================
function loadString(): any {
return 'some string ';
}
function loadNumber(): any {
return 123.456;
}
================================================
FILE: typescript/12 migration/src/index.ts
================================================
function log(value: unknown) {
if (typeof value == 'number') {
console.log(value.toFixed(2));
} else {
console.log(value);
}
}
log(123.456);
log('Hello world');
================================================
FILE: typescript/12 migration/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/13 universal utilities/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/13 universal utilities/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/13 universal utilities/src/examples.ts
================================================
function loadString(): any {
return 'some string ';
}
function loadNumber(): any {
return 123.456;
}
================================================
FILE: typescript/13 universal utilities/src/index.ts
================================================
function log(value: unknown) {
if (typeof value == 'number') {
console.log(value.toFixed(2));
} else {
console.log(value);
}
}
log(123.456);
log('Hello world');
================================================
FILE: typescript/13 universal utilities/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/14 frontend/README.md
================================================
# Getting Started for Frontend Development with React
Create an application:
```
npx create-react-app example --template typescript
```
Open it up:
```
cd example
code .
```
Start a live develoment flow:
```
npm start
```
Play around with `src/App.tsx`.
Once ready to publish run:
```
npm run build
```
And publish the `build` folder to a static host or try it out locally:
```
npx serve
```
Have fun building your amamzing Application with TypeScript 🌹
================================================
FILE: typescript/15 assertion/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/15 assertion/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/15 assertion/src/example.ts
================================================
function load(): unknown {
return 'Hello World ';
}
================================================
FILE: typescript/15 assertion/src/index.ts
================================================
================================================
FILE: typescript/15 assertion/src/index.tsx
================================================
let hello = load();
if (typeof hello === 'string') {
const trimmed = hello.trim();
}
================================================
FILE: typescript/15 assertion/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/16 casting/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/16 casting/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/16 casting/src/example.ts
================================================
function load(): unknown {
return 'Hello World ';
}
================================================
FILE: typescript/16 casting/src/index.ts
================================================
let leet;
// Later
leet = '1337';
// Use as number
const number = +leet;
console.log(number === 1337); // false
console.log(number); // '1337'
================================================
FILE: typescript/16 casting/src/index.tsx
================================================
let hello = load();
if (typeof hello === 'string') {
const trimmed = hello.trim();
}
================================================
FILE: typescript/16 casting/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/17 modules/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/17 modules/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/17 modules/src/index.ts
================================================
import * as utils from './utils';
console.log(utils.isPalindrome('madam')); // true
console.log(utils.isPalindrome('madan')); // false
================================================
FILE: typescript/17 modules/src/utils.ts
================================================
/**
* @returns true if the input string is a palindrome
*/
export function isPalindrome(str: string): boolean {
return str === str.split('').reverse().join('');
}
================================================
FILE: typescript/17 modules/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/18 declarations/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/18 declarations/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/express": "^4.17.8",
"@types/node": "^14.10.0",
"express": "^4.17.1",
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/18 declarations/src/index.ts
================================================
console.log(
'Logged in user:',
process.env.USER
);
declare const process: any;
================================================
FILE: typescript/18 declarations/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/20 async await/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/20 async await/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/20 async await/src/better.ts
================================================
const delay = (ms: number) => new Promise(res => setTimeout(res, ms));
const mainAsync = async () => {
await delay(1000);
console.log('1s');
await delay(1000);
console.log('2s');
await delay(1000);
console.log('3s');
};
mainAsync();
================================================
FILE: typescript/20 async await/src/index.ts
================================================
const main = () => {
setTimeout(() => {
console.log('1s');
setTimeout(() => {
console.log('2s');
setTimeout(() => {
console.log('3s');
}, 1000);
}, 1000);
}, 1000);
};
main();
================================================
FILE: typescript/20 async await/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/21 ts-node/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/21 ts-node/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node src/index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"ts-node": "^9.0.0",
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/21 ts-node/src/index.ts
================================================
let message: string = 'Hello world';
console.log(message);
================================================
FILE: typescript/21 ts-node/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/22 const/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/22 const/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/22 const/src/index.ts
================================================
type Point = { x: number, y: number };
const point: Point = { x: 0, y: 0 };
point = { x: 1, y: 1 }; // Error
// All other behaviours are the same as `let`
point.x = 123;
point.y = 456;
================================================
FILE: typescript/22 const/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/23 this/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/23 this/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/23 this/src/index.ts
================================================
class Person {
private _age: number
constructor(_age: number) {
this._age = _age;
}
growOld = () => {
this._age++;
}
age() {
return this._age;
}
}
const person = new Person(0);
// person.growOld();
const growOld = person.growOld;
setTimeout(person.growOld, 1000);
growOld();
setTimeout(() => console.log('age: ', person.age()), 2000);
================================================
FILE: typescript/23 this/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/24 readonly/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/24 readonly/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/24 readonly/src/index.ts
================================================
class Animal {
public readonly name: string;
constructor(name: string) {
this.name = name;
}
}
const sheep = new Animal('sheep');
console.log(sheep.name); // Allow
sheep.name = 'wolf'; // Disallow
================================================
FILE: typescript/24 readonly/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
================================================
FILE: typescript/25 union/.vscode/settings.json
================================================
{
"typescript.tsdk": "node_modules/typescript/lib"
}
================================================
FILE: typescript/25 union/package.json
================================================
{
"name": "intro",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"typescript": "^4.0.2"
}
}
================================================
FILE: typescript/25 union/src/index.ts
================================================
type Padding =
| number
| string;
/**
* Takes a string and adds `padding` to the left.
* If `padding` is a number, then that number of spaces is added to the left.
* If `padding` is a string, then `padding` is appended to the left.
*/
function padLeft(value: string, padding: Padding) {
if (typeof padding === 'number') {
return Array(padding + 1).join(' ') + value;
}
if (typeof padding === 'string') {
return padding + value;
}
throw new Error(`Expected number or string, got '${padding}'.`);
}
padLeft('Hello world', 4); // ' Hello world'
padLeft('Hello world', ' '); // ' Hello world'
padLeft('Hello world', '---'); // '---Hello world'
padLeft('Hello world', false); // Error
================================================
FILE: typescript/25 union/tsconfig.json
================================================
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support
gitextract_p7mixzv5/
├── .gitignore
├── LICENCE.md
├── README.md
├── advanced-typescript/
│ └── 150 native node support/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── demo/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── app.ts
│ │ ├── example.js
│ │ ├── feature.ts
│ │ └── index.ts
│ └── tsconfig.json
└── typescript/
├── 01 intro/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 02 instance/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 03 primitive/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 04 arrays/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 05 objects/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 06 functions/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 07 structural/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 08 classes/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 09 target/
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 10 generics/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 11 any and unknown/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── examples.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 12 migration/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── examples.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 13 universal utilities/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── examples.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 14 frontend/
│ └── README.md
├── 15 assertion/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ ├── index.ts
│ │ └── index.tsx
│ └── tsconfig.json
├── 16 casting/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ ├── index.ts
│ │ └── index.tsx
│ └── tsconfig.json
├── 17 modules/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── index.ts
│ │ └── utils.ts
│ └── tsconfig.json
├── 18 declarations/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 20 async await/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── better.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 21 ts-node/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 22 const/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 23 this/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 24 readonly/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 25 union/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 26 literal/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 27 narrowing/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 28 discriminating/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 29 parameter properties/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 30 strict/
│ ├── .vscode/
│ │ └── settings.json
│ ├── false/
│ │ ├── false.ts
│ │ └── tsconfig.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── true/
│ ├── true.ts
│ └── tsconfig.json
├── 31 null undefined/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 32 intersection/
│ ├── .vscode/
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 33 optional/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 34 non-null/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 35 interface/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── interface.ts
│ │ └── type.ts
│ └── tsconfig.json
├── 36 declaration merging/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 37 types vs interfaces/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── interfaces.ts
│ │ └── types.ts
│ └── tsconfig.json
├── 38 never/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 39 implements/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 40 definite/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 41 type guard/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 42 assert/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 43 overloads/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 44 call signature/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 45 abstract/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 46 index/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 47 readonly array/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 48 double assertion/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 49 this/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 50 generic constraint/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 51 typeof/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 52 lookup/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 53 keyof/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 54 conditional/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 55 infer/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 56 mapped/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 57 mapped type modifiers/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 58 as const/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── example.json
│ │ └── index.ts
│ └── tsconfig.json
├── 59 override/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ ├── another.ts
│ │ └── index.ts
│ └── tsconfig.json
├── 60 pick/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 61 object/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 62 noUncheckedIndexAccess/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 63 satisfies/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 64 PropertyKey/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 65 thisType/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 66 Awaited/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 67 intrinsic string/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 68 mapped type as clause/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
├── 69 union vs intersection venn diagrams/
│ ├── .vscode/
│ │ ├── extensions.json
│ │ └── settings.json
│ ├── package.json
│ ├── src/
│ │ └── index.ts
│ └── tsconfig.json
└── 70 enums are bad/
├── .vscode/
│ ├── extensions.json
│ └── settings.json
├── package.json
├── src/
│ ├── app.ts
│ ├── index.ts
│ └── initiateLogin.ts
└── tsconfig.json
SYMBOL INDEX (176 symbols across 71 files)
FILE: advanced-typescript/150 native node support/src/index.ts
function log (line 1) | function log(message: string) {
type LoginMode (line 7) | type LoginMode = 'app' | 'email' | 'social';
FILE: demo/src/feature.ts
function initializationWithSideEffects (line 3) | function initializationWithSideEffects() {
FILE: typescript/02 instance/src/index.ts
class Queue (line 8) | class Queue<T> {
method push (line 10) | push(item: T) { this.data.push(item); }
method pop (line 11) | pop(): T | undefined { return this.data.shift(); }
FILE: typescript/05 objects/src/index.ts
type Point (line 1) | type Point = { x: number, y: number };
FILE: typescript/06 functions/src/index.ts
type Add (line 1) | type Add = (a: number, b: number) => number;
FILE: typescript/07 structural/src/index.ts
type Point2D (line 1) | type Point2D = { x: number, y: number };
type Point3D (line 2) | type Point3D = { x: number, y: number, z: number };
function takesPoint2D (line 9) | function takesPoint2D(point: Point2D) { /** ... */ }
function takesPoint3D (line 14) | function takesPoint3D(point: Point3D) { /** ... */ }
FILE: typescript/08 classes/src/index.ts
class Animal (line 1) | class Animal {
method constructor (line 4) | constructor(name: string) {
method move (line 8) | public move(distanceInMeters: number): void {
class Bird (line 17) | class Bird extends Animal {
method fly (line 18) | fly(distanceInMeters: number) {
FILE: typescript/09 target/src/index.ts
class Animal (line 1) | class Animal {
method constructor (line 3) | constructor(name: string) {
method move (line 6) | move(distanceInMeters: number) {
FILE: typescript/10 generics/src/index.ts
class Queue (line 2) | class Queue<T> {
method push (line 4) | push(item: T) { this.data.push(item); }
method pop (line 5) | pop(): T { return this.data.shift(); }
FILE: typescript/11 any and unknown/src/examples.ts
function loadString (line 1) | function loadString(): any {
function loadNumber (line 5) | function loadNumber(): any {
FILE: typescript/11 any and unknown/src/index.ts
function log (line 1) | function log(value: unknown) {
FILE: typescript/12 migration/src/examples.ts
function loadString (line 1) | function loadString(): any {
function loadNumber (line 5) | function loadNumber(): any {
FILE: typescript/12 migration/src/index.ts
function log (line 1) | function log(value: unknown) {
FILE: typescript/13 universal utilities/src/examples.ts
function loadString (line 1) | function loadString(): any {
function loadNumber (line 5) | function loadNumber(): any {
FILE: typescript/13 universal utilities/src/index.ts
function log (line 1) | function log(value: unknown) {
FILE: typescript/15 assertion/src/example.ts
function load (line 1) | function load(): unknown {
FILE: typescript/16 casting/src/example.ts
function load (line 1) | function load(): unknown {
FILE: typescript/17 modules/src/utils.ts
function isPalindrome (line 4) | function isPalindrome(str: string): boolean {
FILE: typescript/22 const/src/index.ts
type Point (line 1) | type Point = { x: number, y: number };
FILE: typescript/23 this/src/index.ts
class Person (line 1) | class Person {
method constructor (line 3) | constructor(_age: number) {
method age (line 9) | age() {
FILE: typescript/24 readonly/src/index.ts
class Animal (line 1) | class Animal {
method constructor (line 3) | constructor(name: string) {
FILE: typescript/25 union/src/index.ts
type Padding (line 1) | type Padding =
function padLeft (line 10) | function padLeft(value: string, padding: Padding) {
FILE: typescript/26 literal/src/index.ts
type DiceValue (line 1) | type DiceValue = 1 | 2 | 3 | 4 | 5 | 6;
function rollDice (line 3) | function rollDice() {
FILE: typescript/27 narrowing/src/index.ts
type Square (line 1) | type Square = {
type Rectangle (line 5) | type Rectangle = {
type Shape (line 10) | type Shape = Square | Rectangle;
function area (line 12) | function area(shape: Shape) {
FILE: typescript/28 discriminating/src/index.ts
type ValidationSuccess (line 1) | type ValidationSuccess = {
type ValidationFailure (line 6) | type ValidationFailure = {
type ValidationResult (line 11) | type ValidationResult =
function logResult (line 15) | function logResult(result: ValidationResult) {
FILE: typescript/29 parameter properties/src/index.ts
class Person (line 1) | class Person {
method constructor (line 2) | constructor(
FILE: typescript/30 strict/false/false.ts
type User (line 1) | type User = {
function getUserAge (line 11) | function getUserAge(name: string): number {
FILE: typescript/30 strict/src/index.ts
class Person (line 1) | class Person {
method constructor (line 2) | constructor(
FILE: typescript/30 strict/true/true.ts
type User (line 1) | type User = {
function getUserAge (line 11) | function getUserAge(name: string): number {
FILE: typescript/32 intersection/src/index.ts
type Person (line 1) | type Person = {
type Email (line 5) | type Email = {
type Phone (line 9) | type Phone = {
type ContactDetails (line 13) | type ContactDetails =
function contact (line 18) | function contact(details: ContactDetails) {
FILE: typescript/33 optional/src/index.ts
class Point (line 1) | class Point {
FILE: typescript/35 interface/src/interface.ts
type Point2D (line 1) | interface Point2D {
type Point3D (line 6) | interface Point3D extends Point2D {
FILE: typescript/35 interface/src/type.ts
type Point2D (line 1) | type Point2D = {
type Point3D (line 6) | type Point3D = Point2D & {
FILE: typescript/36 declaration merging/src/index.ts
type Request (line 2) | interface Request {
type Request (line 7) | interface Request {
function handleRequest (line 12) | function handleRequest(req: Request) {
FILE: typescript/37 types vs interfaces/src/interfaces.ts
type InputProps (line 1) | interface InputProps {
FILE: typescript/37 types vs interfaces/src/types.ts
type InputOnChange (line 1) | type InputOnChange = (newValue: InputValue) => void;
type InputValue (line 3) | type InputValue = string;
type InputType (line 5) | type InputType = 'text' | 'email';
type InputProps (line 7) | type InputProps = {
FILE: typescript/38 never/src/index.ts
type Square (line 1) | type Square = {
type Rectangle (line 6) | type Rectangle = {
type Circle (line 12) | type Circle = {
type Shape (line 17) | type Shape =
function area (line 22) | function area(s: Shape) {
FILE: typescript/39 implements/src/index.ts
type Animal (line 1) | type Animal = {
function log (line 6) | function log(animal: Animal) {
class Cat (line 10) | class Cat implements Animal {
method constructor (line 11) | constructor(public name: string) { }
method voice (line 12) | voice() { return 'meow'; }
class Dog (line 15) | class Dog implements Animal {
method constructor (line 16) | constructor(public name: string) { }
method voice (line 17) | voice() { return 'woof'; }
FILE: typescript/40 definite/src/index.ts
class Point (line 1) | class Point {
method constructor (line 4) | constructor() {
method moveRandom (line 7) | moveRandom() {
FILE: typescript/41 type guard/src/index.ts
type Square (line 1) | type Square = {
type Rectangle (line 4) | type Rectangle = {
type Shape (line 8) | type Shape = Square | Rectangle;
function isSquare (line 10) | function isSquare(shape: Shape): shape is Square {
function isRectangle (line 14) | function isRectangle(shape: Shape): shape is Rectangle {
function area (line 18) | function area(shape: Shape) {
FILE: typescript/42 assert/src/example.ts
function loadPerson (line 1) | function loadPerson(): Person | null {
FILE: typescript/42 assert/src/index.ts
type Person (line 1) | type Person = {
function assert (line 6) | function assert(condition: unknown, message: string): asserts condition {
function assertDate (line 10) | function assertDate(value: unknown): asserts value is Date {
FILE: typescript/43 overloads/src/example.ts
function loadPerson (line 1) | function loadPerson(): Person | null {
FILE: typescript/43 overloads/src/index.ts
function makeDate (line 3) | function makeDate(timestampOrYear: number, month?: number, day?: number)...
FILE: typescript/44 call signature/src/example.ts
function loadPerson (line 1) | function loadPerson(): Person | null {
FILE: typescript/46 index/src/example.ts
type Person (line 2) | type Person = {
type PersonDictionary (line 7) | type PersonDictionary = {
FILE: typescript/46 index/src/index.ts
type Person (line 1) | type Person = {
type PersonDictionary (line 6) | type PersonDictionary = {
FILE: typescript/47 readonly array/src/example.ts
type Person (line 2) | type Person = {
type PersonDictionary (line 7) | type PersonDictionary = {
FILE: typescript/48 double assertion/src/example.ts
type Person (line 2) | type Person = {
type PersonDictionary (line 7) | type PersonDictionary = {
FILE: typescript/48 double assertion/src/index.ts
type Point2D (line 1) | type Point2D = { x: number, y: number };
type Point3D (line 2) | type Point3D = { x: number, y: number, z: number };
type Person (line 3) | type Person = { name: string, email: string };
FILE: typescript/49 this/src/example.ts
type Person (line 2) | type Person = {
type PersonDictionary (line 7) | type PersonDictionary = {
FILE: typescript/49 this/src/index.ts
function double (line 1) | function double(this: { value: number }) {
FILE: typescript/50 generic constraint/src/index.ts
type NameFields (line 1) | type NameFields = { firstName: string, lastName: string };
function addFullName (line 3) | function addFullName<T extends NameFields>(obj: T): T & { fullName: stri...
FILE: typescript/51 typeof/src/index.ts
type PersonResponse (line 8) | type PersonResponse = typeof personResponse;
function processResponse (line 10) | function processResponse(person: PersonResponse) {
FILE: typescript/52 lookup/src/index.ts
type SubmitRequest (line 1) | type SubmitRequest = {
type PaymentRequest (line 54) | type PaymentRequest = SubmitRequest['payment'];
type PreviousAliasRequest (line 55) | type PreviousAliasRequest = SubmitRequest['personal']['previousAliases']...
function getPayment (line 57) | function getPayment(): PaymentRequest {
FILE: typescript/53 keyof/src/index.ts
type Person (line 1) | type Person = {
function logGet (line 13) | function logGet<Obj, Key extends keyof Obj>(obj: Obj, key: Key) {
FILE: typescript/54 conditional/src/index.ts
type TypeName (line 1) | type TypeName<T> =
function typeName (line 11) | function typeName<T>(t: T): TypeName<T> {
FILE: typescript/55 infer/src/index.ts
function createPerson (line 1) | function createPerson(firstName: string, lastName: string) {
function logPerson (line 8) | function logPerson(person: ReturnType<typeof createPerson>) {
FILE: typescript/56 mapped/src/index.ts
type Point (line 1) | type Point = {
FILE: typescript/57 mapped type modifiers/src/index.ts
class State (line 1) | class State<T> {
method constructor (line 2) | constructor(public current: T) { }
method update (line 3) | update(next: Partial<T>) {
FILE: typescript/58 as const/src/index.ts
function layout (line 1) | function layout(settings: {
FILE: typescript/59 override/src/another.ts
class Disposible (line 1) | class Disposible {
method dispose (line 3) | dispose() {
method log (line 7) | log(message: string) {
class File (line 12) | class File extends Disposible {
method write (line 13) | write(contents: string) {
FILE: typescript/59 override/src/index.ts
class Visibility (line 1) | class Visibility {
method setVisible (line 3) | setVisible(visible: boolean) {
class MockVisibility (line 7) | class MockVisibility extends Visibility {
method setVisible (line 8) | override setVisible(visible: boolean) {
FILE: typescript/60 pick/src/index.ts
type CSSProperties (line 2) | type CSSProperties = {
function setSize (line 10) | function setSize(
FILE: typescript/63 satisfies/src/index.ts
type Color (line 1) | type Color = ColorString | ColorRGB;
type ColorString (line 2) | type ColorString = 'red' | 'blue' | 'yellow' | 'purple';
type ColorRGB (line 3) | type ColorRGB = [red: number, green: number, blue: number];
type Theme (line 5) | type Theme = Record<string, Color>;
FILE: typescript/65 thisType/src/index.ts
type StateDescription (line 1) | type StateDescription<D, M> = {
function createState (line 6) | function createState<D, M>(desc: StateDescription<D, M>): D & M {
method moveBy (line 13) | moveBy(dx: number, dy: number) {
FILE: typescript/66 Awaited/src/index.ts
function example (line 1) | async function example<T>(input: T) {
FILE: typescript/67 intrinsic string/src/index.ts
type Getter (line 1) | type Getter<T extends string> = `get${Capitalize<T>}`;
type Setter (line 2) | type Setter<T extends string> = `set${Capitalize<T>}`;
type Name (line 4) | type Name = 'name';
type GetName (line 6) | type GetName = Getter<Name>;
type SetName (line 7) | type SetName = Setter<Name>;
FILE: typescript/68 mapped type as clause/src/index.ts
type Getter (line 1) | type Getter<T extends string> = `get${Capitalize<T>}`;
type Setter (line 2) | type Setter<T extends string> = `set${Capitalize<T>}`;
type Name (line 4) | type Name = 'name';
type GetName (line 6) | type GetName = Getter<Name>;
type SetName (line 7) | type SetName = Setter<Name>;
FILE: typescript/69 union vs intersection venn diagrams/src/index.ts
type Name (line 1) | type Name = { name: string };
type Age (line 2) | type Age = { age: number };
type Union (line 4) | type Union = Name | Age | (Name & Age);
function filter (line 11) | function filter(union: Union) {
FILE: typescript/70 enums are bad/src/index.ts
type LoginMode (line 7) | type LoginMode = keyof typeof LoginMode;
function initiateLogin (line 9) | function initiateLogin(mode: LoginMode) {
Condensed preview — 355 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (569K chars).
[
{
"path": ".gitignore",
"chars": 121,
"preview": "# Logs\nnpm-debug.log*\n\n# Output\nlib/\n\n# NPM Dependency\nnode_modules/\npackage-lock.json\n\n# TypeScript cache\n*.tsbuildinfo"
},
{
"path": "LICENCE.md",
"chars": 18646,
"preview": "Attribution 4.0 International\n\n=======================================================================\n\nCreative Commons"
},
{
"path": "README.md",
"chars": 558,
"preview": "[ {\n console.log(message);\n}\n\nlog(\"Native NodeJS Support!\");\n\ntype LoginMode = 'app' | 'ema"
},
{
"path": "advanced-typescript/150 native node support/tsconfig.json",
"chars": 12810,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig to read more about this file */\n\n /* Projects */\n //"
},
{
"path": "demo/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "demo/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "demo/package.json",
"chars": 290,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "demo/src/app.ts",
"chars": 159,
"preview": "// import { initiateLogin } from './initiateLogin';\n// import { LoginMode } from './index';\n\n// initiateLogin('app'); //"
},
{
"path": "demo/src/example.js",
"chars": 158,
"preview": "const fun = () => { };\n\nObject.setPrototypeOf(fun, { debug: 'fancy' });\n\nconsole.log(fun.debug); // fancy\n\nconsole.log(O"
},
{
"path": "demo/src/feature.ts",
"chars": 185,
"preview": "initializationWithSideEffects();\n\nfunction initializationWithSideEffects() {\n specialConstant = 42;\n console.log(\"Side"
},
{
"path": "demo/src/index.ts",
"chars": 114,
"preview": "import defer * as feature from \"./feature\";\n\nsetTimeout(() => {\n console.log(feature.specialConstant);\n}, 1000);\n"
},
{
"path": "demo/tsconfig.json",
"chars": 1119,
"preview": "{\n // Visit https://aka.ms/tsconfig to read more about this file\n \"compilerOptions\": {\n // File Layout\n // \"root"
},
{
"path": "typescript/01 intro/package.json",
"chars": 271,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\"
},
{
"path": "typescript/01 intro/src/index.ts",
"chars": 80,
"preview": "let message: string = 'Hello world';\nmessage += ' again';\nconsole.log(message);\n"
},
{
"path": "typescript/01 intro/tsconfig.json",
"chars": 6071,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/02 instance/package.json",
"chars": 271,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\"
},
{
"path": "typescript/02 instance/src/index.ts",
"chars": 349,
"preview": "let regexp: RegExp = new RegExp('ab+c');\n\nlet array: Array<number> = [1, 2, 3];\n\nlet set: Set<number> = new Set([1, 2, 3"
},
{
"path": "typescript/02 instance/tsconfig.json",
"chars": 6074,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/03 primitive/package.json",
"chars": 271,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\"
},
{
"path": "typescript/03 primitive/src/index.ts",
"chars": 217,
"preview": "let isPresent: boolean = false;\nlet magic: number = 66.6;\nlet hello: string = 'world';\n\nlet notDefined: undefined = unde"
},
{
"path": "typescript/03 primitive/tsconfig.json",
"chars": 6074,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/04 arrays/package.json",
"chars": 271,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\"
},
{
"path": "typescript/04 arrays/src/index.ts",
"chars": 341,
"preview": "// Array\nlet array: number[] = [1, 2, 3];\n\n// Usage\narray = [1];\narray = [1, 2, 3, 4, 5];\narray = ['hello']; // Error\n\n/"
},
{
"path": "typescript/04 arrays/tsconfig.json",
"chars": 6074,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/05 objects/package.json",
"chars": 271,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\"
},
{
"path": "typescript/05 objects/src/index.ts",
"chars": 120,
"preview": "type Point = { x: number, y: number };\n\nlet center: Point = {\n x: 0,\n y: 0,\n};\n\nlet unit: Point = {\n x: 1,\n y: 1,\n};"
},
{
"path": "typescript/05 objects/tsconfig.json",
"chars": 6074,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/06 functions/package.json",
"chars": 271,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\"
},
{
"path": "typescript/06 functions/src/index.ts",
"chars": 151,
"preview": "type Add = (a: number, b: number) => number;\n\nlet add: Add;\n\nadd = function (a: number, b: number): number {\n return a "
},
{
"path": "typescript/06 functions/tsconfig.json",
"chars": 6075,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/07 structural/package.json",
"chars": 271,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\"
},
{
"path": "typescript/07 structural/src/index.ts",
"chars": 420,
"preview": "type Point2D = { x: number, y: number };\ntype Point3D = { x: number, y: number, z: number };\n\nlet point2D: Point2D = { x"
},
{
"path": "typescript/07 structural/tsconfig.json",
"chars": 6075,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/08 classes/package.json",
"chars": 271,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"test\": \"echo \\"
},
{
"path": "typescript/08 classes/src/index.ts",
"chars": 405,
"preview": "class Animal {\n protected name: string;\n\n constructor(name: string) {\n this.name = name;\n }\n\n public move(distanc"
},
{
"path": "typescript/08 classes/tsconfig.json",
"chars": 6075,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/09 target/package.json",
"chars": 232,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"tsc\"\n"
},
{
"path": "typescript/09 target/src/index.ts",
"chars": 197,
"preview": "class Animal {\n private name: string;\n constructor(name: string) {\n this.name = name;\n }\n move(distanceInMeters: "
},
{
"path": "typescript/09 target/tsconfig.json",
"chars": 5900,
"preview": "{\n \"compilerOptions\": {\n \"target\": \"ES5\", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'E"
},
{
"path": "typescript/10 generics/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/10 generics/package.json",
"chars": 232,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"tsc\"\n"
},
{
"path": "typescript/10 generics/src/index.ts",
"chars": 313,
"preview": "/** A FIFO (First In First Out) collection */\nclass Queue<T> {\n data = [];\n push(item: T) { this.data.push(item); }\n "
},
{
"path": "typescript/10 generics/tsconfig.json",
"chars": 6075,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/11 any and unknown/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/11 any and unknown/package.json",
"chars": 232,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"tsc\"\n"
},
{
"path": "typescript/11 any and unknown/src/examples.ts",
"chars": 105,
"preview": "function loadString(): any {\n return 'some string ';\n}\n\nfunction loadNumber(): any {\n return 123.456;\n}"
},
{
"path": "typescript/11 any and unknown/src/index.ts",
"chars": 175,
"preview": "function log(value: unknown) {\n if (typeof value == 'number') {\n console.log(value.toFixed(2));\n } else {\n conso"
},
{
"path": "typescript/11 any and unknown/tsconfig.json",
"chars": 6074,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/12 migration/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/12 migration/package.json",
"chars": 232,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"tsc\"\n"
},
{
"path": "typescript/12 migration/src/examples.ts",
"chars": 105,
"preview": "function loadString(): any {\n return 'some string ';\n}\n\nfunction loadNumber(): any {\n return 123.456;\n}"
},
{
"path": "typescript/12 migration/src/index.ts",
"chars": 175,
"preview": "function log(value: unknown) {\n if (typeof value == 'number') {\n console.log(value.toFixed(2));\n } else {\n conso"
},
{
"path": "typescript/12 migration/tsconfig.json",
"chars": 6074,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/13 universal utilities/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/13 universal utilities/package.json",
"chars": 232,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"tsc\"\n"
},
{
"path": "typescript/13 universal utilities/src/examples.ts",
"chars": 105,
"preview": "function loadString(): any {\n return 'some string ';\n}\n\nfunction loadNumber(): any {\n return 123.456;\n}"
},
{
"path": "typescript/13 universal utilities/src/index.ts",
"chars": 175,
"preview": "function log(value: unknown) {\n if (typeof value == 'number') {\n console.log(value.toFixed(2));\n } else {\n conso"
},
{
"path": "typescript/13 universal utilities/tsconfig.json",
"chars": 6074,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/14 frontend/README.md",
"chars": 464,
"preview": "# Getting Started for Frontend Development with React\n\nCreate an application:\n```\nnpx create-react-app example --templat"
},
{
"path": "typescript/15 assertion/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/15 assertion/package.json",
"chars": 232,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"tsc\"\n"
},
{
"path": "typescript/15 assertion/src/example.ts",
"chars": 53,
"preview": "function load(): unknown {\n return 'Hello World ';\n}"
},
{
"path": "typescript/15 assertion/src/index.ts",
"chars": 0,
"preview": ""
},
{
"path": "typescript/15 assertion/src/index.tsx",
"chars": 88,
"preview": "let hello = load();\n\nif (typeof hello === 'string') {\n const trimmed = hello.trim();\n}\n"
},
{
"path": "typescript/15 assertion/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/16 casting/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/16 casting/package.json",
"chars": 232,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"tsc\"\n"
},
{
"path": "typescript/16 casting/src/example.ts",
"chars": 53,
"preview": "function load(): unknown {\n return 'Hello World ';\n}"
},
{
"path": "typescript/16 casting/src/index.ts",
"chars": 145,
"preview": "let leet;\n\n// Later\nleet = '1337';\n\n// Use as number\nconst number = +leet;\n\nconsole.log(number === 1337); // false\nconso"
},
{
"path": "typescript/16 casting/src/index.tsx",
"chars": 88,
"preview": "let hello = load();\n\nif (typeof hello === 'string') {\n const trimmed = hello.trim();\n}\n"
},
{
"path": "typescript/16 casting/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/17 modules/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/17 modules/package.json",
"chars": 232,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"tsc\"\n"
},
{
"path": "typescript/17 modules/src/index.ts",
"chars": 135,
"preview": "import * as utils from './utils';\n\nconsole.log(utils.isPalindrome('madam')); // true\nconsole.log(utils.isPalindrome('mad"
},
{
"path": "typescript/17 modules/src/utils.ts",
"chars": 168,
"preview": "/** \n * @returns true if the input string is a palindrome\n */\nexport function isPalindrome(str: string): boolean {\n ret"
},
{
"path": "typescript/17 modules/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/18 declarations/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/18 declarations/package.json",
"chars": 322,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"build\": \"tsc\"\n"
},
{
"path": "typescript/18 declarations/src/index.ts",
"chars": 84,
"preview": "console.log(\n 'Logged in user:',\n process.env.USER\n);\n\ndeclare const process: any;"
},
{
"path": "typescript/18 declarations/tsconfig.json",
"chars": 6068,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/20 async await/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/20 async await/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/20 async await/src/better.ts",
"chars": 246,
"preview": "const delay = (ms: number) => new Promise(res => setTimeout(res, ms));\n\nconst mainAsync = async () => {\n await delay(10"
},
{
"path": "typescript/20 async await/src/index.ts",
"chars": 218,
"preview": "const main = () => {\n setTimeout(() => {\n console.log('1s');\n setTimeout(() => {\n console.log('2s');\n s"
},
{
"path": "typescript/20 async await/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/21 ts-node/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/21 ts-node/package.json",
"chars": 274,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"ts-no"
},
{
"path": "typescript/21 ts-node/src/index.ts",
"chars": 58,
"preview": "let message: string = 'Hello world';\nconsole.log(message);"
},
{
"path": "typescript/21 ts-node/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/22 const/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/22 const/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/22 const/src/index.ts",
"chars": 188,
"preview": "type Point = { x: number, y: number };\n\nconst point: Point = { x: 0, y: 0 };\n\npoint = { x: 1, y: 1 }; // Error\n\n// All o"
},
{
"path": "typescript/22 const/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/23 this/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/23 this/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/23 this/src/index.ts",
"chars": 361,
"preview": "class Person {\n private _age: number\n constructor(_age: number) {\n this._age = _age;\n }\n growOld = () => {\n th"
},
{
"path": "typescript/23 this/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/24 readonly/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/24 readonly/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/24 readonly/src/index.ts",
"chars": 207,
"preview": "class Animal {\n public readonly name: string;\n constructor(name: string) {\n this.name = name;\n }\n}\n\nconst sheep = "
},
{
"path": "typescript/24 readonly/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/25 union/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/25 union/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/25 union/src/index.ts",
"chars": 717,
"preview": "type Padding =\n | number\n | string;\n\n/**\n * Takes a string and adds `padding` to the left.\n * If `padding` is a number"
},
{
"path": "typescript/25 union/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/26 literal/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/26 literal/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/26 literal/src/index.ts",
"chars": 186,
"preview": "type DiceValue = 1 | 2 | 3 | 4 | 5 | 6;\n\nfunction rollDice() {\n return (Math.floor(Math.random() * 6) + 1) as DiceValue"
},
{
"path": "typescript/26 literal/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/27 narrowing/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/27 narrowing/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/27 narrowing/src/index.ts",
"chars": 366,
"preview": "type Square = {\n size: number,\n};\n\ntype Rectangle = {\n width: number,\n height: number,\n};\n\ntype Shape = Square | Rect"
},
{
"path": "typescript/27 narrowing/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/28 discriminating/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/28 discriminating/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/28 discriminating/src/index.ts",
"chars": 464,
"preview": "type ValidationSuccess = {\n isValid: true,\n validatedValue: string,\n};\n\ntype ValidationFailure = {\n isValid: false,\n "
},
{
"path": "typescript/28 discriminating/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/29 parameter properties/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/29 parameter properties/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/29 parameter properties/src/index.ts",
"chars": 183,
"preview": "class Person {\n constructor(\n public name: string,\n public age: number\n ) {\n }\n}\n\nconst adam = new Person('Adam"
},
{
"path": "typescript/29 parameter properties/tsconfig.json",
"chars": 6069,
"preview": "{\n \"compilerOptions\": {\n /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n /* Basic Options"
},
{
"path": "typescript/30 strict/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/30 strict/false/false.ts",
"chars": 262,
"preview": "type User = {\n name: string,\n age: number,\n};\n\nconst users: User[] = [\n { name: 'Oby', age: 12 },\n { name: 'Heera', "
},
{
"path": "typescript/30 strict/false/tsconfig.json",
"chars": 5821,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": false,\n\n\n\n\n\n /* Visit https://aka.ms/ts"
},
{
"path": "typescript/30 strict/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/30 strict/src/index.ts",
"chars": 183,
"preview": "class Person {\n constructor(\n public name: string,\n public age: number\n ) {\n }\n}\n\nconst adam = new Person('Adam"
},
{
"path": "typescript/30 strict/true/true.ts",
"chars": 336,
"preview": "type User = {\n name: string,\n age: number,\n};\n\nconst users: User[] = [\n { name: 'Oby', age: 12 },\n { name: 'Heera', "
},
{
"path": "typescript/30 strict/true/tsconfig.json",
"chars": 5841,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true,\n \n \n \n \n \n /* Visi"
},
{
"path": "typescript/31 null undefined/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/31 null undefined/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/31 null undefined/src/example.ts",
"chars": 77,
"preview": "\ndeclare function someBooleanOrNullOrUndefined(): boolean | null | undefined;"
},
{
"path": "typescript/31 null undefined/src/index.ts",
"chars": 508,
"preview": "console.log(null == null); // true (of course)\nconsole.log(undefined == undefined); // true (of course)\n\nconso"
},
{
"path": "typescript/31 null undefined/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/32 intersection/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/32 intersection/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/32 intersection/src/example.ts",
"chars": 77,
"preview": "\ndeclare function someBooleanOrNullOrUndefined(): boolean | null | undefined;"
},
{
"path": "typescript/32 intersection/src/index.ts",
"chars": 354,
"preview": "type Person = {\n name: string,\n};\n\ntype Email = {\n email: string,\n};\n\ntype Phone = {\n phone: string,\n};\n\ntype Contact"
},
{
"path": "typescript/32 intersection/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/33 optional/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/33 optional/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/33 optional/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/33 optional/src/example.ts",
"chars": 77,
"preview": "\ndeclare function someBooleanOrNullOrUndefined(): boolean | null | undefined;"
},
{
"path": "typescript/33 optional/src/index.ts",
"chars": 107,
"preview": "class Point {\n x?: number;\n y?: number;\n}\n\nconst point = new Point();\n\nconsole.log(point.x); // undefined"
},
{
"path": "typescript/33 optional/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/34 non-null/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/34 non-null/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/34 non-null/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/34 non-null/src/example.ts",
"chars": 77,
"preview": "\ndeclare function someBooleanOrNullOrUndefined(): boolean | null | undefined;"
},
{
"path": "typescript/34 non-null/src/index.ts",
"chars": 0,
"preview": ""
},
{
"path": "typescript/34 non-null/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/35 interface/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/35 interface/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/35 interface/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/35 interface/src/interface.ts",
"chars": 159,
"preview": "interface Point2D {\n x: number,\n y: number,\n}\n\ninterface Point3D extends Point2D {\n z: number,\n}\n\nexport const point:"
},
{
"path": "typescript/35 interface/src/type.ts",
"chars": 149,
"preview": "type Point2D = {\n x: number,\n y: number,\n};\n\ntype Point3D = Point2D & {\n z: number,\n};\n\nexport const point: Point3D ="
},
{
"path": "typescript/35 interface/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/36 declaration merging/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/36 declaration merging/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/36 declaration merging/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/36 declaration merging/src/index.ts",
"chars": 193,
"preview": "// Express Base\nexport interface Request {\n body: any;\n}\n\n// Express JSON\nexport interface Request {\n json: any;\n}\n\n//"
},
{
"path": "typescript/36 declaration merging/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/37 types vs interfaces/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/37 types vs interfaces/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/37 types vs interfaces/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/37 types vs interfaces/src/interfaces.ts",
"chars": 114,
"preview": "export interface InputProps {\n type: 'text' | 'email',\n value: string,\n onChange: (newValue: string) => void,\n}"
},
{
"path": "typescript/37 types vs interfaces/src/types.ts",
"chars": 213,
"preview": "type InputOnChange = (newValue: InputValue) => void;\n\ntype InputValue = string;\n\ntype InputType = 'text' | 'email';\n\nexp"
},
{
"path": "typescript/37 types vs interfaces/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/38 never/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/38 never/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/38 never/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/38 never/src/index.ts",
"chars": 555,
"preview": "type Square = {\n kind: 'square',\n size: number,\n};\n\ntype Rectangle = {\n kind: 'rectangle',\n width: number,\n height:"
},
{
"path": "typescript/38 never/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/39 implements/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/39 implements/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/39 implements/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/39 implements/src/index.ts",
"chars": 398,
"preview": "type Animal = {\n name: string,\n voice(): string,\n};\n\nfunction log(animal: Animal) {\n console.log(`Animal ${animal.nam"
},
{
"path": "typescript/39 implements/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/40 definite/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/40 definite/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/40 definite/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/40 definite/src/index.ts",
"chars": 165,
"preview": "class Point {\n x!: number;\n y!: number;\n constructor() {\n this.moveRandom();\n }\n moveRandom() {\n this.x = Mat"
},
{
"path": "typescript/40 definite/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/41 type guard/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/41 type guard/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/41 type guard/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/41 type guard/src/index.ts",
"chars": 508,
"preview": "type Square = {\n size: number,\n};\ntype Rectangle = {\n width: number,\n height: number,\n};\ntype Shape = Square | Rectan"
},
{
"path": "typescript/41 type guard/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/42 assert/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/42 assert/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/42 assert/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
},
{
"path": "typescript/42 assert/src/example.ts",
"chars": 55,
"preview": "function loadPerson(): Person | null {\n return null;\n}"
},
{
"path": "typescript/42 assert/src/index.ts",
"chars": 567,
"preview": "type Person = {\n name: string,\n dateOfBirth?: Date,\n};\n\nfunction assert(condition: unknown, message: string): asserts "
},
{
"path": "typescript/42 assert/tsconfig.json",
"chars": 6067,
"preview": "{\n \"compilerOptions\": {\n /* Strict Type-Checking Options */\n \"strict\": true, /* Enable a"
},
{
"path": "typescript/43 overloads/.vscode/extensions.json",
"chars": 430,
"preview": "{\n\t// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.\n\t// Extension identif"
},
{
"path": "typescript/43 overloads/.vscode/settings.json",
"chars": 56,
"preview": "{\n \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}"
},
{
"path": "typescript/43 overloads/package.json",
"chars": 240,
"preview": "{\n \"name\": \"intro\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"tsc -"
}
]
// ... and 155 more files (download for full content)
About this extraction
This page contains the full source code of the basarat/typescript-for-professionals GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 355 files (511.1 KB), approximately 126.6k tokens, and a symbol index with 176 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.