Skip to content

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

Closed
@plaa

Description

@plaa

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:

  • React does not have a type Node
  • Section component uses implicit any types (disallowed by strict mode configured in tsconfig.json)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions