Flow complains on the filter definition inside of a layer
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Flow complains on:
```
filter: [
'any',
['==', ['get', 'direction'], 'ba'],
['==', ['get', 'direction'], 'ab'],
],
```
with the error message:
```
Cannot return array literal because:
• Could not decide which case to select. Since case 3 [1] may work but if it doesn't case 9 [2] looks promising too.
To fix add a type annotation to array literal [3].
• Could not decide which case to select. Since case 3 [1] may work but if it doesn't case 9 [2] looks promising too.
To fix add a type annotation to array literal [4].
src/selectors/get-map-style.js
[3] 262│ ['==', ['get', 'direction'], 'ba'],
[4] 263│ ['==', ['get', 'direction'], 'ab'],
:
289│ ];
290│ }
291│
292│ return [sources, layers];
293│ }
294│
../../node_modules/@mapbox/mapbox-gl-style-spec/types.js
[1] 12│ | ['==', string, string | number | boolean]
:
[2] 18│ | Array; // Can't type in, !in, all, any, none -- https://github.com/facebook/flow/issues/2443
Found 2 errors
```
Looks like the [`==` filter definition](https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/types.js#L12) is missing the array type
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect ../../node_modules/@mapbox/mapbox-gl-style-spec/types.js around lines 12 and 18, then review the failing filter literals in src/selectors/get-map-style.js. Run Flow to reproduce the two errors and verify the filter definition accepts the reported array form without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100