Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”

At the same time, I participated in the Digitalstar project to win the creative gift package and challenge the creative incentive money

preface

Preliminary review

Getting started with TypeScript development environment and preparation

The basics of TypeScript

Type operation — keyof

  • The keyof (citation type query operator) was introduced in TS2.1.

  • It gets the type union for all known, public keys on the type

Simple type keyof

interface

1. Interface and Type aliases can be regarded as two grammars of the same concept2, The difference between Interface and Type aliases:

  • The type alias is more generic and can be included on the right sideType expression(type union, type crossing, conditional type), but the right side of the interface can only be some kind of structure ({… })
  • When extending between interfaces (extends), TS checks the relationship. However, TS will try its best to avoid errors in type union
  • Multiple interface declarations of the same name in the same scope can be declared bymerge, and multiple type aliases with the same name will report an error

Class (class)

Class is ES2015 guide | into the new features, only tell you how to use interface to describe a class:

conclusion

If there is any mistake above, please point out in the comment section, thank you!

After reading it, give it a thumbs-up and then walk away