万本电子书0元读

万本电子书0元读

顶部广告

Learning TypeScript 2.x电子书

售       价:¥

8人正在读 | 0人评论 6.2

作       者:Remo H. Jansen

出  版  社:Packt Publishing

出版时间:2018-04-30

字       数:60.5万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Exploit the features of TypeScript to easily create your very own web applications About This Book ? Develop modular, scalable, maintainable, and adaptable web applications by taking advantage of TypeScript ? Walk through the fundamentals of TypeScript with the help of practical examples ? Enhance your web development skills using TypeScript 2.x Who This Book Is For If you are a developer aiming to learn TypeScript to build attractive web applications, this book is for you. No prior knowledge of TypeScript is required. However, a basic understanding of JavaScript would be an added advantage. What You Will Learn ? Understand TypeScript in depth, including its runtime and advanced type system features ? Master the core principles of the object-oriented programming and functional programming paradigms with TypeScript ? Save time using automation tools such as Gulp, Webpack, ts-node, and npm scripts ? Develop robust, modular, scalable, maintainable, and adaptable applications with testing frameworks such as Mocha, Chai, and Sinon.JS ? Put your TypeScript skills to practice by developing full-stack web applications with Node.js, React and Angular ? Use the APIs of the TypeScript compiler to build custom code analysis tool In Detail TypeScript is an open source and cross-platform statically typed superset of JavaScript that compiles to plain JavaScript and runs in any browser or host. This book is a step-by-step guide that will take you through the use and benefits of TypeScript with the help of practical examples. You will start off by understanding the basics as well as the new features of TypeScript 2.x. Then, you will learn how to work with functions and asynchronous programming APIs. You will continue by learning how to resolve runtime issues and how to implement TypeScript applications using the Object-oriented programming (OOP) and functional programming (FP) paradigms. Later, you will automate your development workflow with the help of tools such as Webpack. Towards the end of this book, you will delve into some real-world scenarios by implementing some full-stack TypeScript applications with Node.js, React and Angular as well as how to optimize and test them. Finally, you will be introduced to the internal APIs of the TypeScript compiler, and you will learn how to create custom code analysis tools. Style and approach This is a step-by-step guide that covers the fundamentals of TypeScript with practical examples.
目录展开

Title Page

Copyright and Credits

Learning TypeScript 2.x Second Edition

Dedication

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the author

About the reviewers

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

Introducing TypeScript

The TypeScript architecture

Design goals

TypeScript components

TypeScript language features

Types

Type inference and optional static type annotations

Variables, basic types, and operators

Variable scope (var, let, and const)

Arithmetic operators

Comparison operators

Logical operators

Bitwise operators

Assignment operators

Spread operator

Flow control statements

The single-selection structure (if)

The double-selection structure (if...else)

The inline ternary operator (?)

The multiple-selection structure (switch)

The expression is tested at the top of the loop (while)

The expression is tested at the bottom of the loop (do...while)

Iterate on each object's properties (for...in)

Iterate values in an iterable (for...of)

Counter-controlled repetition (for)

Functions

Classes

Interfaces

Namespaces

Putting everything together

Summary

Working with Types

The TypeScript type system's characteristics

The line between TypeScript and JavaScript

Type inference

Optional static type annotations

Structural type system

Core features of the TypeScript type system

Union types

Type aliases

Intersection types

Non-nullable types

The --strict mode

The typeof operator

Type guards

Custom type guards

Control flow analysis

Literal types

Discriminated unions

The never type

Enumerations

Object literals

Weak types

The keyof operator

Index signature

Local types

Type casting

Advanced features of the TypeScript type system

Generic types

Generic constraints

Mapped types

Lookup types

Mapped type modifiers

Conditional types

The infer keyword

Built-in conditional types

The polymorphic this type

Ambient declarations

Type declarations – .d.ts

Summary

Working with Functions

Working with functions in TypeScript

Function declarations and function expressions

Function types

Trailing commas in function arguments

Functions with optional parameters

Functions with default parameters

Functions with REST parameters

Function overloading

Specialized overloading signature

Function scope

Immediately invoked functions

Tag functions and tagged templates

Asynchronous programming in TypeScript

Callbacks and higher-order functions

Arrow functions

Callback hell

Promises

Covariant checking in callback parameters

Generators

Asynchronous functions – async and await

Asynchronous generators

Asynchronous iteration (for await...of)

Delegating to another generator (yield*)

Summary

Object-Oriented Programming with TypeScript

Classes

Strict property initialization

Inheritance

Depth of the inheritance tree (DIT)

Access modifiers

The public access modifier

The private access modifier

The protected access modifier

Parameter properties

Class expressions

Static members

Optional members

Read-only properties

Method overriding

Generic classes

Generic constraints

Multiple types in generic type constraints

The new operator in generic types

Association, aggregation, and composition

Association

Aggregation

Composition

Mixins (multiple inheritance)

The diamond problem

Implementing mixins

Iterables

Abstract classes

Interfaces

SOLID principles, encapsulation, and polymorphism

SOLID – the single responsibility principle

Encapsulation

SOLID – the open/closed principle

Polymorphism

SOLID – the Liskov substitution principle

SOLID – the interface segregation principle

SOLID – the dependency inversion principle

Summary

Working with Dependencies

Third-party dependencies

Package management tools

The rise and fall of package management tools

npm

Type definitions

Modules with native support for TypeScript

Modules with external support for TypeScript

Modules with no support for TypeScript

The ECMAScript specification type definitions (lib.d.ts)

External TypeScript helpers (tslib)

Internal modules (module and namespace)

Nested internal modules

Cross-file internal modules

Internal module aliases

Compiling internal modules

External modules

Module loaders and module definition syntaxes

External modules at design time and runtime

