heroiclabs / nakama-js

JavaScript client for Nakama server written in TypeScript.
https://heroiclabs.com/docs/nakama/client-libraries/javascript/
Apache License 2.0
182 stars 54 forks source link

Addresses type definition discoverability issue #160

Closed foundrium closed 1 year ago

foundrium commented 1 year ago

I have a newly created Vite project setup, and when trying to use nakama-js I see the following:

Could not find a declaration file for module '@heroiclabs/nakama-js'. '/home/foundrium/code/nakama-poc/node_modules/@heroiclabs/nakama-js/dist/nakama-js.esm.mjs' implicitly has an 'any' type. There are types at '/home/foundrium/code/nakama-poc/node_modules/@heroiclabs/nakama-js/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@heroiclabs/nakama-js' library may need to update its package.json or typings.ts(7016)

I tested this fix locally with npm link and the error goes away, but I don't have a clear picture of what it would mean for other setups. Will leave it to the maintainers to decide if its worth merging.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

lugehorsam commented 1 year ago

Hey @foundrium could you share your Typescript and NPM versions?

foundrium commented 1 year ago

Sure @lugehorsam they are

lugehorsam commented 1 year ago

Thanks @foundrium. I see that Vite uses a newer bundling method which causes this to happen. The solution looks okay but I was wondering why you removed the existing types entry in the root-level package.json? I think that may still be needed for projects that are not using the "exports" block.

foundrium commented 1 year ago

@lugehorsam yeah thats a good point. I can update

foundrium commented 1 year ago

@lugehorsam done.