Closed andyrooger closed 6 years ago
To add a little to that - I can change a project's TypeScript tools version to a specific major and minor version, e.g. 2.6, but I can't choose 2.6.1 or 2.6.2 so it's hard to keep package.json and the language service in sync.
I've also realised I can figure out what specific version I'll be using on my own machine by digging through the folders installed in C:\Program Files (x86)\Microsoft SDKs\TypeScript
.
tslint-language-service is just a simple TypeScript plugin. I don't know which fixes you wish to do?
I was hoping either you might be able to tell me I'm doing it wrong, or that you would know where to start looking for a fix.
The reason I've raised an issue here is that on its own tslint works fine for me, it's just an issue when it is passed source files from Visual Studio. It's a really useful plugin, but this makes it hard for me to use it on a shared project in VS.
Two approaches I guess might work and are possible from the plugin are
mock-require
I'm happy to try writing both since it's easy for me to repro the problem, but do you think either of these approaches are reasonable?
For now I have used the code from the PR to create a second plugin locally that loads before tslint-language-service
that looks like this
// testing/tslint-language-service-versioner/index.js
"use strict";
function init(modules) {
// Force tslint to load with the language service's version of typescript. Must be loaded before tslint-language-service
require("mock-require")('typescript', modules.typescript);
function create(info) {
info.project.projectService.logger.info("tslint-language-service-versioner loaded");
return info.languageService;
}
return { create };
}
module.exports = init;
and added it to tsconfig plugins as { "name": "../testing/tslint-language-service-versioner" }
This seems to work around the problem until an official fix makes it into npm.
Short version
Rules either don't work or work badly when the version of typescript differs between tslint and VS. It is hard to notice when this has happened, and it's hard to stop it happening.
Long version
I am trying to get the language service set up in Vs 2017 and noticed certain rules (mainly
semicolon
) weren't producing linter errors. I tracked it down the issue to a difference in version between the typescript used by VS (and hence tslint-language-service) and the typescript used by tslint. TheSyntaxKind
enum has changed between 2.6.1 and 2.6.2, and the source file for tslint comes from the VS typescript version, but is walked using the tslint version.I can confirm that downgrading my tslint version of typescript (in package.json) to 2.6.1 to match VS fixes things, however:
I'm happy to have a go at fixing this but I'm not sure where to start:
Program
passed back from the language service?