mapbox / mapbox/mapbox-gl-draw

Error: Cannot use namespace 'Point' as a type.

Open
#1,393 0 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

types
Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
8d 9h
Merged PRs (30d)
5

Description

Mapbox GL Version: 3.6.0
Mapbox GL Draw Version: 1.5.0

After upgrading from Mapbox GL 3.4.0 to 3.6.0, I began getting an error that I've been unable to resolve:

```
Error: node_modules/@types/mapbox__vector-tile/index.d.ts:16:21 - error TS2709: Cannot use namespace 'Point' as a type.

16 loadGeometry(): Point[][];
~~~~~
```
It's failing internally in the `mapbox__vector-tile` library that Mapbox imports. This only fails though if Mapbox GL Draw is also included in the project. Otherwise, it works fine.

MCVE:

`package.json`
```json
{
"name": "map-mcve",
"main": "index.js",
"dependencies": {
"mapbox-gl": "3.6.0",
"@mapbox/mapbox-gl-draw": "^1.5.0"
},
"devDependencies": {
"typescript": "^5.8.3"
}
}
```

`tsconfig.json`
```json
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"strict": true,
}
}
```

And then import `mapbox-gl` into a `index.ts` and run `tsc`.

I was [advised to post an issue here](https://github.com/mapbox/mapbox-gl-js/issues/13203#issuecomment-2826697027), since this might be fixed by an eventual Typescript migration.

I also have a [SO question open](https://stackoverflow.com/questions/79560829/cannot-use-namespace-point-as-a-type-when-updating-mapbox-gl?noredirect=1) for more context.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the error with the package.json and tsconfig.json shown in the issue, importing mapbox-gl from index.ts and running tsc. Start by inspecting the mapbox__vector-tile declaration containing loadGeometry() and how Mapbox GL Draw affects its types. Done means the MCVE type-checks successfully with mapbox-gl 3.6.0 and Mapbox GL Draw 1.5.0.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.