2
戻り値をdocument.getElementById
からHTMLInputElement
に変換するには、どのようにしてフローを取得できますか?もっと一般的なものではありません。HTMLElement
?フロータイプ:親クラスを返す関数から拡張クラスを使用
例:https://github.com/facebook/flow/blob/master/lib/dom.js
declare class Document extends Node {
…
getElementById(elementId: string): HTMLElement;
…
}
から
let input = document.getElementById('myinput');
console.log(input.value);
script.js:28
28: console.log(input.value);
^^^^^ property `value`. Property not found in
28: console.log(input.value);
^^^^^ HTMLElement
しかし、getElementById
(この場合HTMLInputElement
に)
declare class HTMLInputElement extends HTMLElement {
…
value: string;
…
}
のサブクラスを返すことができる私ができるようにしたいと思い入力エレメのvalue
プロパティにアクセスする流れがなくてもエラーは発生しません。
あなたの質問を詳しく説明できますか? –