ES6 modules (runtime and design time)

Legacy external modules (design time only)

AMD modules (runtime only)

CommonJS modules (runtime only)

UMD modules (runtime only)

SystemJS modules (runtime only)

Modules summary

Managing dependencies in OOP

Dependency injection versus dependency inversion

Inversion of control containers

InversifyJS basics

Circular dependencies

Summary

Understanding the Runtime

The execution environment

Understanding the event loop

Frames

Stack

Queue

Heap

The event loop

The this operator

The this operator in the global context

The this operator in a function context

The call, apply, and bind methods

Prototypes

Instance properties versus class properties

Prototypal inheritance

The prototype chain and property shadowing

Accessing the prototype of an object

The new operator

Closures

Static variables powered by closures

Private members powered by closures

Summary

Functional Programming with TypeScript

FP concepts

Pure functions

Side effects

Referential transparency

Immutability

Functions as first-class citizens

Lambda expressions

Function arity

Higher-order functions

The benefits of FP

Is TypeScript a FP language?

FP techniques

Composition

Partial application

Currying

Pipes

Pointfree style

Recursion

Category theory

Functor

Applicative

Maybe

Either

Monad

Real-world FP

Immutable.js

Ramda

React and MobX

Summary

Working with Decorators

Prerequisites

Annotations versus decorators

The class decorators

The method decorators

The property decorators

The parameter decorators

Decorators with arguments

The reflect metadata API

The decorator factory

Summary

Automating Your Development Workflow

A modern development workflow

Prerequisites

Node.js

Visual Studio Code

Git and GitHub

Companion source code

Source control tools

Package management tools

The TypeScript compiler

Linting tools

Working with npm scripts

Gulp

Controlling the gulp task execution order

Passing in a callback to the task definition function

Returning a promise

Returning a stream

Webpack

Webpack development server

Unit testing and test coverage

Visual Studio Code

Quick fixes

Debugging utilities

Source control utilities

ts-node

Continuous integration (CI) tools

Scaffolding tools

Why does the command line win?

Summary

Node.js Development with TypeScript

Understanding Node.js

Understanding non-blocking I/O

The main components of Node.js

V8

Libuv

Bindings

The Node.js core API (node-core)

Node.js environment versus browser environment

The Node.js ecosystem

The Node.js core API

The style of the Node.js core API

The npm ecosystem

Setting up Node.js

Node.js development

Working with the filesystem

Working with databases

Working with REST APIs

Hello world (http)

Hello world (Express.js)

Routing with Express

Express middleware

Architecting Node.js application – the MVC design pattern

Model

Repository

Controller

Database

View

Index

Controllers and routing with inversify-express-utils

Model, repository, database, and view

Types

Controller

InversifyJS configuration

Index

Other applications of Node.js

Summary

Frontend Development with React and TypeScript

Working with React

About the sample application

Serving a React application with Node.js

Working with react-dom and JSX

Working with the react-router

Working with React components

Components as classes

Properties and state

Functional stateless components

React component life cycle

Smart components and dumb components

Working with MobX

Understanding the MobX architecture

Working with actions and observables

Dependency injection in MobX

MobX alternatives

Development tools

Summary

Frontend Development with Angular and TypeScript

Working with Angular

About the sample application

Serving an Angular application with Node.js

Bootstrapping an Angular application

Working with NgModules

Working with Angular components

Our first component

Components and directives

Data binding

Working with @Attribute and @Input

Using structural directives

Using the <ng-content> directive

Working with @Output and EventEmitter

Working with the component's host

Working with the Angular router

Angular component life cycle hooks

Working with services

Smart components and dumb components

Dependency injection in Angular

Summary

Application Performance

Prerequisites

Google Chrome

Node.js

Performance and resources

Common performance metrics

Availability

Response time

Processing speed

Bandwidth

Latency

Scalability

Performance analysis

Network performance analysis

Network performance and user experience

Network performance best practices and rules

GPU performance analysis

Frames per second (FPS)

CPU performance analysis

Memory performance analysis

The garbage collector

Performance analysis in Node.js applications

Performance automation

Performance optimization automation

Performance monitoring automation

Performance testing automation

Exception handling

The Error class

The try...catch statements and throw statements

Summary

Application Testing

Testing terminology

Assertions

Specs

Test cases

Suites

Spies

Dummies

Stubs

Mocks

Test coverage

Prerequisites

Mocha

Chai

Sinon.JS

nyc

Webpack

Enzyme

SuperTest

PM2

Nightwatch.js and ChromeDriver

Testing methodologies

Test-driven development (TDD)

Behavior-driven development (BDD)

Tests plans and test types

Unit tests

Integration tests

Regression tests

Performance and load tests

End-to-end (e2e) tests

User-acceptance tests (UAT)

The example application

Unit tests and integration tests with Mocha

Back to basics

Testing asynchronous code

Asserting exceptions

Testing a web service with SuperTest

Working with tests suites

Isolating components with Sinon.JS

jsdom

Testing React web components with Enzyme

TDD versus BDD with Mocha and Chai

End-to-end tests with Nightwatch.js

Summary

Working with the TypeScript Compiler and the Language Services

The TypeScript compiler's internal architecture

Scanner

Lexemes and tokens

Parser

AST

Symbols

Binder

Type checker

Emitter

Language service

Understanding the abstract syntax tree (AST)

TypeScript AST Viewer

Sample application

interfaces.ts

katana.ts

ninja.ts

main.ts

broken.ts

Traversing the TypeScript AST

Working with ts-simple-ast

Traversing the AST with ts-simple-ast

Diagnostics with ts-simple-ast

Accessing class details with ts-simple-ast

Accessing module details with ts-simple-ast

Accessing the language services API

Implementing a yUML compiler

VS Code extensions

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部