deckgl-typings icon indicating copy to clipboard operation
deckgl-typings copied to clipboard

Trouble with installation

Open andrewshrout opened this issue 4 years ago • 10 comments

Hey Dan,

I'm new to typescript but I'm migrating a maptool I developed in deck.gl. I can't figure out what I'm supposed to do to install IndefinitelyTyped and get the deck.gl types to go to the right place. The readme for both is confusing for someone like me who's fairly new to this stuff.

Is indefinitelytyped supposed to be globally installed? If so, why does it not put the deckgl-typings into my @types in node_modules when I install that in my project?

Thanks for any help

andrewshrout avatar Oct 07 '20 21:10 andrewshrout

Hi Andrew, you shouldn’t have to install indefinitely-typed. You should only have to npm install @danmarshall/deckgl-typings. Check the readme in this repo, there was PR yesterday that may add another way for you to get the typings in your project. Sorry I’m on a mobile device right now or else I’d add the link :)

danmarshall avatar Oct 07 '20 21:10 danmarshall

And then you put import * as DeckTypings from "@danmarshall/deckgl-typings" declare module "deck.gl" { export namespace DeckTypings {} } at the top of the file usings DeckGL?

andrewshrout avatar Oct 08 '20 18:10 andrewshrout

In my projects, that part is not needed. However, others have said they do need it. If you use it, I think you can put it in its own .d.ts file or in any .ts file within your project.

danmarshall avatar Oct 08 '20 18:10 danmarshall

Also check out https://github.com/danmarshall/deckgl-typescript-example to see how it all hangs together.

danmarshall avatar Oct 08 '20 18:10 danmarshall

When I install, then put <reference types="deckgl-typings" /> like your sample, I still get Cannot find type definition file for 'deckgl-typings' ts(2668).

I'm sorry, I don't know what a .d.ts file is. That would just contain the import / declare module code? Where would that typically go in a project?

andrewshrout avatar Oct 08 '20 20:10 andrewshrout

🤔 not sure where you got <reference types="deckgl-typings" /> ... I don't see it in my sample. That is an older style of referencing that we don't use anymore.

danmarshall avatar Oct 08 '20 21:10 danmarshall

Perhaps you can share your repo?

danmarshall avatar Oct 08 '20 21:10 danmarshall

I think I was accidentally looking at an old repo for react examples. Now looking at the new updated one.

My partner and I are beginning to migrate our project that we had originally created in React over to Typescript in Nextjs. The map file is here, and I've just been stuck trying to understand all the linting issues for the last couple days. Any help would be greatly appreciated. Judging from the type of errors I keep getting (tons of property's dont exist on types that don't exist), my assumption is if I could figure out how to load your types, it could compile finally and I could keep working on the migration.

https://github.com/andrewshrout/mapstack/blob/master/app/components/map/OlMap.tsx

Thank you so much for your patience with a new developer.

andrewshrout avatar Oct 08 '20 23:10 andrewshrout

@andrewshrout you could try to create a file called 'deckgl.d.ts' in your src folder. And in this file put only this code:

import * as DeckTypings from "@danmarshall/deckgl-typings" 
declare module "deck.gl" { 
    export namespace DeckTypings {} 
}

ChrisJamesC avatar Oct 20 '20 06:10 ChrisJamesC

@andrewshrout you could try to create a file called 'deckgl.d.tsin yoursrc` folder. And in this file put only this code:

import * as DeckTypings from "@danmarshall/deckgl-typings" 
declare module "deck.gl" { 
    export namespace DeckTypings {} 
}

This helped me tremendously. Thank you. I will make a PR to the README to add these additional details 😄

epan avatar Apr 14 '21 23:04 epan