-
Book Overview & Buying
-
Table Of Contents
Learn React with TypeScript - Third Edition
By :
TypeScript complements JavaScript with a rich type system, and in this chapter, we experienced catching errors early using TypeScript’s type checking.
We also learned that JavaScript types, such as number and string, can be used in TypeScript, as well as types that only exist in TypeScript, such as Date and unknown.
New types can be created using type aliases. We learned that type aliases could be based on objects, functions, or even mixed types using a union type. We used a type alias to strongly type the props on an alert React component.
We now know that the ? symbol in a type annotation makes an object property or function parameter optional. Also, an existing type can be extended using the & symbol.
We learned that the TypeScript compiler can be invoked via a CLI, allowing it to be integrated into a continuous integration pipeline. The compiler can carry out transpilation to JavaScript, as well as type checking, and can be configured with a tsconfig...