0%

Book Description

Master the TypeScript language and its latest features. Explore modern application frameworks and utilize industry best practices in TDD, OOP and UI Design.

Key Features

  • Learn the key features of TypeScript 3 and explore advanced language features through in-depth discussions.
  • Use TypeScript with modern frameworks including Backbone, Angular, Aurelia, React, and Node.
  • Explore TDD practices, OOP techniques, and industry best practices to create high-quality, modular, and adaptable applications.

Book Description

TypeScript is both a language and a set of tools to generate JavaScript. It was designed by Anders Hejlsberg at Microsoft to help developers write enterprise-scale JavaScript.

Starting with an introduction to the TypeScript language, before moving on to basic concepts, each section builds on previous knowledge in an incremental and easy-to-understand way. Advanced and powerful language features are all covered, including asynchronous programming techniques, decorators, and generics.

This book explores many modern JavaScript and TypeScript frameworks side by side in order for the reader to learn their respective strengths and weaknesses. It will also thoroughly explore unit and integration testing for each framework.

Best-of-breed applications utilize well-known design patterns in order to be scalable, maintainable, and testable. This book explores some of these object-oriented techniques and patterns, and shows real-world implementations.

By the end of the book, you will have built a comprehensive, end-to-end web application to show how TypeScript language features, design patterns, and industry best practices can be brought together in a real-world scenario.

What you will learn

  • Gain insights into core and advanced TypeScript language features
  • Integrate existing JavaScript libraries and third-party frameworks using declaration files
  • Target popular JavaScript frameworks, such as Angular, React, and more
  • Create test suites for your application with Jasmine and Selenium
  • Organize your application code using modules, AMD loaders, and SystemJS
  • Explore advanced object-oriented design principles
  • Compare the various MVC implementations in Aurelia, Angular, React, and more

Who this book is for

This guide to the TypeScript that starts with basic concepts, and then builds on this knowledge to introduce more advanced language features and frameworks. No prior knowledge of JavaScript is required, although some prior programming experience is assumed. If you are keen to learn TypeScript, this book will give you all of the necessary knowledge and skills to tackle any TypeScript project. If you are already an experienced JavaScript or TypeScript developer, then this book will take your skills to the next level. Learn how to use TypeScript with a multitude of modern frameworks, and choose the best framework for your project requirements. Investigate techniques for Test Driven Development, explore industry-standard design patterns, and learn how to put together a full production-ready TypeScript application.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering TypeScript 3 Third Edition
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. TypeScript Tools and Framework Options
    1. What is TypeScript?
      1. JavaScript and the ECMAScript Standard
      2. The benefits of TypeScript
        1. Compiling
        2. Strong typing
          1. TypeScript's syntactic sugar
        3. Type definitions for popular JavaScript libraries
          1. DefinitelyTyped
        4. Encapsulation
          1. TypeScript classes generate closures
        5. Public and private accessors
    2. TypeScript IDEs
      1. Node-based compilation
        1. Creating a tsconfig.json file
        2. Localized messages
      2. Visual Studio Code
        1. Installing VSCode
        2. Exploring VSCode
          1. Creating a tasks.json file
          2. Building the project
          3. Creating a launch.json file
          4. Setting breakpoints
          5. Debugging web pages
      3. Microsoft Visual Studio
        1. Creating a Visual Studio project
        2. Default project settings
        3. Debugging in Visual Studio
      4. WebStorm
        1. Creating a WebStorm project
        2. Default files
        3. Building a simple HTML application
        4. Running the web page in Chrome
      5. Other editors
        1. Using --watch and Grunt
    3. Summary
  7. Types, Variables, and Function Techniques
    1. Basic types
      1. JavaScript typing
      2. TypeScript typing
      3. Type syntax
      4. Inferred typing
      5. Duck typing
      6. Template strings
      7. Arrays
      8. for...in and for...of
      9. The any type
      10. Explicit casting
      11. Enums
      12. Const enums
      13. String enums
      14. Enum implementation
      15. Const values
      16. The let keyword
      17. Definite assignment
      18. Dotted property types
      19. Numeric separators
    2. Functions
      1. Function return types
      2. Anonymous functions
      3. Optional parameters
      4. Default parameters
      5. Rest parameters
      6. Function callbacks
      7. Function signatures
      8. Function overrides
      9. Try catch
    3. Advanced types
      1. Union types
      2. Type guards
      3. Type aliases
      4. Null and undefined
      5. Null operands
        1. Never
        2. Unknown
      6. Object rest and spread
        1. Spread precedence
        2. Rest and spread with arrays
      7. Tuples
        1. Tuple destructuring
        2. Optional tuple elements
        3. Tuples and rest syntax
      8. Bigint
    4. Summary
  8. Interfaces, Classes, and Inheritance
    1. Interfaces
      1. Optional properties
      2. Interface compilation
      3. Weak types
      4. Type inference with the in operator
    2. Classes
      1. Class properties
      2. Implementing interfaces
      3. Class constructors
      4. Class functions
      5. Interface function definitions
      6. Class modifiers
      7. Constructor access modifiers
      8. Readonly properties
      9. Class property accessors
      10. Static functions
      11. Static properties
      12. Namespaces
    3. Inheritance
      1. Interface inheritance
      2. Class inheritance
      3. The super keyword
      4. Function overriding
      5. Protected class members
      6. Abstract classes
      7. JavaScript closures
      8. instanceof
    4. Using interfaces, classes, and inheritance – the Factory Design Pattern
      1. Business requirements
      2. What the Factory Design Pattern does
        1. The IPerson interface
        2. The Person class
        3. Specialist classes
        4. The Factory class
        5. Using the Factory class
    5. Summary
  9. Decorators, Generics, and Asynchronous Features
    1. Decorators
      1. Decorator syntax
      2. Multiple decorators
      3. Decorator factories
      4. Class decorator parameters
      5. Property decorators
      6. Static property decorators
      7. Method decorators
      8. Using method decorators
      9. Parameter decorators
      10. Decorator metadata
      11. Using decorator metadata
    2. Generics
      1. Generic syntax
      2. Instantiating generic classes
      3. Using the type T
      4. Constraining the type of T
      5. Generic interfaces
      6. Creating new objects within generics
    3. Advanced types with generics
      1. Conditional types
      2. Distributed conditional types
      3. Conditional type inference
      4. keyof
      5. keyof with number
      6. Mapped types
      7. Partial, Readonly, Record, and Pick
    4. Asynchronous language features
      1. Promises
      2. Promise syntax
      3. Using promises
      4. Callback versus promise syntax
      5. Returning values from promises
      6. async and await
      7. await errors
      8. Promise versus await syntax
      9. await messages
    5. Summary
  10. Declaration Files and Strict Compiler Options
    1. Global variables
    2. Using JavaScript code blocks in HTML
      1. Structured data
    3. Writing your own declaration file
      1. The module keyword
      2. Interfaces
      3. Union types
    4. Module merging
    5. Declaration syntax reference
      1. Function overrides
        1. The JavaScript syntax
        2. The declaration file syntax
      2. Nested namespaces
        1. The JavaScript syntax
        2. The declaration file syntax
      3. Classes
        1. The JavaScript syntax
        2. The declaration file syntax
      4. Class namespaces
        1. The JavaScript syntax
        2. The declaration file syntax
      5. Class constructor overloads
        1. The JavaScript syntax
        2. The declaration file syntax
      6. Class properties
        1. The JavaScript syntax
        2. The declaration file syntax
      7. Class functions
        1. The JavaScript syntax
        2. The declaration file syntax
      8. Static properties and functions
        1. The JavaScript syntax
        2. The declaration file syntax
      9. Global functions
        1. The JavaScript syntax
        2. The declaration file syntax
      10. Function signatures
        1. The JavaScript syntax
        2. The declaration file syntax
      11. Optional properties
        1. The JavaScript syntax
        2. The declaration file syntax
      12. Merging functions and modules
        1. The JavaScript syntax
        2. The declaration file syntax
    6. Strict compiler options
      1. noImplicitAny
      2. strictNullChecks
      3. strictPropertyInitialization
      4. noUnusedLocals and noUnusedParameters
      5. noImplicitReturns
      6. noFallthroughCasesInSwitch
      7. strictBindCallApply
    7. Summary
  11. Third-Party Libraries
    1. Using definition files
    2. Using NuGet
      1. Using the NuGet Extension Manager
      2. Installing declaration files
      3. Using the Package Manager Console
        1. Installing packages
        2. Searching for package names
        3. Installing a specific version
    3. Using npm and @types
    4. Using third-party libraries
      1. Choosing a JavaScript framework
    5. Backbone
      1. Using inheritance with Backbone
      2. Using interfaces
      3. Using generic syntax
      4. Using ECMAScript 5
      5. Backbone TypeScript compatibility
    6. Angular 1
      1. Angular classes and $scope
      2. Angular 1 TypeScript compatibility
    7. Inheritance – Angular 1 versus Backbone
    8. ExtJS
      1. Creating classes in Ext JS
      2. Using type casting
      3. An Ext JS-specific TypeScript compiler
    9. Summary
  12. TypeScript Compatible Frameworks
    1. What is MVC?
      1. The Model
      2. The View
      3. The Controller
      4. MVC summary
      5. The Benefits of using MVC
      6. Sample application outline
    2. Using Backbone
      1. Rendering performance
      2. Backbone setup
      3. Backbone structure
      4. Backbone models
      5. Backbone ItemView
      6. Backbone ItemCollectionView
      7. Backbone application
      8. Backbone forms
      9. Backbone summary
    3. Using Aurelia
      1. Aurelia setup
      2. Aurelia controllers and models
      3. Aurelia views
      4. Aurelia application bootstrap
      5. Aurelia events
      6. Aurelia forms
      7. Aurelia summary
    4. Angular
      1. Angular setup
      2. Angular models
      3. Angular views
      4. Angular events
      5. Angular forms
        1. Angular template forms
        2. Template form limitations
        3. Angular Reactive forms
        4. Using Reactive forms
      6. Angular summary
    5. Using React
      1. React setup
      2. Configuring webpack
      3. React ItemView
      4. React CollectionView
      5. React bootstrapping
      6. React forms
        1. React state change
        2. React state properties
      7. React TypeScript features
        1. JSX template rest syntax
        2. Default properties
      8. React summary
    6. Performance comparison
    7. Summary
  13. Test-Driven Development
    1. Test-driven development
    2. Unit, integration, and acceptance tests
      1. Unit tests
      2. Integration tests
      3. Acceptance tests
    3. Unit testing frameworks
    4. Jasmine
      1. A simple Jasmine test
      2. Test reporters
      3. Matchers
      4. Test start-up and tear-down
      5. Forcing tests
      6. Skipping tests
      7. Data-driven tests
      8. Using spies
      9. Spying on callback functions
      10. Using spies as fakes
      11. Asynchronous tests
      12. Using done()
      13. Using async await
      14. HTML-based tests
      15. Jasmine fixtures
      16. DOM events
    5. Jasmine runners
      1. Testem
      2. Karma
      3. Headless testing
      4. Protractor
        1. Using Selenium
      5. Finding page elements
    6. Using continuous integration
      1. Benefits of CI
      2. Selecting a build server
        1. Team Foundation Server
        2. Jenkins
        3. TeamCity
      3. Integration test reporting
    7. Summary
  14. Testing Typescript Compatible Frameworks
    1. Testing our sample application
    2. Backbone testing
      1. Test setup
      2. Model tests
      3. Complex model tests
      4. Rendering tests
      5. DOM event tests
      6. Collection view tests
      7. Form tests
      8. Backbone testing summary
    3. Aurelia testing
      1. Aurelia test setup
      2. Aurelia unit tests
      3. Rendering tests
      4. Aurelia DOM events
      5. Aurelia test summary
    4. Angular testing
      1. Angular test setup
      2. Angular model tests
      3. Angular rendering tests
      4. Angular form tests
      5. Angular testing summary
    5. React testing
      1. Multiple entry points
      2. Using Jest
      3. Basic React Test format
      4. Initial state tests
      5. React form input
      6. React form submission
      7. React testing summary
    6. Summary
  15. Modularization
    1. Module basics
      1. Exporting modules
      2. Importing modules
      3. Module renaming
      4. Default exports
      5. Exporting variables
      6. Import types
    2. AMD module loading
      1. AMD compilation
      2. AMD module setup
      3. Require configuration
      4. AMD browser configuration
      5. AMD module dependencies
      6. Bootstrapping Require
      7. Fixing Require config errors
        1. Incorrect dependencies
        2. 404 errors
    3. SystemJS module loading
      1. SystemJS installation
      2. SystemJS browser configuration
      3. SystemJS module dependencies
      4. Bootstrapping Jasmine
    4. Using Express with Node
      1. Express setup
      2. Using modules with Express
      3. Express routing
      4. Express templating
      5. Using Handlebars
      6. Express POST events
      7. HTTP Request redirection
    5. AWS Lambda functions
      1. Lambda function architecture
      2. AWS setup
      3. Serverless
      4. Serverless configuration
      5. Serverless deployment
      6. TypeScript Lambda functions
      7. Lambda node modules
      8. Lambda logging
      9. Node REST testing
    6. Summary
  16. Object-Oriented Programming
    1. Object-oriented principles
      1. Programming to an interface
      2. SOLID principles
        1. Single responsibility
        2. Open-closed
        3. Liskov substitution
        4. Interface segregation
        5. Dependency inversion
    2. User interface design
      1. Conceptual design
      2. Angular setup
      3. Using Bootstrap and Font-Awesome
      4. Creating a side panel
      5. Creating an overlay
      6. Coordinating transitions
    3. The State pattern
      1. State interface
      2. Concrete states
    4. The Mediator pattern
    5. Modular code
      1. Navbar component
      2. SideNav component
      3. RightScreen component
      4. Child components
      5. Mediator interface implementation
      6. The Mediator class
      7. Using the Mediator
      8. Reacting to DOM events
    6. Summary
  17. Dependency Injection
    1. Sending mail
      1. Using nodemailer
      2. Using a local SMTP server
      3. A service class
      4. Configuration settings
      5. Object dependency
      6. Service Location
      7. Service Location anti-pattern
      8. Dependency Injection
    2. Building a dependency injector
      1. Interface resolution
      2. Enum resolution
      3. Class resolution
      4. Constructor injection
    3. Decorator injection
      1. Using a class definition
      2. Parsing constructor parameters
      3. Finding parameter types
      4. Injecting properties
      5. Using dependency injection
      6. Recursive injection
    4. Summary
  18. Building Applications
    1. Node and Angular integration
      1. Angular Express server
      2. Express server configuration
      3. Server logging
    2. The UI experience
      1. Using Brackets
      2. Using Emmet
      3. Creating a login panel
    3. Authentication
      1. Angular routing
      2. Using UI-designed HTML
      3. Auth Guards
      4. Login form binding
      5. Using HttpClient
      6. Using Observables
      7. Using JWT tokens
      8. Verifying JWT tokens
      9. Using Observables in anger – of, pipe, and map
    4. External authentication
      1. Obtaining a Google API key
      2. Configuring social login
      3. Using Google user data
    5. Summary
  19. Let's Get Our Hands Dirty
    1. Board Sales application
    2. Database-driven APIs
      1. Database structure
      2. Express API endpoints
      3. Parameterized API endpoints
      4. Angular REST services
      5. The OpenAPI specification
    3. The BoardSales application
      1. The BoardList component
      2. Rendering REST data
      3. Observables – concatMap
      4. Observables – forkJoin
      5. Unit-testing Observables
    4. The Domain Events design pattern
      1. Raising and consuming Domain Events
      2. Observables – data filtering
    5. Summary
  20. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
18.116.51.117