TypeScript part4 (378レス)
TypeScript part4 http://mevius.5ch.net/test/read.cgi/tech/1640872622/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
レス栞
あぼーん
165: デフォルトの名無しさん [] 2022/06/29(水) 20:00:27.28 ID:NKfPTkof 質問です。 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...は、そんな文法は無く、仮想の方法です。) また、型定義と型指定部分だけ書き換え不可としたら、普通は、 <string><unknown>false; // @ts-ignore どちらで乗り切るのでしょうか? http://mevius.5ch.net/test/read.cgi/tech/1640872622/165
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
1.073s*