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

no-unused-variable doesn't work in declaration files #3883

Closed
karol-majewski opened this issue May 6, 2018 · 6 comments
Closed

no-unused-variable doesn't work in declaration files #3883

karol-majewski opened this issue May 6, 2018 · 6 comments

Comments

@karol-majewski
Copy link
Contributor

Bug Report

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

TypeScript code being linted

a.ts
export const name = "John";
export const surname = "Doe";
b.d.ts
import { name, surname } from "./a";

export { name };

with tslint.json configuration:

{
  "extends": [
    "tslint:latest"
  ],
  "rules": {
    "no-unused-variable": true
  }
}

Actual behavior

No error.

Expected behavior

Error: 'surname' is declared but its value is never read.

@giladgray
Copy link

@karol-majewski what happens in the original b.ts source file? does it use surname in a way that is not preserved in the output? if not, then this behavior is expected.

@giladgray
Copy link

giladgray commented May 7, 2018

basically, this behavior looks correct. TSLint treats .d.ts files as source code unless you exclude/ignore them. so the lint rule is catching a valid error.

oops i think i read this backwards!

@karol-majewski
Copy link
Contributor Author

@giladgray It does not use it in any way.

This becomes problematic when you import and export from & to .d.ts files (your application domain model for example) and you end up with dead code pilling up, with no way to manage it.

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Nov 5, 2018

Amusing: this is the opposite of requests such as #190 and #434. Imports and types do seem reasonable to not exclude for being declarations.

@JoshuaKGoldberg
Copy link
Contributor

💀 It's time! 💀

TSLint is deprecated and no longer accepting pull requests other than security fixes. See #4534. ☠️
We recommend you instead use typescript-eslint to lint your TypeScript code with ESLint. ✅

👋 It was a pleasure open sourcing with you!

@JoshuaKGoldberg
Copy link
Contributor

🤖 Beep boop! 👉 TSLint is deprecated 👈 (#4534) and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

@palantir palantir locked and limited conversation to collaborators Mar 20, 2020
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