amplify-js: Could not find TypeScript declaration for '../vendor/paho-mqtt'
If you are using TypeScript and you try to install the latest version of aws-amplify you will see the following error:
/Users/username/WebstormProjects/my-project/node_modules/@aws-amplify/pubsub/lib/Providers/MqttOverWSProvider.d.ts
(1,23): Could not find a declaration file for module '../vendor/paho-mqtt'. '/Users/username/WebstormProjects/my-project/node_modules/@aws-amplify/pubsub/lib/vendor/paho-mqtt.js' implicitly has an 'any' type.
Try `npm install @types/aws-amplify__pubsub` if it exists or add a new declaration (.d.ts) file containing `declare module 'aws-amplify__pubsub';`
Trying to install@types/aws-amplify__pubsub doesnt help as it doesnt exist so the solution is to declare it yourself.
To Reproduce
- Error happens when starting up (
npm start) a Create React App TypeScript project
Expected behavior No loading errors
Desktop (please complete the following information):
- OS: OSX
- Browser: n/a
- Version: n/a
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 15 (1 by maintainers)
A temporary fix, working for us:
Update your
tsconfig.json:Same issue with
After discussing with a colleague of mine we came up with a workaround to solve the problem. I believe this problem relates to https://github.com/Microsoft/TypeScript/issues/15031. Work around:
@typs/paho-mqttfor types.npm install -D @types/paho-mqttglobal.d.tsif you haven’t already.global.d.ts@chris-ramon Thanks for adding the temporary fix and @elorzafe picking up this ticket.
This is happening on both of the latest versions:
1.1.31.1.4-unstable.2