type t = (a: string) => string; const f: t = (a) => false; console.log(f('x'));
で false のところで、 Type 'boolean' is not assignable to type 'string'.ts(2322) になりますが、 ・type t = ... を書き換えてはいけない ・const f の実装を const f: t = (a) => <string><unknown>false; のように書き換えてはいけない ・// @ts-ignore を使ってはいけない。 という縛りで、例えばですが、 type t = (a: string) => string; overwrite type t = (a: string) => string | boolean; const f: t = (a) => false; console.log(f('x')); のように同名の型のまま戻り値の定義を書き換えるということはできるのでしょうか? (overwrite type...は、そんな文法は無く、仮想の方法です。)