• Complain

Nicholas Brown - TypeScript: JavaScript Development Guide

Here you can read online Nicholas Brown - TypeScript: JavaScript Development Guide full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2016, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    TypeScript: JavaScript Development Guide
  • Author:
  • Genre:
  • Year:
    2016
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

TypeScript: JavaScript Development Guide: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "TypeScript: JavaScript Development Guide" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

This book is an exploration of TypeScript, which is a superset of JavaScript. The first part of the book explains to you what TypeScript is and what it is used for. You will also learn how it is related to JavaScript. The book also guides you on how to install TypeScript on Windows and on other platforms. Type annotations, which are very good in defining how the program is indented, are discussed, and thus, you will learn how to work with them. Interfaces, which are good and compatible with most objects, are discussed in detail. Understanding the scope of objects such as this is very difficult. This book examines arrow functions which are a good mechanism to help you understand the scope of this keyword. Expressions are also used widely in TypeScript, and these have been explored in detail. Classes which are very important in object-oriented programming and for creation of large apps are also covered, along with features such as inheritance which are associated with classes; Iterators have also been explored in detail. The forof loop is widely used in TypeScript. This is discussed in this book, along with how to implement it. The spread operator, which is used for the purpose of spreading the elements of an array, is also examined.The following topics are discussed in this book:A Brief Overview of TypeScriptInstalling TypeScriptType AnnotationsInterfacesArrow Function ExpressionsClassesDestructuringforofIteratorsTemplate StringsSpread OperatorEnumslet

Nicholas Brown: author's other books


Who wrote TypeScript: JavaScript Development Guide? Find out the surname, the name of the author of the book and a list of all author's works by series.

TypeScript: JavaScript Development Guide — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "TypeScript: JavaScript Development Guide" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make

TypeScript JavaScript Development Guide By Nicholas Brown
Copyright2016 by Nicholas Brown All Rights Reserved
Copyright 2016 by David Johnson All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the author, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law.
Table of Contents
Disclaimer While all attempts have been made to verify the information provided in this book, the author does assume any responsibility for errors, omissions, or contrary interpretations of the subject matter contained within. The information provided in this book is for educational and entertainment purposes only. The reader is responsible for his or her own actions and the author does not accept any responsibilities for any liabilities or damages, real or perceived, resulting from the use of this information. The trademarks that are used are without any consent, and the publication of the trademark is without permission or backing by the trademark owner.

All trademarks and brands within this book are for clarifying purposes only and are the owned by the owners themselves, not affiliated with this document.


Introduction
There is a greater need for large software applications, and especially the web applications. The reason behind this is the increase in the functionalities which are needed to be implemented in software applications. This calls for us to learn how to develop large applications. This can only be done in programming languages which are capable of supporting that. TypeScript is one of such programming languages.

It supports the creation of large applications. This book is an excellent waay for you to learn how to program in TypeScript. Enjoy reading!


Chapter 1- A Brief Overview of TypeScript
TypeScript is a programming language which was developed and is maintained by Microsoft. It is an open source programming language. The language is a superset of JavaScript since it has added some extra features to it, such as support for object oriented programming and optional static typing. The language was developed for the purpose of creating large applications, and it always compiles into JavaScript.

One can use TypeScript to develop JavaScript applications for both the client side and server side. Since we have said that TypeScript is a superset of javaScript, any program written in JavaScript is also viable to be considered a TypeScript program. The TypeScript compiler was also written in TypeScript. The aim of TypeScript is to provide developers with an easy mechanism by which to develop large applications. It comes with concepts such as classes, inheritance, interfaces, modules, and others, and these make it easy for developers to create large applications with much ease.


Chapter 2- Installing TypeScript
There are two ways that we can install TypeScript into our system.

These include the following:

  1. By use of the npm (Node Package Manager) tool.
  1. By installation of Visual studio plugins for TypeScript.
