Skip to content

Latest commit

 

History

History
43 lines (39 loc) · 3.42 KB

typescript.md

File metadata and controls

43 lines (39 loc) · 3.42 KB

Typescript

Books

  1. Effective TypeScript

Questions

  • What are Type soundness and Type safety? Is there a difference between these concepts?
  • What is structural typing? What are the alternatives? What are the advantages and disadvantages of this approach?
  • In what cases does TS move away from the principles of structural typing and move on to nominative typing to determine the compatibility of types?
  • What are declarations merging? How does it work in TS? What are the pros and cons? How are types combined for methods?
  • Compatibility
    • Why TS considers compatible function type with fewer arguments `typescript ((a: number) => 0; assignable to (b: number, s: string) => 0;) ``
    • And how does this apply to the return result of functions?
    • Does TS Type soundness break because of this?
  • What is Type Variance? What do Invariance, Covariance, Contravariance and Bivariance mean?
    • When does Covariance appear in TS? When is the Bivariance? When is the Contravariance?
    • If you pass a callback to the function that accepts another callback, will the parameters show Covariance or Contravariance (output by example yourself)?
    • If TS objects and classes were Invariant, how would this affect type safety and ease of development?
  • What is Type Widening? How does this mechanism affect type safety in TS?
  • fresh object literal type
    • What it is?
    • Why is excess property checking turned on for him in a special way?
    • Why does passing an object literal not directly to a function, but through intermediate variable assignment, increase the likelihood of an error in the program?
  • What is a refinement? How does it work in the context of Discriminated Unions?
  • Why can using generic variables in tags for Discriminated Unions make a program more bug-prone? When does it really lead to bugs, and when not?
  • What is a Companion Object Pattern? How is Declaration Merging used to implement it?
  • What is type inference? What are some common type inference problems? What types can TS output?
  • What types of polymorphism does TS support and how to work with it?

Links