当前位置:网站首页>Introduction tutorial of typescript (dark horse programmer of station B)

Introduction tutorial of typescript (dark horse programmer of station B)

2022-07-06 10:18:00 Giant Zhang

Video link :https://www.bilibili.com/video/BV14Z4y1u7pi?p=1

1. TypeScript Introduce

1.1 TypeScript What is it?

 Insert picture description here

1.2 TypeScript Why for JS Add type support ?

 Insert picture description here

1.3 TypeScript comparison JS The advantages of

 Insert picture description here

2. TypeScript First experience

2.1 Installation and compilation TS The toolkit

 Insert picture description here

2.2 Compile and run TS Code

 Insert picture description here

2.3 Simplify operation TS Steps for

 Insert picture description here

  • Be careful : if ts-node hello.ts Error report in execution , You need to execute the command first tsc --init Create a tsconfig.json file , The document is TypeScript The configuration file for the project
  • tsconfig.json contain TypeScript Compile the relevant configuration , Compile configuration items by changing , We can get TypeScript Compiled ES6、ES5、node Code for .

3. TypeScript Common types

 Insert picture description here

3.1 Type notes

 Insert picture description here

3.2 Overview of common foundation types

 Insert picture description here

3.3 The original type

 Insert picture description here

3.4 An array type

 Insert picture description here

3.5 Type the alias

 Insert picture description here

3.6 Function type

 Insert picture description here
 Insert picture description here

  • If the function does not return a value , that , Function return value type is :void.

 Insert picture description here
 Insert picture description here

3.7 object type

 Insert picture description here
 Insert picture description here

3.8 Interface

 Insert picture description here
 Insert picture description here
 Insert picture description here

3.9 Tuples

 Insert picture description here

3.10 type inference

 Insert picture description here

3.11 Types of assertions

 Insert picture description here
 Insert picture description here

3.12 Literal type

 Insert picture description here
 Insert picture description here

3.13 enumeration

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

3.14 any type

 Insert picture description here

3.15 typeof

 Insert picture description here

4. TypeScript Advanced type

 Insert picture description here

4.1 class class

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

  • Two ways of class inheritance :1 extends( Inherited parent class ) 2 implements( Implementation interface ).

 Insert picture description here
 Insert picture description here

  • Class member visibility : have access to TS To control class Method or property of for class Whether the code outside is visible .
  • public
     Insert picture description here
  • protected
     Insert picture description here
  • private
     Insert picture description here
  • readonly
     Insert picture description here

4.2 Type compatibility

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

4.3 Cross type

 Insert picture description here  Insert picture description here

4.4 Generic

 Insert picture description here
 Insert picture description here  Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

  • Partial<Type>
     Insert picture description here
  • Readonly<Type> Insert picture description here
  • Pick<Type, Keys>
     Insert picture description here
  • Record<Keys, Type>

 Insert picture description here

4.5 Index signature type

 Insert picture description here

4.6 Mapping type

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

5. TypeScript Type declaration file

 Insert picture description here

5.1 TS Two file types in

 Insert picture description here

5.2 Instructions for using the type declaration file

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

6. stay React Use in TypeScript

 Insert picture description here

6.1 Use CRA Create support TS Project

 Insert picture description here
 Insert picture description here
 Insert picture description here

6.2 TS The configuration file tsconfig.json

 Insert picture description here
 Insert picture description here

6.3 React Common types in

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

原网站

版权声明
本文为[Giant Zhang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060910499854.html