1

Typescript works perfect since it tells you all errors you have in the code when compiling.

However, in development, this can be a bit annoying when you make a change to try like, for example, to comment a line. An example working with eslint: Failed to compile. Line whatever. Variable X is declared but its value is never read.

Is there a way to force Typescript compile with this kind of errors that don't affect the app's behaviour?

1 Answer 1

3

You can edit the tsconfig.json with:

{
  "compilerOptions": {
    "noUnusedLocals": false,
    "noUnusedParameters": false
  }
}

Additionally you can set no-unused-vars eslint rule so that the errors would show in your IDE but typescript would still compile your code.

Or include it as a flag (--noUnusedLocals, --noUnusedParameters) in your build command in the package.json.

More info about flags in the docs.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I want to add that "noUnusedLocals": false and "noUnusedParameters": false is the default behavior. For my problem, adding "no-unused-vars": "warn" worked. It allows to see the unused variables in the console while still letting the compiler compile without trouble.

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.