react-native-community / react-native-template-typescript

👾 Clean and minimalist React Native template for a quick start with TypeScript.
https://www.npmjs.com/package/react-native-template-typescript
MIT License
1.86k stars 398 forks source link

Brand new project fails to compile due to incorrect types #195

Closed plaa closed 3 years ago

plaa commented 3 years ago

Steps to reproduce

$ npx react-native init MyApp --template react-native-template-typescript
...
$ cd MyApp/
$ npx tsc --skipLibCheck
App.tsx:12:15 - error TS2305: Module '"./node_modules/@types/react"' has no exported member 'Node'.

12  import type {Node} from 'react';
                 ~~~~

App.tsx:31:20 - error TS7031: Binding element 'children' implicitly has an 'any' type.

31  const Section = ({children, title}): Node => {
                      ~~~~~~~~

App.tsx:31:30 - error TS7031: Binding element 'title' implicitly has an 'any' type.

31  const Section = ({children, title}): Node => {
                                ~~~~~

Found 3 errors.

Expected results

A newly created project should be valid Typescript (according to the accompanying tsconfig.json). It would also be nice to be styled e.g. according to some prettier rules.

Observed results

Running the app works (npm run ios) but compiling the code fails and VScode shows the following errors:

These are both introduced in #193.

Also App.tsx shows up bright red/yellow in VScode with prettier for example because every code line is indented by one space.

It would be great if the code validity could be (automatically) tested prior to releases.