Joshua Augustinus
Joshua Augustinus

Reputation: 1670

Errors after adding typescript to react native app

I'm very new to TypeSccript. I'm trying to convert my React Native to use TypeScript. I followed the instructions here: https://reactnative.dev/docs/typescript

After running yarn tsc I get errors like:

node_modules/@react-navigation/stack/lib/typescript/src/types.d.ts:99:67 - error TS2339: Property 'style' does not exist on type 'PropsWithChildren<AnimatedProps<TextProps & RefAttributes<Text>>>'.

99     headerTitleStyle?: React.ComponentProps<typeof Animated.Text>['style'];

Is this an error in the node module or in my own code? Any tips on what I need to do?

I have a minimal project here: https://github.com/jauggy/React-Native-TypeScript-Test

Upvotes: 0

Views: 700

Answers (1)

g2jose
g2jose

Reputation: 1465

This seems to be caused by bad declaration typings in the @react-navigation version you're on. You can get around this by updating your tsconfig to tell typescript to skip type checking of all declaration files (*.d.ts files):

// tsconfig.json
"compilerOptions": {
  // ...
  "skipLibCheck": true
}

Docs https://www.typescriptlang.org/docs/handbook/compiler-options.html

Upvotes: 2

Related Questions