Frontend Weekly 2023-11-24
TypeScript 5.3
2023 年 11 月 20 日に TypeScript 5.3 がリリースされました。
https://devblogs.microsoft.com/typescript/announcing-typescript-5-3/
新たな構文のサポートに加えて、JSDoc 解析をスキップすることによる最適化やパッケージの重複を避けることによるパッケージサイズの削減なども行われました。
Import Attributes
Stage 3 の Import Attributes がサポートされました。
https://github.com/tc39/proposal-import-attributes
これによりモジュールの形式をランタイムに提供できるようになります。
import obj from "./something.json" with { type: "json" };
import * as foo from "./foo.js" with { type: "fluffy bunny" };
const obj = await import("./something.json", { with: { type: "json" },});
switch(true) Narrowing
switch (true)
内の各case
句に基づいて型の絞り込みをできるようになりました。
function f(x: unknown) { switch (true) { case typeof x === "string": // 'x' is a 'string' here console.log(x.toUpperCase()); // falls through...
case Array.isArray(x): // 'x' is a 'string | any[]' here. console.log(x.length); // falls through...
default: // 'x' is 'unknown' here. // ... }}
Narrowing On Comparisons to Booleans
true
または false
と直接比較した場合でも、絞り込みが出来るようになりました。
interface A { a: string;}
interface B { b: string;}
type MyType = A | B;
function isA(x: MyType): x is A { return "a" in x;}
// <=5.2function someFn(x: MyType) { if (isA(x)) { console.log(x.a); // works! }}// <=5.2function someFn(x: MyType) { if (isA(x) === true) { console.log(x.a); // not works }}// 5.3function someFn(x: MyType) { if (isA(x) === true) { console.log(x.a); // works! }}
Git 2.43
2023 年 11 月 20 日に Git 2.43 がリリースされました。
https://github.blog/2023-11-20-highlights-from-git-2-43/
リバートコミットをリバートした際のコミットメッセージの Revert Revert から Reapply になりました。
$ git revert --no-edit HEAD >/dev/null$ git revert --no-edit HEAD >/dev/null$ git log --oneline a300922 (HEAD -> main) Revert: "Revert: "fix bug"" a300922 (HEAD -> main) Reapply "fix bug" 0050730 Revert "fix bug" b290810 fix bug
巨大なリポジトリを扱う際に、Blob を必要に応じて取得する Blobless clone を実行したい場合があります。
これを通常のローカルリポジトリに後から適用できるようになりました。
% git repack -ad --filter=blob:none --filter-to=pack --no-write-bitmap-index% git config remote.origin.promisor true% git config remote.origin.partialclonefilter blob:none
他にも 1MiB 未満の Blob のみフィルタリングして取得するといったことも出来ます。
git repack -ad --filter='blob:limit=1m' --filter-to=pack
Firefox 120.0
2023 年 11 月 21 日に Firefox 120.0 がリリースされました。
https://www.mozilla.org/en-US/firefox/120.0/releasenotes/
トラッキングコードを削除したリンクをコピーする機能が追加されました。また WebAssembly GC が有効になりました。