facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.78k stars 26.87k forks source link

Type checks not working in a typescript project #11151

Open kanagarajkm opened 3 years ago

kanagarajkm commented 3 years ago

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 }

3. 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(

, 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"})) ``` 4. Run `yarn start` or `yarn build` 5. 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
jtsorlinis commented 3 years ago

I was having the same issue, turned out it was because I was using a junction/symlink for my project.

Switching to the original folder directly fixed my typescript compilation and errors now show up as expected.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.