[英]Are Flow.js maps not writable?
/* @flow */
let m: Map<number, string>;
m = new Map();
m[1] = 'qwe';
給出這個錯誤:
7: m[1] = 'qwe';
^ Cannot assign `'qwe'` to `m[1]` because an index signature declaring the expected key / value type is not writable.
7: m[1] = 'qwe';
^ Cannot assign `'qwe'` to `m[1]` because number [1] is incompatible with `$SymbolToStringTag` [2].
References:
7: m[1] = 'qwe';
^ [1]
[LIB] ..//static/v0.111.0/flowlib/core.js:606: +[key: $SymbolToStringTag]: any;
^ [2]
你可以在這里試試
啊該死的,那是因為在帶有地圖的 JS 中,你不允許m[key] = value;
只有m.set(key, value)
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.