Skip to content

Type checks not working in a typescript project #11151

@kanagarajkm

Description

@kanagarajkm

Describe the bug

yarn start or yarn build are not throwing any type errors.

Did you try recovering your dependencies?

I have tried a fresh install.

Which terms did you search for in User Guide?

I tried finding a similar issue in github, but there isn't any

Environment

Environment Info:

  current version of create-react-app: 4.0.3
  running from /home/kanagaraj/.config/yarn/global/node_modules/create-react-app

  System:
    OS: Linux 4.15 Ubuntu 18.04.4 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
  Binaries:
    Node: 12.16.1 - /usr/bin/node
    Yarn: 1.21.1 - /usr/bin/yarn
    npm: 6.13.4 - /usr/bin/npm
  Browsers:
    Chrome: 86.0.4240.75
    Firefox: 89.0
  npmPackages:
    react: ^17.0.2 => 17.0.2 
    react-dom: ^17.0.2 => 17.0.2 
    react-scripts: 4.0.3 => 4.0.3 
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. Run npx create-react-app my-app --template typescript
  2. Create a new file test.jsx under the src directoy with following contents
type Props = {
  message: string
}

export function getValue(props: Props): string {
  return props.message1
}
  1. Update the index.tsx with following contens
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import {getValue} from "./test"

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

console.log(getValue({message: "test"}))
  1. Run yarn start or yarn build
  2. No errors thrown even there is a type error in test.jsx

Code is present in this repo https://github.com/kanagarajkm/my-app-ts

Expected behavior

Type check errors should be thrown

Actual behavior

Type check errors are not thrown

Reproducible demo

Please refer this repo https://github.com/kanagarajkm/my-app-ts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions