- 787 名前:デフォルトの名無しさん mailto:sage [2018/02/18(日) 22:15:41.08 ID:+Qsqi9wm.net]
- >>763
せめて関数のオーバーロード定義みたいなことが出来ればコードが整理しやすくなると思うんだよね。 つまり export function h(name, attributes /*, ...rest*/) { // 省略 return typeof name === "function" ? name(attributes || {}, children) : { nodeName: name, attributes: attributes || {}, children: children, key: attributes && attributes.key } } ってあった時に export function h(name: string, attributes:obj /*, ...rest*/) {} export function h(nextFunc: (attributes:obj)=>void, attributes:obj /*, ...rest*/) {} みたく出来れば型定義自体も綺麗にできる気がする。 でも今のTypeScriptってこれできんよね。
|

|