1

I am using vs code with create-react-app --typescript, if i get any type errors i see it in the browser and typescript prevents compilation. i would like to see the errors only in google console and terminal but allow the valid js to compile.enter image description here

2
  • "and allow valid js to compile" The code from your image (which should be included in text form in the question btw) is valid js, but it is not valid typescript and you are writing typescript and not javascript. Therefore it is correct for typescript not to compile it. So what is your question? Do you want to turn off the error? Do you want to fix it? Do you want to disable the prompt? Or do you want to compile even when there are errors? Commented Jun 5, 2019 at 8:20
  • hello Patrick, sorry if it's not very clear ... I want to be able to see the error in the console/terminal but to be able to compile, for example: if i am assigning string to number, the error with display in the console but i wil not see this in the browser hope its clear Commented Jun 5, 2019 at 8:59

2 Answers 2

3

You cannot do that. But you can put //@ts-ignore before the line which contains the error. In your case:

{/* 
  //@ts-ignore */} //this will do the trick
{value.galleryId} <DragHandle />
Sign up to request clarification or add additional context in comments.

Comments

0

If you use webpack the ForkTsCheckerWebpackPlugin will achieve something like you want to do. This plugin will separate the compile process from the error reporting. After you have installed and imported this plugin, you will need to set the ts-loader to compile only mode. In the plugins section the plugin needs to be injected, to do the error reporting separately.

const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
//...
   module: {
      rules: [{
          test: /\.tsx?$/,
          use: [
            // ...
            {
              loader: 'ts-loader',
              options: {
                // disable ts checker - will run it in fork plugin leater
                transpileOnly: true
              }
            }
          ]
        }, 
   // ..
   ],
   plugins: [
      new ForkTsCheckerWebpackPlugin({
         tsconfig: path.resolve(__dirname, 'tsconfig.json')
      }),
   // ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.