售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
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
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