-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"property not found in object literal" using dot notation and computed properties #1853
Comments
From docs:
|
@vkurchatkin thank you, that makes sense. I think it'd be useful if the error message included something about the object literal being a sealed object. |
@vkurchatkin I ran into the same error for a slightly different use case, using computed properties:
Is this expected behavior? Is Flow correctly interpreting the object literal with computed properties? |
OMFG. I struggled with this for a day. Turns out that changing this: export function makeResponse (
event: EvType,
data?: JSONType,
err?: (string | {message: string})
) : Response {
var response = {event}
if (event === EVENT_TYPE.ERROR) {
if (err) {
response.data = data
response.err = err
} else {
response.err = data
}
} else {
response.data = data
}
return response
} To this: export function makeResponse (
event: EvType,
data?: JSONType,
err?: (string | {message: string})
) : Response {
var response: Response = {event} // <-- !!!! bs!!
if (event === EVENT_TYPE.ERROR) {
if (err) {
response.data = data
response.err = err
} else {
response.err = data
}
} else {
response.data = data
}
return response
} Made the nonsensical error go away. Of course it's a response type! It's what's being returned and that's clearly annotated in the function definition. Surprised Flow couldn't figure that out on its own and needed me to tell it. |
@vkurchatkin So what am I supposed to do in the following case: const route = {
path,
name,
getComponent () {
// ...
}
}
if (sagas) {
route.onEnter = function () {
// ...
}
route.onLeave = function () {
// ...
}
} |
Answering my own question. It could be: const route: Object = { // ... } More options in #1606 |
I'm getting
property not found in object literal
with the following code:However, if I change the code slightly, the error goes a way:
What am I doing wrong in the first example? What is it that Flow is flagging as a problem?
The text was updated successfully, but these errors were encountered: