Last active
February 16, 2017 10:15
-
-
Save stomita/64828d2dadc165826f84a4234f94bcf4 to your computer and use it in GitHub Desktop.
Flowtypeの不可解な挙動
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @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