Skip to content

Instantly share code, notes, and snippets.

@stomita
Last active February 16, 2017 10:15
Show Gist options
  • Save stomita/64828d2dadc165826f84a4234f94bcf4 to your computer and use it in GitHub Desktop.
Save stomita/64828d2dadc165826f84a4234f94bcf4 to your computer and use it in GitHub Desktop.
Flowtypeの不可解な挙動
/* @flow */
type NMap = { [key:string]: number }
// これは当然だめ
const map1: NMap = {
a: 1,
b: 2,
c: 'a',
};
// これもだめ
const map2: NMap = {
a: 1,
b: 2,
['c']: 'a',
};
// これもだめ
const c1 = 'c';
const map3: NMap = {
a: 1,
b: 2,
[c1]: 'a',
};
// でもこれは通ってしまう!
const map4: NMap = {
a: 1,
b: 2,
['c'+'d']: 'a',
};
// これも通ってしまう!
const c2 = 'c'+'d';
const map5: NMap = {
a: 1,
b: 2,
[c2]: 'a',
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment