1

I'm getting this typescript error from basically every component in VSCode, both custom and library components. This is an expo build for react native. This command yields the same results: yarn tsc --project tsconfig.json

here's an example in VSCode enter image description here

and an example of the full error message:

'KeyboardAvoidingView' cannot be used as a JSX component.
  Its instance type 'KeyboardAvoidingView' is not a valid JSX element.
    Property '$props' is missing in type 'TimerMixin & KeyboardAvoidingViewComponent' but required in type 'ElementClass'.ts(2786)

This is my .tsconfig:

{
  "extends": "../../node_modules/expo/tsconfig.base",

  "compilerOptions": {
    "jsx": "react-native",
    "strict": true
  }
}

and this is expo's that it extends:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Expo",

  "compilerOptions": {
    "allowJs": true,
    "esModuleInterop": true,
    "jsx": "react-native",
    "lib": ["DOM", "ESNext"],
    "moduleResolution": "node",
    "noEmit": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "target": "ESNext"
  },

  "exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
}
Georgemayer
  • 315
  • 4
  • 15

1 Answers1

1

I had the same problem I just added this to package.json then run yarn

"resolutions": {
   "@types/react": "17.0.2",
   "@types/react-dom": "17.0.2"
},

as mentioned here