JS & TS/TypeScript

[TypeScript] Object

Bay Im 2024. 2. 13. 16:43
  • 객체(Object) 정의하는 타입
    • 객체의 형태를 정의하고 객체의 할당 가능성 확인
    • TS의 타입 시스템은 타입을 구조화하여 정의 (structured type system)
  • CoVariance & ContraVariance
    • Covariance
      • 원래 지정된 것보다 더 많이 파생된 형식을 사용할 수 있다.
      • IEnumerable<Derived>의 인스턴스를 IEnumerable<Base> 형식의 변수에 할당할 수 있다.
    • Contravariance
      • 원래 지정된 것보다 더 제네릭한(덜 파생적인) 형식을 사용할 수 있다.
      • Action<Base>의 인스턴스를 Action<Derived> 형식의 변수에 할당할 수 있다.
728x90

'JS & TS > TypeScript' 카테고리의 다른 글

[TypeScript] Array, Tuple  (0) 2024.02.13
[TypeScript] Function  (0) 2024.02.13
[TypeScript] Union, Literal  (0) 2024.02.13
[TypeScript] Type System  (0) 2024.02.13
[TypeScript] TypeScript란?  (0) 2024.02.13