Open jnarwold opened 7 years ago
Your tslint-language-service is installed in the same folder than typescript?
In other words have you that:
Yep - our web project (contains all the js/ts/etc. code) is a subdirectory of our core project. The structure of that web project looks like this with tslint & tsconfig being at the same level of the node_modules folder:
---> web project folder ------> node_modules ---------> typescript ---------> tslint-language-service ---------> tslint ------> tslint.json ------> tsconfig.json
Please share a little project which causes your pb, thanks
This is a drop of the codebase we're having issues with - due to size I had to delete everything from the node_modules so you'll want to run an npm install for that. server.ts has some random code that should be throwing 5-6 linter errors.
I've been futzing with it today and it appears the issue might stem from namespacing. If I copy the contents from a folder with . to one without, vscode picks up the errors as expected.
@jnarwold have you also forced the use of the project's typescript install in vscode (by clicking on the version of typescript on the bottom right of the screen, next to the smiley and then selecting "use workspace version").
@angelozerr I've noticed that if you don't set "typescript.tsdk": "./node_modules/typescript/lib"
in the workspace settings of vscode, it does not propose to use it…
@angelozerr I've noticed that if you don't set "typescript.tsdk": "./node_modules/typescript/lib" in the workspace settings of vscode, it does not propose to use it…
Yes you need that tslint-language-service is hosted inside the same folder than TypeScript, it's because of this declaration https://github.com/angelozerr/tslint-language-service/blob/master/src/index.ts#L1:
import * as ts_module from "../node_modules/typescript/lib/tsserverlibrary";
I have done like sample, but I'm not sure that's it's a good idea, see https://github.com/RyanCavanaugh/sample-ts-plugin/issues/2
TypeScript 2.4 will provide the capabilty to register a plugin "globally" so I think @egamma will use this feature inside VSCode to avoid installing at hand the tslint-language-service.
@victornoel I suggest you also try the vscode-tslint(vnext) extension. It bundles the tslint-language-service https://marketplace.visualstudio.com/items?itemName=eg2.ts-tslint
@egamma so ultimately (when it is released), we should not use at all the tslint-language-service in our projects but simply add the extension, right?
@victornoel the goal for vscode users is that the user can just install a VS Code extension. The extension then has the typescript language server plugin bundled, so that the user doesn't have to install both an extension and the plugin.
If you want to use a different version of typescript using the tsdk setting, then you are on you need to use and configure the tslint-language-service directly.
@egamma ok, I got it, thanks for the explanation :)
@victornoel - Yep! I'm using TypeScript 2.3.3 on VSCode through the vscode typescript install.
I don't believe this is a versioning issue, though. As I mentioned earlier, it seems to be directly linked to folder structure namespacing.
@angelozerr Any ideas on what might be causing the namespacing issue (if that is indeed the root of my problems)?
@jnarwold waiting for answer of https://github.com/RyanCavanaugh/sample-ts-plugin/issues/2
@egamma How do I confirm that vscode-tslint(vnext)
extension is running?
I've followed the steps and so far, I don't see an option to check the log for the project or some command to run the linter and get the output. Do we get a friendly output to fix the problems with links to the files with errors?
Thanks a lot for the amazing work.
@matheo you can enable logging and you should see that the tslint language service trace messages.
You can enable logging like:
set TSS_LOG=-level verbose -file c:\tmp\tsserver.log
The message would look something like:
Info 13 Loading tslint-language-service from C:\Users\egamma\.vscode-insiders\extensions\eg2.vscode-ts-tslint-0.0.1 (resolved to C:/Users/egamma/.vscode-insiders/extensions/eg2.vscode-ts-tslint-0.0.1/node_modules)
@egamma I'm trying with VSCode 1.22.2 and I had to select VSCode typescript version to be able to detect the plugin inside the extension ~/.vscode/extensions/eg2.ts-tslint-0.0.4/node_modules
(Ubuntu 17.10)
But when I try to pick custom versions adding them to my local node_modules
, it couldn't load it with typescript < 2.6:
Info 10 [11:48:56.877] Config file name: /my/tsconfig.json
Info 11 [11:48:57.100] Enabling plugin tslint-language-service from candidate paths: /media/work/git/selvera/provider/node_modules/typescript/lib/tsserver.js/../../..
Info 12 [11:48:57.100] Loading tslint-language-service from /my/node_modules/typescript/lib/tsserver.js/../../.. (resolved /my/node_modules/node_modules)
Info 13 [11:48:58.843] tslint-language-service loaded
Info 14 [11:48:58.844] Plugin activation failed: TypeError: info.project.getCurrentDirectory is not a function
With typescript ¬2.6 it finally worked:
Info 30 [11:52:23.321] Plugin validation succeded
and now I see this plugin is developed "typescript": "^2.7.2"
which is far beyond my Angular 4, which supports <= 2.4.x. Will see if I have troubles with this typescript
version.
Thanks
I'm not sure if I've configured something incorrectly or if vscode is just struggling but I can't manage to get vscode to lint properly through the tslint-language-service.
tsconfig.json
tslint.json
server.ts (file I'm intentionally trying to break to catch errors)
This should trip on multiple levels: no vars, single quotes, etc. Running TypeScript 2.3.3 Note: I can run tslint via the command line and it picks up on errors as expected.