MapboxGeocoder mapboxgl option should refer to mapbox-gl instance
MapboxGeocoder expected the mapboxgl option to be a Map instance, but MapboxGeocoder expects the entire mapboxgl instance. I've attempted a fix for this by using typeof mapboxgl.
Please fill in this template.
- [x] Use a meaningful title for the pull request. Include the name of the package modified.
- [x] Test the change in your own code. (Compile and run.)
- [x] Add or edit tests to reflect the change.
- [x] Follow the advice from the readme.
- [x] Avoid common mistakes.
- [x] Run
npm test <package to test>.
Select one of these and delete the others:
If changing an existing definition:
- [x] Provide a URL to documentation or source code which provides context for the suggested changes: https://github.com/mapbox/mapbox-gl-geocoder/blob/main/API.md?plain=1#L92
- [x] If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
@jamiemorganward Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.
This is a live comment which I will keep updated.
1 package in this PR
Code Reviews
This PR can be merged once it's reviewed.
You can test the changes of this PR in the Playground.
Status
- ✅ No merge conflicts
- ✅ Continuous integration tests have passed
- ✅ Most recent commit is approved by type definition owners or DT maintainers
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.
Diagnostic Information: What the bot saw about this PR
{
"type": "info",
"now": "-",
"pr_number": 61086,
"author": "jamiemorganward",
"headCommitOid": "d4741aa0db8a45513e02b262efae4141e134c8b3",
"mergeBaseOid": "ef830fd355cfc08d920997794fef88a886c78207",
"lastPushDate": "2022-07-04T23:48:45.000Z",
"lastActivityDate": "2022-08-15T20:54:40.000Z",
"maintainerBlessed": "Waiting for Code Reviews",
"mergeOfferDate": "2022-08-15T18:03:23.000Z",
"mergeRequestDate": "2022-08-15T20:54:40.000Z",
"mergeRequestUser": "jamiemorganward",
"hasMergeConflict": false,
"isFirstContribution": true,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Well-liked by everyone",
"pkgInfo": [
{
"name": "mapbox__mapbox-gl-geocoder",
"kind": "edit",
"files": [
{
"path": "types/mapbox__mapbox-gl-geocoder/index.d.ts",
"kind": "definition"
}
],
"owners": [
"Nosfit",
"dmytro-gokun"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Well-liked by everyone"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "jakebailey",
"date": "2022-08-15T18:02:40.000Z",
"isMaintainer": true
}
],
"mainBotCommentID": 1174465293,
"ciResult": "pass"
}
🔔 @Nosfit @dmytro-gokun — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.
It has been more than two weeks and this PR still has no reviews.
I'll bump it to the DT maintainer queue. Thank you for your patience, @jamiemorganward.
(Ping @Nosfit, @dmytro-gokun.)
Ready to merge
Don't know who or what is at fault, but this check-in apparently broke my build. Previously working code was:
import mapboxgl, {GeoJSONSource} from "mapbox-gl";
import MapboxGeocoder from "@mapbox/mapbox-gl-geocoder";
...
document.getElementById("geocoder2")?.appendChild(this.ctrlGeocoder.onAdd(DZ.map));
where DZ.map is defined as:
export type DZ = {
map: mapboxgl.Map;
...
}
The error is: TS2345: Argument of type 'mapboxgl.Map' is not assignable to parameter of type 'import("c:/GitHub/dzweb/ClientApp/node_modules/@types/mapbox__mapbox-gl-geocoder/node_modules/@types/mapbox-gl/index").Map'.
Those node_module folders look nested. Perhaps you have multiple versions of this types package in your dependency tree?
Or, do you need to install @types/mapbox-gl into your package, since you seem to be explicitly referencing it in your project? I'd definitely check those versions to see where the mismatch is.
Verified the problem is not due to multiple version of types package in dependency tree, and @types/mapbox-gl was already referenced. Reverting back to the previous version of the package made the error disappear:
yarn add @types/[email protected] -D
Also tried deleting node_modules and then yarn without beneficial effect.
Is there any chance you could post your yarn.lock file, specifically all of the entries that start with @types/mapbox?
That was it! I deleted yarn.lock and it fixed itself. Looks like there was a leftover earlier version of @types/mapbox-gl (This is the lockfile using 4.7.2, I upgraded to 4.7.3 and it's still working fine).
"@types/mapbox-gl@*":
version "2.7.3"
resolved "https://registry.yarnpkg.com/@types/mapbox-gl/-/mapbox-gl-2.7.3.tgz#d75049251f1cb5f5a5453d6c20ffb9d2de6cbd75"
integrity sha512-XdveeJptNNZw7ZoeiAJ2/dupNtWaV6qpBG/SOFEpQNQAc+oiO6qUznX85n+W1XbLeD8SVRVfVORKuR+I4CHDZw==
dependencies:
"@types/geojson" "*"
"@types/mapbox-gl@^2.7.5":
version "2.7.5"
resolved "https://registry.yarnpkg.com/@types/mapbox-gl/-/mapbox-gl-2.7.5.tgz#9e31fc592adb2762e4e5c7727dca5ec367dfc780"
integrity sha512-T8gACm3oGKMlBo2l/9vnKEAxgCc0g2mr8g6dI1d3ZO6EzRe7JALBONlWRmc7SOHV79kiarkcdLdDVEnfd+jilA==
dependencies:
"@types/geojson" "*"
"@types/mapbox__mapbox-gl-draw@^1.2.5":
version "1.2.5"
resolved "https://registry.yarnpkg.com/@types/mapbox__mapbox-gl-draw/-/mapbox__mapbox-gl-draw-1.2.5.tgz#bb37284030033f46b493150154ddb1ab553cc651"
integrity sha512-swDFPOPYkDSLWWXznurjradEAX05E0l8QZwdciQkTBjjg5dQmOjNfCIN54HNIDpKoSypSY+8T5SyFAOOm5LSTQ==
dependencies:
"@types/geojson" "*"
"@types/mapbox-gl" "*"
"@types/[email protected]":
version "4.7.2"
resolved "https://registry.yarnpkg.com/@types/mapbox__mapbox-gl-geocoder/-/mapbox__mapbox-gl-geocoder-4.7.2.tgz#201fea053016f995a98569388bcf0facd442aefa"
integrity sha512-/Bz3Ko7+3yGQFH9Byv9xQB2TRfc08r7Hpu2g70c9qEUnEa31SKAwiAo6XCQEnPJZAeozXmSN84cMKZWP9FMVZA==
dependencies:
"@types/geojson" "*"
"@types/mapbox-gl" "*"
Thank you and sorry for the distraction!
All good!