Paste the following into try flow:
// @flow
const stringLiteral: 'STRING' = 'STRING'
const test = (type: 'STRING' | 'NUM') => {
if (type === stringLiteral) {
(type: 'STRING') // does error, but should not.
}
if (type === 'STRING') {
(type: 'STRING') // A-OK
}
};
The above code errors, but it should not. The type of stringLiteral is the string literal 'STRING' (not string) and it cannot be changed, so comparisons should work the same as comparing to a string literal. However, it does not.