Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Unclear how to enable type checking after removing --type-check #3399

Closed
zamiang opened this issue Oct 26, 2017 · 14 comments
Closed

Unclear how to enable type checking after removing --type-check #3399

zamiang opened this issue Oct 26, 2017 · 14 comments

Comments

@zamiang
Copy link

zamiang commented Oct 26, 2017

Bug Report

  • TSLint version: 5.7.0
  • TypeScript version: 2.5.3
  • Running TSLint via: CLI

TypeScript code being linted

// code snippet

with tslint.json configuration:

{
  "linterOptions": {
    "typeCheck": true
  }
}

Actual behavior

No type checking happens.

The latest tslint recommends removing --type-check. I now run tslint --project tsconfig.json --config tslint.json. Even though I have typeCheck: true in my tslint.json, no type checking is performed if I remove the deprecated --type-check.

Is there a new config I am supposed to specify beyond adding typeCheck: true?

Expected behavior

Type checking happens

@adidahiya
Copy link
Contributor

We are removing type checking as a feature of TSLint, that's why we deprecated the CLI flag. Type checking errors should be reported by the compiler, not the linter.

@zamiang
Copy link
Author

zamiang commented Oct 26, 2017

Ah! I was unaware of that large change.

It seems like that change of functionality should be very clearly communicated. Am I safe to assume that type checking will continue to work at least until the next major version?

@adidahiya
Copy link
Contributor

I don't consider it a huge change... we are still allowing rules to use the type checker in their implementations. See here for more info #3322 (comment)

Yeah, we can call it out more loudly in future release notes.

@artem-konovalov-personal
Copy link

artem-konovalov-personal commented Nov 12, 2017

Yep but this change's completely killed pre-commit hooks. It seems like now it's possible to commit broken changes

@ajafff
Copy link
Contributor

ajafff commented Nov 12, 2017

@nervebassmaster That means you are probably using the wrong tool. Use tsc --noEmit in your precommit hook to make sure there are no compile errors

@artem-konovalov-personal
Copy link

artem-konovalov-personal commented Nov 12, 2017

@ajafff And what is the best way to do the same if I use ts-node instead of tsc

@artem-konovalov-personal

I guess I see. I found the issue in my script.
thx, @ajafff

@ajafff
Copy link
Contributor

ajafff commented Apr 10, 2018

To anyone subscribed into this issue who is still interested in a way to have type errors as part of the linter output:
I wrote my own linter runtime in the meantime. It has the ability to run TypeScript's type checker as a lint rule. See this recipe for more information.
It can even run TSLint rules, which is described here.

@MiguelMadero
Copy link

I was considering using tsc --noEmit but that adds about 7 more seconds to our build time for each package, while tsling with --type-check is only ~0.9 seconds, I'm assuming a lot of the work is duplicated between both tools.

@jamonkko
Copy link

I understand the design decision from technical perspective to remove typechecking from tslint. However as Miguel pointed out it has negative usability effect.

More devs will be bumping into this when they remove the deprecating no-unused-variable option and try to use the compiler options (noUnusedLocals and noUnusedParameters) instead.

So if I want to do both typechecking and linting using npm scripts I need to do something like:

"lint": "yarn typecheck && yarn tslint",
"tslint": "tslint --project tsconfig.json --config tslint.json '{src,test}/**/*.ts'",
 "typecheck": "tsc --project tsconfig.json --noEmit"

and then I can just:
yarn lint

This is slower and much more script code than before... I wouldn't be surprised if someone will write a wrapper or fork that does both.

@jpike88
Copy link
Contributor

jpike88 commented Sep 26, 2018

So basically, I can't use no-floating-promises in VSCode without doing some weird workaround instead of using the plugin. Me no like

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Nov 4, 2018

See https://github.com/Microsoft/typescript-tslint-plugin for a (n experimental, for now) VS Code plugin that works with typed rules.

@kasvtv
Copy link

kasvtv commented Mar 7, 2020

I really hope that the maintainers listen to their community on this one.
--type-check is still marked as deprecated and it makes precommit hooks terribly terribly slow to run tsc before.

@JoshuaKGoldberg
Copy link
Contributor

@kasvtv in case you missed it, TSLint is deprecated now: #4534. You'll want to switch to https://typescript-eslint.io.

I hear your point and agree with the pain point, but at this point your best bet is to switch tools anyway.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants