技術とかの雑なToday I Learnedメモ

assert functions 続き

assert functions 続き

昨日書いた assert functions について、リプライで教えてもらったのでメモ。教えてくれた方ありがとうございます。

この直し方→Assertions require every name in the call target to be declared with an explicit type annotation. - Qiita

↑この記事に自分が躓いていたことがそのまんま書いてあったので助かりました。

どうしてこのようなエラーが発生するのかは分かりませんが、下記のissueによれば、この仕様は意図的なものだそうです。

Error when assertion function calls aren't CFA'd by ahejlsberg · Pull Request #33622 · microsoft/TypeScript

Generic type uplifting during assignment (ts 2775) · Issue #41047 · microsoft/TypeScript

ふむふむ。