Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to fix "Could not find a declaration file for module" from aws-appsync lib cause another error

I'm using aws-appsync library and I'm getting this error:

(4,42): Could not find a declaration file for module '@redux-offline/redux-offline/lib/types'. 'node_modules/aws-appsync/node_modules/@redux-offline/redux-offline/lib/types.js' implicitly has an 'any' type. Try npm install @types/redux-offline__redux-offline if it exists or add a new declaration (.d.ts) file containing declare module '@redux-offline/redux-offline/lib/types';

Then I added declare module @redux-offline/redux-offline/lib/types; to my typings.d.ts to check if that error goes away but I got other:

/node_modules/aws-appsync/lib/store.d.ts (13,69): Cannot use namespace 'NetworkCallback' as a type.

Now I don't know how to fix the last error because I didn't find many pieces of information about it on the internet.

I don't know if this is important, but packages/web/node_modules/@redux-offline/redux-offline/lib/types.js is a file only with "use strict"; line.

A solution that works is setting noImplicitAny: false, but I've read about it and it's not a good one.

Thank you!

like image 684
Pedro Arantes Avatar asked Dec 12 '18 12:12

Pedro Arantes


1 Answers

So I open the file /node_modules/aws-appsync/lib/store.d.ts and there are two types imported from @redux-offline/redux-offline/lib/types:

import { NetInfo, NetworkCallback } from '@redux-offline/redux-offline/lib/types';

Then in typings.d.ts I just added:

declare module '@redux-offline/redux-offline/lib/types' {
  export type NetInfo = any;
  export type NetworkCallback = any;
}

and the problem was gone.

like image 133
Pedro Arantes Avatar answered Oct 14 '22 01:10

Pedro Arantes