タグ

ブックマーク / medium.com/@cefn (1)

  • Typescript’s new ‘satisfies’ operator

    The satisfies operator has arrived in Typescript 4.9. This article explains the purpose of the new keyword, illustrated by detailed, runnable code examples. satisfies : The basicsPutting satisfies T after an expression asks the compiler to check your work. You will get helpful compiler errors if the expression doesn’t fulfil the requirements of type T. However, its not the same as assigning to a t

    Typescript’s new ‘satisfies’ operator
    efcl
    efcl 2022/09/24
    TypeScript 4.9で導入される`satisfies`演算子について。 `const a: <T>`や`a as <T>`では、その型にキャストしてしまう。`a satisfies <T>`はキャストはせずに型のチェックだけを行う安全な演算子
  • 1