≪ Today I learned.
RSS購読
    公開日
    タグ
    TypeScript
    著者
    ダーシノ

    TypeScript 5.7 RCの主なアップデート

    TypeScript 5.7 RCがリリースされた。

    などなど。

    初期化されていない変数のチェック

    Before: TS5.6

    function foo() {
      let result: number
    
      function printResult() {
        // resultは初期化されていないがエラーにならない
        console.log(result)
      }
    }

    After: TS5.7

    function foo() {
      let result: number
    
      function printResult() {
        console.log(result)
        //          ^^^^^^ Variable 'result' is used before being assigned.
      }
    }

    まったく初期化されていない場合にはエラーになる。

    ES2024をサポート

    以下のようなES2024で追加された新しい機能をサポートした。

    Node.js v22の新しいAPIを用いたコンパイルキャッシュ

    Node.js v22はAPIModule.enableCompileCache()をサポートした。この機能はコンパイル作業の一部をキャッシュして再利用できるようにするもので、TypeScript 5.7ではこれを利用することでコンパイル時間を短縮できる。