facebook / facebook/flow

delete check has misleading error message

Open
#8,116 0 comments 0 reactions 0 assignees View on GitHub
bug needs triage
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Flow version: 0.109.0

## Expected behavior
Error message should tell that `c` is a required property

## Actual behavior

Error message claims that `c` is missing from an object type

Following code:

```
type O1 = {a: number};
type O2 = O1 & {c:number};
declare var o: O2;
delete o.c;
```

Gives following error:

```
4: delete o.c;
^ Cannot delete `o.c` because property `c` is missing in `O1` [1].
References:
2: type O2 = O1 & {c:number};
^ [1]
```

If you change property `c` to optional:
`type O2 = O1 & {c:number};`

The error disappears. It's good that there is error, but the message is quite wrong. It should assist to make `c` optional, but instead it tells that O1 does not have the property at all.

* Link to Try-Flow or Github repo:

https://flow.org/try/#0C4TwDgpgBA8gjFAvFA3gQwFxQHYFcC2ARhAE4C+A3AFCiSwBMSsCAZKgMYZ5GmVUAmEdgBs0JaADcxUAPZYY9aoOERg0GQDp2FIA

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.