GetMetaMap / metamap-reactnative-plugin

Metamap React Native SDK
9 stars 15 forks source link

TypeScript typing missing #70

Closed bombillazo closed 1 year ago

bombillazo commented 2 years ago

Hello, when using the MetaMap SDK in TypeScript I get the following error:

Could not find a declaration file for module 'react-native-expo-metamap-sdk'. '/Users/code/project/node_modules/react-native-expo-metamap-sdk/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-native-expo-metamap-sdk` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-native-expo-metamap-sdk';`ts(7016)

Running npm i --save-dev @types/react-native-expo-metamap-sdk yields this error:

[1/4] 🔍  Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@types%2freact-native-expo-metamap-sdk: Not found".
AvoSukiasyan commented 2 years ago

@bombillazo Hello. Are you using React Native or React Native Expo in your project?

bombillazo commented 1 year ago

React Native Expo

AvoSukiasyan commented 1 year ago

@bombillazo can I have your package.json or tsconfig.json and package.lock files? please

bombillazo commented 1 year ago

I have various files (we use a monorepo) and they are very large to be honest, what are you looking for ?

AvoSukiasyan commented 1 year ago

@bombillazo for my example project URL of the package.lock looks like this. what does your URL look like? "https://registry.npmjs.org/react-native-metamap-sdk/-/react-native-expo-metamap-sdk-4.5.1.tgz".

bombillazo commented 1 year ago

I cannot see the file, but I don't see any type definitions inside the metamap node module:

image
LeoGCode commented 5 months ago

This should be reopen the package are still missing the types definitions, the only thing required is add this code to the file a.ts


declare module 'react-native-expo-metamap-sdk' {
  export const MetaMapRNSdk: {
    showFlow: (
      clientId: string,
      flowId: string | null,
      metadata: Record<string, string> | null,
    ) => void
    showFlowWithConfigurationId: (
      clientId: string,
      flowId: string | null,
      metadata: Record<string, string> | null,
      configurationId: string | null,
      encryptionConfigurationId: string | null,
    ) => void
  }
}

renamed to types.ts for more descriptive file and add the location to the types property in the package.json

teampazi commented 4 months ago

Hello @AvoSukiasyan I am having this issue but there was no solution provided here for this issue please can you help. I am using expo 51, node 18, npm 9, typescript ~5.3.3, react 18.2.0 , react-native 0.74.1