-
Notifications
You must be signed in to change notification settings - Fork 886
no-unused-variable: Create a duplicate SourceFile #2763
no-unused-variable: Create a duplicate SourceFile #2763
Conversation
@andy-hanson having this problem fixed would be great. To verify the fix you need to run on case insensitive system like Windows. Is there a build of tslint in npm that I could try to verify the fix? If desired I can come up with steps for how to verify the fix with the tslint-language-service plugin. |
@egamma You could try with a linked copy? Clone my branch, |
Works for me on Windows. |
@andy-hanson with the fix I can no longer reproduce the problem in the TS server plugin, which is great. However, I have a question about the implementation of this rule in general. One goal of running tslint as a TypeScript server plugin is to reuse/share the Program that the TS server already maintains. Doesn't the current implementation of the no-unused-variable rule create another Program with copies of Source files for each run of the rule? While this is OK when the program is run from the command line, when the rule is run in the TypeScript server as part of the tslint-plugin, then the rule is run as the user types. Will this implementation scale with large Programs? Also I'm still concerned about the implementation of getCaseSensitiveFileNames which is hardcoded to:
Won't this bite at some point? |
@egamma |
@andy-hanson goodness.
Does the rule still need access to the original Program? In other words does the rule still need to be a TypeRule? Stepping back, the trick with using the compiler options to temporarily enable the TS noUnusedLocal option is a clever way to reuse the TS implementation of this check. It looks like the tslint rule does some additional work on top of what the TS option provides. Wouldn't it make sense to improve the original TS implementation so that there is no need for a temporary program with different compiler options? Reparsing a large single file can still be costly. |
The TS implementation marks symbols as used while checking them, so it can't be run independently of a |
@andy-hanson got it, actually not a problem when tslint is run as a language server plugin. In this setup we always pass a Program to tslint tslint-language-service. So what I will do for now is to add a setting for the tslint-language-service plugin that allows a user to supress this rule when running as a plugin.
#9448 has lots of comments, but your point is that you want to have some comment like Interestingly TS has added a such a comment to disable type checking in JS files with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like there are real build failures on Windows (appveyor CI)
Looks like there is still a TypeScript blug blocking this. The checker tries to grab a |
@ajafff would you be able to take a look here and update the PR as necessary? |
I resolved the merge conflicts. The changes regarding case sensitivity from #2819 are still included. I had to revert the change that created a program consisting of only one source file. That produced exceptions in I verified that it no longer has side effects on other rules by linting https://github.com/CSchulz/tslint-type-check-rule-collision Re: windows CI failures: |
That sounds like a lot. We only take this performance hit when |
You're right. This might make the rule unusable for larger projects or as a language service plugin, though. |
Agreed, when used in language service plugin this will happen as the user types. |
@andy-hanson please update this branch so we can review it, or close it if not relevant. |
Closing due to age and inactivity. Feel free to re-open or create a new pull request if you decide to continue working on this. |
PR checklist
Overview of change:
I tested out on https://github.com/CSchulz/tslint-no-unsafe-any-showcase and this fixed that issue. Hopefully this can fix the errors in VSCode too, but I'd need confirmation. CC @egamma
CHANGELOG.md entry:
[bugfix]
no-unused-variable
: Create a duplicate SourceFile