For Windows users, you can use the second option if it will be more convenient for you. Just install the Visual Studio, and then download and install the necessary plugin for programming in TypeScript. This option has been found to be a bit superior compared to the use of other code editors. For those using platforms other than Windows, just ensure that you have a text editor, a browser, and the npm package for TypeScript so as to be able to program in TypeScript. The following steps can be followed for this to be done:
  1. Begin by installing the Node Package Manager (npm).
Just open the terminal, and execute the commands given below: $ curl http://npmjs.org/install.sh | sh $ npm --version 1.1.70
  1. In the next step, install the TypeScript npm package, and this should be done globally on the command line. The following commands can be used for doing this:
$ npm install -g typescript $ npm view typescript version npm http GET https://registry.npmjs.org/typescript npm http 304 https://registry.npmjs.org/typescript 0.8.1-1 Make sure that you use the latest version of your browser, such as Chrome.

Any text editor is appropriate, and an example of this is the Sublime text editor.
Hello World Example Now that we have set up the environment ready for programming, we can begin to program. We will begin by creating the Hello world example. Remember that TypeScript is a superset of ES5, and it has more features for ES6. TypeScript is also compiled into JavaScript. We want to create our index file and then reference it to an external file.

Here is the code for the file index.html : As shown in the above code, we have referenced the code in the file to the file hello.ts. This has been done in the line as the script source. The extension .ts in the file name means that it is a TypeScript file. Now, create a new file and give it the name hello.ts. The following line of code should then be added to the file: alert('hello world, this is TypeScript!'); After that, just launch the command line, and then navigate to the folder with the file hello.ts. Compile the file by executing the following command: tsc hello.ts The tsc command in TypeScript represents the TypeScript compiler, and it will generate a new file with the name hello.js.

From the extension in the file, we will have transformed the TypeScript to a JavaScript file, which is what normally happens in TypeScript.


Chapter 3- Type Annotations
This feature is optional in TypeScript, and it allows us to express and implement indentation in our TypeScript programs. We need to demonstrate this by creating a program which will calculate the area of a rectangle. Just open your text editor and create a new file with the name area.ts. Add the following code to the file: function area(shape: string, width: number, height: number) { var area = width * height; return "The shape is " + shape + " having an area of " + area + " cm squared."; } document.body.innerHTML = area("rectangle", 20, 15); Next, open the file index.html and change the script source from type.ts to area.ts. Open your terminal, and then execute the following command so as to compile the whole thing: tsc area.ts The message together with the area of the rectangle will be displayed.

As you must have noticed, the type annotations are passed to the parameters of the function, and they are used for indicating the kind of parameters which are supported by the function. In the above example, the parameter shape is a string, while the parameters length and width are numbers. You have to know that both Type annotations and other TypeScript features are enforced during compile time. In case one passes other types of values to these parameters, a compile-time error will be displayed by the compiler. This is a very good idea when it comes to working with large applications. We need to demonstrate how errors will be detected in our case.

Consider the code given below: function area(shape: string, width: number, height: number) { var area = width * height; return "The shape is " + shape + " having an area of " + area + " cm squared."; } document.body.innerHTML = area("rectangle", "width", 15); // wrong type of width In the above example, the width has been passed in as a string, which is wrong. The compiler expects that the width should be a number. After compiling the program given above, you will get the following as the error: $ tsc type.ts type.ts(6,26): Supplied parameters do not match any signature of call target That is the kind of error you get. However, you must have noticed that although there was a warning due to type mismatch, this did not stop the TypeScript file from compiling and creating a JavaScript file. As shown in the above examples, it is very clear that annotations are used for the purpose of recording the function which a function or a variable is intended to perform. Suppose that you have a function which expects that only a single parameter should be passed to it, and the parameter should be of the string type.

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «TypeScript: JavaScript Development Guide»

Look at similar books to TypeScript: JavaScript Development Guide. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «TypeScript: JavaScript Development Guide»

Discussion, reviews of the book TypeScript: JavaScript Development Guide and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.