mongodb / stitch-js-sdk

MongoDB Stitch JavaScript SDK
Apache License 2.0
113 stars 67 forks source link

Problem with mongodb-stitch-bson typings #171

Closed marozzocom closed 6 years ago

marozzocom commented 6 years ago

I am trying to build a client-side solution with TypeScript using a MongoDB Stitch backend. My build fails with the following error:

[project path]/dist/esm/core/auth/providers/userapikey/UserApiKeyAuthProviderClient.d.ts (6,29): Namespace '"mongodb-stitch-bson"' has no exported member 'ObjectID'.

I have declared a module ina global.d.ts file as follows:

declare module "mongodb-stitch-bson";

without this line I get the following error:

Could not find a declaration file for module 'mongodb-stitch-bson'. '[project path]/node_modules/mongodb-stitch-bson/index.js' implicitly has an 'any' type.

The only MongoDB related dependency I have installed in package.json is

"mongodb-stitch-browser-sdk": "^4.0.14"

I understand the dependency on BSON, but I am not sure should BSON be somehow separately installed?

marozzocom commented 6 years ago

I was able to fix the problem without changing the imports by including the line "esModuleInterop": true into tsconfig.json compilerOptions.