-
Notifications
You must be signed in to change notification settings - Fork 1.9k
How to tell flow that a dynamic string is just like a normal string #9253
Copy link
Copy link
Open
Labels
Typing: completenessNo false positives (type checker claims that there are some errors in the correct program)No false positives (type checker claims that there are some errors in the correct program)bug
Description
type Props = $ReadOnly<{
actionId: string,
onPress: (args:{dispatch: () => void}) => void
}> | $ReadOnly<{
actionId?:void,
onPress: () => void
}>
const A: (p:Props) => void = () => {}
const actionId: string = `1`
A({
actionId,
onPress:({dispatch}) => {dispatch()}
// ^ property `dispatch` is missing in undefined [1]. [incompatible-use]
})
A({
actionId: ''.concat(''),
onPress:({dispatch}) => {dispatch()}
// ^ property `dispatch` is missing in undefined [1]. [incompatible-use]
})
A({
actionId: '1',
onPress:({dispatch}) => {dispatch()}
// no error like it should be
})
Flow version: 0.259.1
Expected behavior
No error.
Actual behavior
Flow treats "dynamic" strings in a different way.
- Link to Try-Flow or Github repo:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Typing: completenessNo false positives (type checker claims that there are some errors in the correct program)No false positives (type checker claims that there are some errors in the correct program)bug