create-react-app
create-react-app copied to clipboard
checkJs option ignored in tsconfig
Is this a bug report?
Yes (sort of)
Did you try recovering your dependencies?
Not necessary
Which terms did you search for in User Guide?
Looked through documentation and issues, did not find relevant ticket or info.
Environment
Environment Info:
System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Binaries:
Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
Yarn: 1.5.1 - /usr/local/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
Browsers:
Chrome: 71.0.3578.98
Firefox: 64.0.2
Safari: 12.0
npmPackages:
react: 16.4.1 => 16.4.1
react-dom: 16.4.1 => 16.4.1
react-scripts: ^2.1.3 => 2.1.3
npmGlobalPackages:
create-react-app: 2.1.3
(paste the output of the command here)
Steps to Reproduce
- Create a react-app bootstrapping typescript
- Add javascript with flow typings
- Add
checkJs: false
to tsconfig.json - Try to run the application -> js errors still show
Expected Behavior
I would like the checkJs
to be taken into account when building the application to allow migration from a flow-based application to typescript while allowing JS to be built in but not having typescript validate it. This will also allow typescript to import JS components without validating their implicit types.
Basically I have a codebase where I was using react-scripts-ts and we were able to slowly migrate using allowJs: true
and checkJs: false
and have eslint cover checking the code. I realize that having types in JS files is invalid syntax, however I'm in a migration process of removing flow.
Actual Behavior
Currently checkJs
option is ignored in the parent tsconfig.json
.
Configuration that normally works for flow migration
...
"noImplicitAny": false,
"allowJs": true,
"checkJs": false,
In CRA 2 the following options work:
...
"noImplicitAny": false,
"allowJs": false,
It will still compile properly with the issues and render the component, even the build will work, but this is counter-intuitive. Shouldn't allowJs false throw an error if JS is being imported on build?
Reproducible Demo
https://github.com/mobinni/cra-flow-migration
- Run yarn start
Output:
I also noticed that typescript with checkJs to true will infer types based on the defaulted value in the component and complain if something else is passed in:
I've also tried using // @ts-nocheck
/// @ts-ignore
however that does not seem to take effect
I realize that the ambiguity between babel building and how tsconfig does validation is not really a bug and that the above configuration will allow for a migration path
This sounds like a bug, maybe. Let's leave it open and get a better understanding. Thanks!
Has anyone found a solution or workaround for this problem yet ? For reasons specific to my current project, it is really bugging me right now.
I am also facing this issue. Any solution yet?
Migrating a code base from flow to ts and also facing this issue
Bumping this as it's been +2 years
I am getting the issue anyone got the solution??
I am upgrading to yarn 4 and I struggle with prisma that generate a client with js file that emit error and I want to ignore, checkJs false does not help