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

Unused types / imports are not being detected in *.d.ts files #3922

Closed
massimonewsuk opened this issue May 22, 2018 · 3 comments
Closed

Unused types / imports are not being detected in *.d.ts files #3922

massimonewsuk opened this issue May 22, 2018 · 3 comments

Comments

@massimonewsuk
Copy link

massimonewsuk commented May 22, 2018

Bug Report

  • TSLint version: 5.10.0
  • TypeScript version:
  • Running TSLint via: CLI

TypeScript code being linted

Inside a .d.ts file

type Unused = {
    unused: string;
}
export type Foo = {
    foo: string;
}

with tslint.json configuration:

{
  "extends": ["tslint-config-airbnb", "tslint-config-prettier"],
  "rules": {
    "import-name": [false],
    "prefer-array-literal": [false],
    "variable-name": [true, "check-format", "allow-leading-underscore"],
    "object-shorthand-properties-first": [false],
    "only-arrow-functions": [true],
    "ter-arrow-body-style": [true, "as-needed"]
  }
}

Actual behavior

No errors. The same code inside a normal *.ts file results in an error.

Expected behavior

I expect it to say that the Unused type is unused.

@giladgray
Copy link

@massimonewsuk are you running tslint --project ...? must use the project approach as these unused rules require the type checker.
https://palantir.github.io/tslint/rules/no-unused-variable/

@massimonewsuk
Copy link
Author

Yep I'm using tslint --project

As mentioned above, this only affects *.d.ts files

@JoshuaKGoldberg
Copy link
Contributor

Duplicate of #3883.

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

3 participants