Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

checkJs option ignored in tsconfig

See original GitHub issue

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 Info:

    OS: macOS 10.14
    CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    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
    Chrome: 71.0.3578.98
    Firefox: 64.0.2
    Safari: 12.0
    react: 16.4.1 => 16.4.1
    react-dom: 16.4.1 => 16.4.1
    react-scripts: ^2.1.3 => 2.1.3
    create-react-app: 2.1.3

(paste the output of the command here)

Steps to Reproduce

  1. Create a react-app bootstrapping typescript
  2. Add javascript with flow typings
  3. Add checkJs: false to tsconfig.json
  4. 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

  1. Run yarn start

Output: screen shot 2019-01-24 at 2 24 52 pm

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: screen shot 2019-01-24 at 2 26 21 pm screen shot 2019-01-24 at 2 27 57 pm

I’ve also tried using // @ts-nocheck/// @ts-ignore however that does not seem to take effect

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:14
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

couziccommented, Apr 28, 2020

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.

tfahrenreichcommented, May 11, 2020

Migrating a code base from flow to ts and also facing this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Reference - Docs on every TSConfig option
Setting the value to undefined will allow most JavaScript runtime checks for the existence ... null and undefined are effectively ignored by the...
Read more >
Typescript ignores node_module's tsconfig - Stack Overflow
I noticed, in node-expose-sspi tsconfig there is only noImplicitAny=true , which implies other strict checks options to be false. Because of ...
Read more >
Disable type checking for JavaScript files in TypeScript
... set the `checkJs` option to `false` in your `tsconfig.json` file. ... eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore function ...
Read more >
Working with JavaScript in Visual Studio Code
Using the TypeScript language service, VS Code can provide smart completions ... or tsconfig.json , add "checkJs": true to the project's compiler options:....
Read more >
Ignoring TypeScript Errors - next.config.js
If disabled, be sure you are running type checks as part of your build or deploy process, otherwise this can be very dangerous....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found