TypeScript 5.8リリース — Node.jsで扱える文法のみに制限する--erasableSyntaxOnlyオプション、CommonJSからのESM読み込みサポートなど改善点多数
DRANK

3月1日、TypeScript 5.8がリリースされた」。この記事では、TypeScript 5.8の主な新機能や変更点について簡潔に紹介する。新機能・変更点の概要return文内の条件式に対する型チェックの強化以下のようにreturn文の中で条件演算子を使う場合、TypeScript 5.8では各分岐が関数の戻り値型と整合しているかをより厳密にチェックするようになった。declare const untypedCache: Map<any, any>;function getUrlObject(urlString: string): URL { return untypedCache.has(urlString) ? untypedCache.get(urlString) : urlString; // ~~~~~~~~~ // error! Type 'string' is not assignable to type 'URL'.}

by @tf_official
Related Topics: TypeScript
1 comments