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

no-unnecessary-qualifier reports qualifier as being in scope when it is not #2413

Closed
tomblind opened this issue Mar 27, 2017 · 6 comments
Closed

Comments

@tomblind
Copy link

Bug Report

  • TSLint version: 4.5.1
  • TypeScript version: 2.2.1
  • Running TSLint via: CLI

TypeScript code being linted

//foo.ts
namespace Foo
{
	export class SomeClass
	{
	}
}

//bar.ts
namespace Bar
{
	export var someVar = new Foo.SomeClass();
}

with tslint.json configuration:

{
	"rules":
	{
		"no-unnecessary-qualifier": true
	}
}

Actual behavior

tslint reports:
bar.ts[3, 27]: Qualifier is unnecessary since 'Foo' is in scope.

Expected behavior

No warning should be emitted, as Foo is not in scope and removing the qualifier will produce code that will not compile.

Note that the two namespaces must be in separate files and the first namespaces declared in those files. Placing a namespace above either Foo or Bar makes the warning go away.

tslint command: tslint -c tslint.json --type-check --project tsconfig.json

tsconfig.json:

{
	"files": [
		"foo.ts",
		"bar.ts"
	]
}
@manu-st
Copy link

manu-st commented Jun 15, 2018

I have a similar issue but in a slightly different context and the latest version of tslint (v5.10.0) is reporting the error:

export enum FooEnum
{
   FIRST = 0,
   LAST = 1,
   INVALID = 2,
}

export namespace FooEnum
{
   export function isEnumValid (value: FooEnum): boolean
   {
      return value !== FooEnum.INVALID;
   }
}

@zakjan
Copy link

zakjan commented Jul 21, 2018

Same invalid error with enum and namespace here.

@JoshuaKGoldberg
Copy link
Contributor

The original code (foo.ts, bar.ts) is no longer an issue, but manu-st's FooEnum still does.

@igabesz
Copy link

igabesz commented Aug 5, 2019

Still having this issue with FooEnum using tslint@5.18.0

@adidahiya adidahiya added the P3 label Nov 18, 2019
@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

6 participants