Correctness Fixes and Breaking Changes
TL;DR
破壊的変更を含む改善が施された。
lib.d.ts
Updates
lib.d.ts
UpdatesエラーのcauseはErrorオブジェクトでなくunknownになった。
Unconstrained Generics No Longer Assignable to{}
{}
以下の機能が破壊的変更を含む。 暗黙のうちに許容していたnull,undefinedに対してエラーが発生する。
Decorators are placed on modifiers on TypeScript’s Syntax Trees
ECMAScriptのデコレータの策定により、先行して実装していたTSとの齟齬が生じた。 ECMAScriptのデコレータにアクセスするための関数が公開された。
function canHaveModifiers(node: Node): node is HasModifiers;
function getModifiers(node: HasModifiers): readonly Modifier[] | undefined;
Types Cannot Be Imported/Exported in JavaScript Files
JSファイルで型をエクスポートした場合に、ランタイムのESMでエラーが発生するようになった?(以前からなのか不明)。
JSで型をインポート・エクスポートするにはJSDocの @typedef
で補完する。
Binding Patterns Do Not Directly Contribute to Inference Candidates
以下の機能が破壊的変更を含む。 推論結果が変わる影響によりエラーが発生する。
Unused Renames in Binding Patterns are Now Errors in Type Signatures
関数の引数において名前なしのバインディングバターンが許容されなくなった。 以下のような構文はエラーが発生する。
// ❌ ERROR
declare function fn({ a: string, b: number }): void;
// 正しくはこのようになる
declare function fn({ a,b }:{ a: string, b: number }): void;
// もしくはオブジェクト自体に名前を付ける
declare function fn(args: { a: string, b: number }): void;
Last updated