<html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8"><meta name="generator" content="pdf2htmlEX"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/css/base.min.css"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/css/fancy.min.css"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/15331036/raw.css"><script src="https://csdnimg.cn/release/download_crawler_static/js/compatibility.min.js"></script><script src="https://csdnimg.cn/release/download_crawler_static/js/pdf2htmlEX.min.js"></script><script>try{pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({});}catch(e){}</script><title></title></head><body><div id="sidebar" style="display: none"><div id="outline"></div></div><div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://csdnimg.cn/release/download_crawler_static/15331036/bg1.jpg"><div class="t m0 x1 h2 y1 ff1 fs0 fc0 sc0 ls0 ws0">Ess<span class="_ _0"></span>ential </div><div class="t m0 x1 h2 y2 ff1 fs0 fc0 sc0 ls0 ws0">T<span class="_ _1"></span>ypeS<span class="_ _2"></span>cript</div><div class="t m0 x2 h3 y3 ff2 fs1 fc1 sc0 ls1 ws1">F<span class="_ _3"></span>ro<span class="_ _3"></span>m Be<span class="_ _3"></span>gi<span class="_ _3"></span>n<span class="_ _4"></span>n<span class="_ _3"></span>e<span class="_ _3"></span>r t<span class="_ _3"></span>o P<span class="_ _3"></span>ro</div><div class="t m0 x2 h3 y4 ff2 fs1 fc1 sc0 ls0 ws0">—</div><div class="t m0 x2 h3 y5 ff2 fs1 fc0 sc0 ls0 ws0">A<span class="_ _5"></span>dam F<span class="_ _3"></span>reeman</div></div><div class="pi" data-data='{"ctm":[1.884722,0.000000,0.000000,1.884722,0.000000,0.000000]}'></div></div></body></html>
<div id="pf2" class="pf w2 h0" data-page-no="2"><div class="pc pc2 w2 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://csdnimg.cn/release/download_crawler_static/15331036/bg2.jpg"><div class="t m0 x3 h4 y6 ff3 fs2 fc2 sc0 ls0 ws0">Essential T<span class="_ _6"></span>ypeScript</div><div class="t m0 x4 h5 y7 ff3 fs3 fc3 sc0 ls0 ws0">Fr<span class="_ _3"></span>om Beginner to Pr<span class="_ _3"></span>o</div><div class="t m0 x5 h6 y8 ff3 fs4 fc2 sc0 ls0 ws0">Adam Fr<span class="_ _3"></span>eeman</div></div><div class="pi" data-data='{"ctm":[1.884722,0.000000,0.000000,1.884722,0.000000,0.000000]}'></div></div>
<div id="pf3" class="pf w2 h0" data-page-no="3"><div class="pc pc3 w2 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://csdnimg.cn/release/download_crawler_static/15331036/bg3.jpg"><div class="t m0 x6 h7 y9 ff4 fs5 fc2 sc0 ls0 ws0">AdamFreem<span class="_ _3"></span>an</div><div class="t m0 x6 h7 ya ff4 fs5 fc2 sc0 ls0 ws0">London, UK</div><div class="t m0 x6 h7 yb ff4 fs5 fc2 sc0 ls0 ws2">ISBN<span class="_ _4"></span>-13 <span class="_ _7"></span>(pbk): <span class="_ _7"></span>978-1-4842-4978-9 <span class="_ _8"> </span> ISBN<span class="_ _4"></span>-13 <span class="_ _7"></span>(electr<span class="_ _3"></span>onic): <span class="_ _9"></span>978-1-4842-4979-6</div><div class="t m0 x6 h7 yc ff4 fs5 fc4 sc0 ls0 ws0">https://doi.org/10.1007/978-1-4842-4979-6</div><div class="t m0 x6 h8 yd ff4 fs6 fc2 sc0 ls0 ws0">Copyright © 2019 b<span class="_ _3"></span>y Adam Freem<span class="_ _3"></span>an</div><div class="t m0 x6 h7 ye ff4 fs5 fc2 sc0 ls0 ws0">This work is subject to copyright<span class="_ _3"></span>. All rights are reserved by the Publisher<span class="_ _4"></span>, whether the whole or part of the </div><div class="t m0 x6 h7 yf ff4 fs5 fc2 sc0 ls0 ws0">material is concerned, specifically the rights of transla<span class="_ _3"></span>tion, reprinting, r<span class="_ _3"></span>euse of illustrations<span class="_ _3"></span>, recitation, </div><div class="t m0 x6 h7 y10 ff4 fs5 fc2 sc0 ls0 ws0">broadcasting<span class="_ _3"></span>, reproduction on micr<span class="_ _3"></span>ofilms or in any other physical wa<span class="_ _3"></span>y, and transmission or information </div><div class="t m0 x6 h7 y11 ff4 fs5 fc2 sc0 ls0 ws0">storage and r<span class="_ _3"></span>etrieval, electronic adaptation, computer softwar<span class="_ _3"></span>e, or by similar or dis<span class="_ _3"></span>similar methodology now </div><div class="t m0 x6 h7 y12 ff4 fs5 fc2 sc0 ls0 ws0">known or hereafter developed.</div><div class="t m0 x6 h7 y13 ff4 fs5 fc2 sc0 ls0 ws0">Trademark<span class="_ _3"></span>ed names, logos<span class="_ _3"></span>, and images may appear in this book. Ra<span class="_ _3"></span>ther than use a trademark sym<span class="_ _3"></span>bol with </div><div class="t m0 x6 h7 y14 ff4 fs5 fc2 sc0 ls0 ws0">every occurrence of a trademarked name<span class="_ _3"></span>, logo<span class="_ _3"></span>, or image we use the names, logos<span class="_ _3"></span>, and images only in an </div><div class="t m0 x6 h7 y15 ff4 fs5 fc2 sc0 ls0 ws0">editorial fashion and to the benefit of the trademark owner<span class="_ _4"></span>, with no inten<span class="_ _3"></span>tion of infringement of the </div><div class="t m0 x6 h7 y16 ff4 fs5 fc2 sc0 ls0 ws0">trademark<span class="_ _3"></span>.</div><div class="t m0 x6 h7 y17 ff4 fs5 fc2 sc0 ls0 ws0">The use in this publication of trade n<span class="_ _3"></span>ames, tradem<span class="_ _3"></span>arks, service marks<span class="_ _3"></span>, and similar terms, even if they are not </div><div class="t m0 x6 h7 y18 ff4 fs5 fc2 sc0 ls0 ws0">identified as such, is not to be taken as an expr<span class="_ _3"></span>ession of opinion as to whether or not they are subject to </div><div class="t m0 x6 h7 y19 ff4 fs5 fc2 sc0 ls0 ws0">proprietary rights.</div><div class="t m0 x6 h7 y1a ff4 fs5 fc2 sc0 ls0 ws0">While the advice and information in this book are believed to be true and accurate a<span class="_ _3"></span>t the date of publication, </div><div class="t m0 x6 h7 y1b ff4 fs5 fc2 sc0 ls0 ws0">neither the authors nor the editors nor the publisher can accept any legal r<span class="_ _3"></span>esponsibility for any errors or </div><div class="t m0 x6 h7 y1c ff4 fs5 fc2 sc0 ls0 ws0">omissions that ma<span class="_ _3"></span>y be made. The publisher m<span class="_ _3"></span>akes no warranty, expres<span class="_ _3"></span>s or implied, with respect to the </div><div class="t m0 x6 h7 y1d ff4 fs5 fc2 sc0 ls0 ws0">material contained her<span class="_ _3"></span>ein.</div><div class="t m0 x6 h9 y1e ff5 fs5 fc2 sc0 ls0 ws0">Essential Typ<span class="_ _5"></span>eScript<span class="_ _5"></span>: From Beginner to Pro</div><div class="t m0 x5 h7 y1f ff4 fs5 fc2 sc0 ls0 ws0">Man<span class="_ _3"></span>aging Director<span class="_ _4"></span>, A<span class="_ _3"></span>press Media LLC: W<span class="_ _3"></span>elmoed Spahr</div><div class="t m0 x5 h7 y20 ff4 fs5 fc2 sc0 ls0 ws0">Acquisitions Editor: Joan Murr<span class="_ _3"></span>ay</div><div class="t m0 x5 h7 y21 ff4 fs5 fc2 sc0 ls0 ws0">Development Editor: Laura Berendson</div><div class="t m0 x5 h7 y22 ff4 fs5 fc2 sc0 ls0 ws0">Coordina<span class="_ _3"></span>ting Editor<span class="_ _5"></span>: M<span class="_ _3"></span>ark Powers</div><div class="t m0 x6 h7 y23 ff4 fs5 fc2 sc0 ls0 ws0">Cover designed b<span class="_ _3"></span>y eStudioCalamar</div><div class="t m0 x6 h7 y24 ff4 fs5 fc2 sc0 ls0 ws0">Cover ima<span class="_ _3"></span>ge designed by Freepik (<span class="ff6 fc4 ls2 ws3">www.freepik.com</span>)</div><div class="t m0 x6 h7 y25 ff4 fs5 fc2 sc0 ls0 ws0">Distributed to the book trade worldwide by Springer Science+Business M<span class="_ _3"></span>edia NewY<span class="_ _4"></span>ork, </div><div class="t m0 x6 h7 y26 ff4 fs5 fc2 sc0 ls0 ws0">233 Spring Str<span class="_ _3"></span>eet, 6th Floor<span class="_ _4"></span>, N<span class="_ _3"></span>ewY<span class="_ _4"></span>ork, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail </div><div class="t m0 x6 h7 y27 ff6 fs5 fc4 sc0 ls0 ws0">orders-ny@springer-sbm.com<span class="ff4 fc2">, or visit </span>www.springeronline.com<span class="ff4 fc2">. Apr<span class="_ _3"></span>ess Media, LLC is a California LLC </span></div><div class="t m0 x6 h7 y28 ff4 fs5 fc2 sc0 ls0 ws0">and the sole member (o<span class="_ _3"></span>wner) is Springer Science + Business Media Fin<span class="_ _3"></span>ance Inc (SSBM Fin<span class="_ _3"></span>ance Inc<span class="_ _3"></span>). </div><div class="t m0 x6 h7 y29 ff4 fs5 fc2 sc0 ls0 ws0">SSBM Fin<span class="_ _3"></span>ance Inc is a <span class="ff7">Delaware </span>corporation.</div><div class="t m0 x6 h7 y2a ff4 fs5 fc2 sc0 ls0 ws0">For informa<span class="_ _3"></span>tion on translations<span class="_ _3"></span>, please e-mail <span class="ff6 fc4 ls2 ws3">editorial@apress.com</span>; for reprint, paperback<span class="_ _3"></span>, or audio </div><div class="t m0 x6 h7 y2b ff4 fs5 fc2 sc0 ls0 ws0">rights, please email <span class="ff6 fc4 ls2 ws3">bookpermissions@springernature.com</span>.</div><div class="t m0 x6 h7 y2c ff4 fs5 fc2 sc0 ls0 ws0">Apr<span class="_ _3"></span>ess titles may be purc<span class="_ _3"></span>hased in bulk for academic, corporate<span class="_ _3"></span>, or promotional use<span class="_ _3"></span>. eBook versions and </div><div class="t m0 x6 h7 y2d ff4 fs5 fc2 sc0 ls0 ws0">licenses are also av<span class="_ _3"></span>ailable for most titles. F<span class="_ _3"></span>or more information, r<span class="_ _3"></span>eference our Print and eBook Bulk S<span class="_ _3"></span>ales </div><div class="t m0 x6 h7 y2e ff4 fs5 fc2 sc0 ls0 ws0">web page at <span class="ff6 fc4 ls2 ws3">www.apress.com/bulk-sales</span>.</div><div class="t m0 x6 h7 y2f ff4 fs5 fc2 sc0 ls0 ws0">Any source code or other supplemen<span class="_ _3"></span>tar<span class="_ _5"></span>y ma<span class="_ _3"></span>terial referenced b<span class="_ _3"></span>y the author in this book is available to </div><div class="t m0 x6 h7 y30 ff4 fs5 fc2 sc0 ls0 ws0">readers on GitH<span class="_ _3"></span>ub via the book’<span class="_ _4"></span>s product page, loca<span class="_ _3"></span>ted at <span class="ff6 fc4 ls2 ws3">www.apress.com/9781484249789</span>. For mor<span class="_ _3"></span>e </div><div class="t m0 x6 h7 y31 ff4 fs5 fc2 sc0 ls0 ws0">detailed information, please visit <span class="ff6 fc4 ls2 ws3">www.apress.com/source-code</span>.</div><div class="t m0 x6 h7 y32 ff4 fs5 fc2 sc0 ls0 ws0">Printed on acid-free paper</div><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a></div><div class="pi" data-data='{"ctm":[1.884722,0.000000,0.000000,1.884722,0.000000,0.000000]}'></div></div>
<div id="pf4" class="pf w2 h0" data-page-no="4"><div class="pc pc4 w2 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://csdnimg.cn/release/download_crawler_static/15331036/bg4.jpg"><div class="t m0 x7 ha y33 ff8 fs7 fc2 sc0 ls0 ws0">Dedicated to my lovely wife, J<span class="_ _3"></span>acqui Griyth.</div><div class="t m0 x8 ha y34 ff8 fs7 fc2 sc0 ls0 ws0">(And also to P<span class="_ _3"></span>eanut.)</div></div><div class="pi" data-data='{"ctm":[1.884722,0.000000,0.000000,1.884722,0.000000,0.000000]}'></div></div>
<div id="pf5" class="pf w2 h0" data-page-no="5"><div class="pc pc5 w2 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://csdnimg.cn/release/download_crawler_static/15331036/bg5.jpg"><div class="t m0 x9 hb y35 ff4 fs7 fc2 sc0 ls0 ws0">v</div><div class="t m0 xa hc y36 ff9 fs8 fc4 sc0 ls0 ws0"> <span class="_ _a"></span><span class="ffa fc3">■<span class="_ _5"></span><span class="ff9 fc4">P<span class="_ _3"></span>art I: Getting Started with T<span class="_ _b"></span>ypeScript<span class="ws4"> �����������������������������������������������<span class="_ _c"> </span></span>1</span></span></div><div class="t m0 xb hd y37 ff9 fs9 fc4 sc0 ls0 ws0"> <span class="_ _d"></span><span class="ffa fc3">■<span class="_ _5"></span><span class="ff9 fc4">Chapter 1:<span class="fc5"> </span>Y<span class="_ _b"></span>our First T<span class="_ _4"></span>ypeScript Application<span class="ws5"> ���������������������������������������������������������<span class="_ _e"> </span></span>3</span></span></div><div class="t m0 xb hd y38 ffb fs9 fc4 sc0 ls0 ws0">Getting Ready for <span class="_ _4"></span>This Book<span class="ws6"> ���������������������������������������������������������������������������������������������<span class="_ _e"> </span></span>3</div><div class="t m0 xc he y39 ffb fs7 fc4 sc0 ls0 ws0">Step 1:<span class="_ _3"></span> Install Node<span class="_ _3"></span>�js<span class="ws7"> �����������������������������������������������������������������������������������������������������������������������������<span class="_"> </span></span>3</div><div class="t m0 xc he y3a ffb fs7 fc4 sc0 ls0 ws0">Step 2:<span class="_ _3"></span> Install Git<span class="ws8"> ������������������������������������������������������������������������������������������������������������������������������������<span class="_ _2"> </span></span>3</div><div class="t m0 xc he y3b ffb fs7 fc4 sc0 ls0 ws0">Step 3:<span class="_ _3"></span> Install <span class="_ _3"></span>T<span class="_ _4"></span>ypeScript<span class="ws9"> ������������������������������������������������������������������������������������������������������������������������<span class="_ _0"></span></span>4</div><div class="t m0 xc he y3c ffb fs7 fc4 sc0 ls0 ws0">Step 4:<span class="_ _3"></span> Install a Programmer’<span class="_ _3"></span>s Editor<span class="wsa"> �����������������������������������������������������������������������������������������������������<span class="_ _2"> </span></span>4</div><div class="t m0 xb hd y3d ffb fs9 fc4 sc0 ls0 ws0">Creating the Project<span class="wsb"> ����������������������������������������������������������������������������������������������������������<span class="_ _e"> </span></span>5</div><div class="t m0 xc he y3e ffb fs7 fc4 sc0 ls0 ws0">Initializing the Project<span class="wsc"> �����������������������������������������������������������������������������������������������������������������������������<span class="_ _2"> </span></span>5</div><div class="t m0 xc he y3f ffb fs7 fc4 sc0 ls0 ws0">Creating the Compiler Configuration File<span class="wsd"> ������������������������������������������������������������������������������������������������<span class="_ _0"></span></span>6</div><div class="t m0 xc he y40 ffb fs7 fc4 sc0 ls0 ws0">Adding a <span class="_ _3"></span>T<span class="_ _4"></span>ypeScript Code File<span class="wse"> ����������������������������������������������������������������������������������������������������������������<span class="_ _2"> </span></span>6</div><div class="t m0 xc he y41 ffb fs7 fc4 sc0 ls0 ws0">Compiling and Executing the Code<span class="wsf"> ���������������������������������������������������������������������������������������������������������<span class="_ _2"> </span></span>6</div><div class="t m0 xc he y42 ffb fs7 fc4 sc0 ls0 ws0">Defining the Data Model<span class="ws10"> �������������������������������������������������������������������������������������������������������������������������<span class="_"> </span></span>7</div><div class="t m0 xc he y43 ffb fs7 fc4 sc0 ls0 ws0">Adding Features to the Collection Class<span class="ws11"> �����������������������������������������������������������������������������������������������<span class="_"> </span></span>13</div><div class="t m0 xb hd y44 ffb fs9 fc4 sc0 ls0 ws0">Using a <span class="_ _3"></span>Third-Party Package<span class="ws12"> ������������������������������������������������������������������������������������������<span class="_ _f"> </span></span>20</div><div class="t m0 xc he y45 ffb fs7 fc4 sc0 ls0 ws0">Adding <span class="_ _3"></span>T<span class="_ _4"></span>ype Declarations for the Jav<span class="_ _3"></span>aScript Package<span class="ws13"> �������������������������������������������������������������������������<span class="_ _2"> </span></span>22</div><div class="t m0 xb hd y46 ffb fs9 fc4 sc0 ls0 ws0">Adding Commands<span class="ws14"> ���������������������������������������������������������������������������������������������������������<span class="_ _f"> </span></span>23</div><div class="t m0 xc he y47 ffb fs7 fc4 sc0 ls0 ws0">Filtering Items<span class="ws15"> ���������������������������������������������������������������������������������������������������������������������������������������<span class="_ _2"> </span></span>24</div><div class="t m0 xc he y48 ffb fs7 fc4 sc0 ls0 ws16">Adding T<span class="_ _4"></span>asks<span class="ws17"> �����������������������������������������������������������������������������������������������������������������������������������������<span class="_ _2"> </span><span class="ws0">25</span></span></div><div class="t m0 xc he y49 ffb fs7 fc4 sc0 ls0 ws16">Marking T<span class="_ _4"></span>asks <span class="_ _5"></span>Complete<span class="ws18"> ����������������������������������������������������������������������������������������������������������������������<span class="_ _0"></span><span class="ws0">27</span></span></div><div class="t m0 x5 hf y4a ffc fsa fc2 sc0 ls0 ws0">T<span class="_ _10"></span>able of<span class="_ _f"></span> Contents</div><div class="t m0 x5 hd y4b ff9 fs9 fc4 sc0 ls0 ws0">About the Author<span class="ws19"> ����������������������������������������������������������������������������������������������������</span>xix</div><div class="t m0 x5 hd y4c ff9 fs9 fc4 sc0 ls0 ws0">About the T<span class="_ _b"></span>echnical Reviewer<span class="ws1a"> ��������������������������������������������������������������������������������</span>xxi</div><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a></div><div class="pi" data-data='{"ctm":[1.884722,0.000000,0.000000,1.884722,0.000000,0.000000]}'></div></div>