justdice / react-native-advertising-id

React Native bridge for fetching advertising info on iOS and Android
MIT License
37 stars 31 forks source link

@types missing, problems using lib with TS #25

Open geoche opened 3 years ago

geoche commented 3 years ago

After installation always have an error

TS7016: Could not find a declaration file for module 'react-native-advertising-id'. 'E:/Projects/application/node_modules/react-native-advertising-id/index.js' implicitly has an 'any' type.   Try npm install @types/react-native-advertising-id if it exists or add a new declaration (.d.ts) file containing declare module 'react-native-advertising-id';

Already tried creating new externals.d.ts with module declaration, some configurations in tscofing. Nothing helped.

Any suggestions?

RN: 0.59.5 with Redux and TS

dv-jm commented 3 years ago

I created a file named "decs.d.ts" in my root directory (RN 0.63):

declare module 'react-native-advertising-id' {
  export const getAdvertisingId: () => Promise<{
    advertisingId: string;
    isLimitAdTrackingEnabled: boolean;
  }>;
}

You might have to specify this file location in the include property of your tsconfig.json file.