-
Notifications
You must be signed in to change notification settings - Fork 889
no-unused-variable false positive when variable is declared outside of a module #570
Comments
Additional failure example: class HelloWorld {
constructor(public name: string) { }
sayHello() {
return `Hello, ${this.name}!`;
}
};
let hello = new HelloWorld("TSLint");
hello.sayHello(); Output:
This is a bad bug, going to try to get it fixed ASAP. |
@jkillian @adidahiya - can I ask, is this the following an instance of the same issue? Or a problem specific to /// <reference path="tsd.d.ts" />
import * as React from "react";
interface IMProps {
Name: string;
}
export class HelloMsg extends React.Component<{}, {}> {
constructor() {
super();
}
render(): JSX.Element {
let props: IMProps = { Name: "test" };
return <div>
<Msg {...props} />
</div>;
}
}
export class Msg extends React.Component<IMProps, {}> {
constructor() {
super();
}
render(): JSX.Element {
return <div></div>;
}
}
Configuration as follows:
|
@myitcv I think what you're seeing is a similar, but different problem. Definitely an issue, but my guess is it has a different cause than the other bugs above |
I'm getting false positive when using import variables in another import statement. (due to rule 'no-unused-variable'). Below is sample code. import ExternalDefinition = require("ExternalDefinition");
import Def = ExternalDefinition.MyNamespace.MyClass1;
export class MyImplementation
extends MyBaseClasses.BaseClass1
implements Def.Contract {
} I get below error even though 'ExternalDefinition' is used in another import statement:
|
@jkillian - just in case you haven't seen the link, I think I tracked it down to this: |
Thanks both. @myitcv nice find, looks like it is a TypeScript bug. Hopefully they'll get that fixed pretty soon and then we'll be sure to get that into TSLint. @praveennet Yours is because of a TSLint bug which I discuss here. I'm working on getting that fixed, (hopefully) should be released by next Friday. |
@jkillian - no problem. I've found that using these tests as a template for finding issues like this really useful. |
@jkillian @adidahiya - just so that I'm clear, are we thinking this issue is a separate bug and needs fixed from TypeScript core? If so I'll open a new issue to track that. |
@myitcv If the fourslash test is failing, definitely a TypeScript issue. Feel free to go ahead and open up a separate issue, I tried out your sample and am still getting 'unused variable: "props"' |
@jkillian hi, I am using tslint version 3.14.0 and I just got a false positive similar to the one @praveennet got. thanks! |
@hashark I recommend using TS 2.0, these bugs should be fixed in it. |
thanks! I don't see them. |
simple repro code:
tslint reports
'fs'
on line 1 is unused.The text was updated successfully, but these errors were encountered: