【发布时间】:2019-05-18 23:13:55
【问题描述】:
在这段代码中
document.addEventListener('keydown', (e: SyntheticKeyboardEvent<Document>) => {
if (e.ctrlKey && e.shiftKey && e.code === 'KeyE' && !this.state.envChangePopupOpened) {
this.openPopup();
}
});
Flow 给出了 2 个似乎并非如此的问题。
首先它给出了这个神秘的信息:
Cannot call `document.addEventListener` because: Either string [1] is incompatible with enum [2]. Or string [1] is incompatible with enum [3]. Or `KeyboardEvent` [4] is incompatible with `SyntheticKeyboardEvent` [5] in the first argument. Or string [1] is incompatible with enum [6]. Or string [1] is incompatible with string literal `wheel` [7]. Or string [1] is incompatible with enum [8]. Or string [1] is incompatible with enum [9]. Or string [1] is incompatible with enum [10]. Or string [1] is incompatible with enum [11]. Or string [1] is incompatible with enum [12]. Or `Event` [13] is incompatible with `SyntheticKeyboardEvent` [5] in the first argument. (References: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13])
第二个给出:
property `code` is missing in `SyntheticKeyboardEvent` [1]. (References: [1])
但它应该在 e 上。
你如何处理这些?
编辑:
SyntheticEvent 不支持第二个问题,应该解决。
【问题讨论】:
-
根据this 问题,我认为尚不支持代码。
标签: javascript flowtype