Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supercluster types should be dependency + error in their import #791

Closed
henrinormak opened this issue Oct 22, 2019 · 5 comments
Closed

Supercluster types should be dependency + error in their import #791

henrinormak opened this issue Oct 22, 2019 · 5 comments

Comments

@henrinormak
Copy link
Contributor

Due to the way Supercluster types are used here, they should be listed as dependency/peerDependency, not just devDep. The reason is the exported State interface, which refers to the Supercluster type.

Furthermore, even after installing the supercluster types to a project, typescript still fails with the following error:

node_modules/react-mapbox-gl/lib/cluster.d.ts:23:13 - error TS2749: ‘Supercluster’ refers to a value, but is being used as a type here.

23     superC: Supercluster;
              ~~~~~~~~~~~~

If I were to alter the code in cluster.d.ts:4 to be import * as Supercluster from 'supercluster'; then this error goes away. So probably this is caused by changes made in #731.

#735 referred to a build error that might be somewhat related to this.

@alex3165
Copy link
Owner

Hey @henrinormak I am not too sure why the examples didn't pick this up, I will have a look if I have some time, meanwhile feel free to open a pull request if you have some time with a proper fix

@henrinormak
Copy link
Contributor Author

@alex3165 I'll see if I can whip up a PR that would fix the problem, I have not touched the codebase of react-mapbox-gl before, so it might take me a bit longer to sort this out though.

@narkowicz
Copy link

Chiming in to say this is also breaking our webpack builds (we're not transpiling node_modules):

ERROR in node_modules/react-mapbox-gl/lib/cluster.d.ts(23,13):
TS2749: 'Supercluster' refers to a value, but is being used as a type here.
Version: typescript 3.6.4

Changing the import in cluster.d.ts to import * as Supercluster from 'supercluster'; as suggested by @henrinormak results in the following error:

ERROR in node_modules/react-mapbox-gl/lib/cluster.d.ts(23,13):
TS2709: Cannot use namespace 'Supercluster' as a type.
Version: typescript 3.6.4

@narkowicz
Copy link

As per #735 this was solved by installing @types/supercluster@latest... "Silly me" indeed! Original report appears correct in that the types should be production or peer dependency. 👍

@mklopets
Copy link
Collaborator

mklopets commented Dec 5, 2019

esModuleInterop solves the import issue; release v4.8.1 solves the type dependency issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants