2022-04-13のJS: TypeScript 4.7 Beta、RedwoodJS 1.0、Sanitizer API #975
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TypeScript 4.7 Betaがリリースされました。
TypeScript 4.5 Betaで導入されNightlyでテストされていた、Node.jsのECMAScript Moduleサポートを再び有効化されています。
これに関連して
package.json
のexports
フィールドのサポート、"module": "nodenext"
、.mts
/cts
の拡張子のサポートが追加されています。また、Node.jsではファイルがモジュールかどうかは
package.json
のmodule
フィールドなどによって暗黙的に異なります。そのため、ファイルがモジュールかどうかを判定方法を制御できる
moduleDetection
オプションも追加して、強制的(force
)にモジュールとして認識させることもできるようになっています。型推論の改善として、Compuatedプロパティに対するコントロールフロー解析の改善、オブジェクトにおける関数の型推論の改善が含まれています。
Genericsの型を指定したaliasを定義できる Instantiation Expressionsをサポート。
infer
に対するextends
での推論条件の追加をサポート、型が共変(in
)/反変(out
)/不変(in out
)なのかを指定できるアノテーションを追加されています。モジュール解決持の探索方法をカスタマイズする
moduleSuffixes
オプションの追加、import type
とReference Commentでresolution-mode
を指定できるようになっています。Making of: The Sanitizer API (Nullcon 2022) - Google スライドというスライドでは、HTML Sanitizer APIという策定中/実装中のウェブ標準について紹介されています。
信頼できないHTML文字列のインジェクトするときに、そのHTML文字列をサニタイズしてXSSを防止するためのAPIです。
最初は、HTML文字列をサニタイズしてHTML文字列を返すAPIとして進められていました、HTMLのパースモードの違いなどからパイパスする方法があることが発見されました。(HTML文字列という文字列のフラグメントに対するサニタイズは安全にはできないと分かった)
そのため、
innerHTML
とよく似たsetHTML
という新しいAPIが策定され、このAPIにsanitizerを渡す形に変更された話が書かれています。