//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
}
}
tslint reports:
bar.ts[3, 27]: Qualifier is unnecessary since 'Foo' is in scope.
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"
]
}
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;
}
}
Same invalid error with enum and namespace here.
The original code (foo.ts, bar.ts) is no longer an issue, but manu-st's FooEnum still does.
Still having this issue with FooEnum using [email protected]
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!
๐ค 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! ๐
Most helpful comment
I have a similar issue but in a slightly different context and the latest version of tslint (v5.10.0) is reporting the error: