1
votes

Checked these links:

  1. Typescript error Property does not exist on type
  2. property then does not exist on type void , A typescript error
  3. Typescript property does not exist on type {}
  4. TypeScript: suppress Property does not exist on type
  5. TS2339: Property does not exist on type
  6. https://github.com/Microsoft/TypeScript/issues/1574

But I couldn't seem to understand this behavior.

Reproduce:

git clone https://github.com/the-joat/rn-maps-ts-bug-demo
cd rn-maps-ts-bug-demo
yarn
yarn build

Typescript will successfully compile but I want to suppress the error you'll see in Qwerty.tsx.

I've tried having a .d.ts file that has:

import MapView from "react-native-maps"
declare module "react-native-maps" {
  const a: any
  export default a
}

but it's throwing another error and I don't think it's really a permanent solution since I won't be able to benefit from the types declared in react-native-maps.

1

1 Answers

1
votes

It looks like the react and react-native type definitions are missing from the project. Those types are required to properly recognize the props of JSX elements. Try installing them:

yarn add --dev @types/react @types/react-native