Weird error message in misuse of addLayer()
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Obviously not serious, but can be pretty confusing if you accidentally call `addLayer()` with the argument structure you expect from `addSource()`.
**mapbox-gl-js version**: 1.12.0
### Steps to Trigger Behavior
1. call `map.addLayer('mylayerid', { ... })`
### Expected Behavior
An error message like "addLayer() expects an object, not a string."
### Actual Behavior
`Uncaught TypeError: cannot use 'in' operator to search for "ref" in "mylayerid"`
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
Start at the map.addLayer() entry point and reproduce the call with a string first argument to locate where the current TypeError originates. Done means the misuse produces a clear error explaining that addLayer() expects an object rather than a string.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100