Vscode-ng-language-service: Breaking IntelliSense in typescript non angular project

Created on 4 Apr 2017  路  16Comments  路  Source: angular/vscode-ng-language-service

Once the extension installed, in my node,js+typescript project the IntelliSense breaks. Only when I disable the extension and reload the IntelliSense works again.

bug

All 16 comments

I have not seen this before. Do you have an example repository I can clone?

unfortunately it is a private repository. Might it be because I use typescript 2.2.1 in the node.js project?

There should be no way the angular language service should be able to interfere with a non-angular project. Is this something you can reproduce with any TS project or just the one you have?

This might be related to a 100% CPU consumption issue that I narrowed down. I am going to release 0.1.2 tonight or tomorrow. Let me know if it helps.

it makes that it relates to 100% CPU. I've noticed when the extension enabled the CPU peaks.
I've updated the to 0.1.2 and it is still failing. When the extension enabled the CPU reaches to 100%.

Can you help me narrow this down by pointing me to a project I can clone that reproduces this (or attaching a .zip of a project)?

@chuckjaz This might be the same as #73
Attaching zip:
node-course.zip

I am hitting this too on the latest release.

I'm seeing this too with the sample app from http://mean.io/
image

Same here. Breaks intellisense in all projects for me, regardless if angular or not.

@aeschli I created a default application using mean init myApp and discovered we don't handle incorrect dependencies very well. I will be working on this.

mean init myApp does not include all the peer dependencies that Angular requires and that is causing the language service to get very confused. As a work-around, fix the peer dependencies of the project (for example @angular/compiler-cli should match the rest of the framework, @angular/material now has a peer dependency on @angular/cdk, which is causing the confusion).

To get the language-service to work better you should, at least, add:

js "@angular/cdk": "^2.0.0-beta.6",

to the package.json file along side @angluar/material and re-run npm install.

@RenaldasK I have seen other reports of this but no concrete reproducible case. Can you give me an example?

Regardless of whether or not there is a repro / bug - if this extension does extra work when it shouldn't, it is taking cycles off of users, and that isn't acceptable. That can be demonstrated simply by inspecting the code and analyzing when it is doing work.

The first thing this extension should do is detect if the currently opened project is an angular project or not. If it is, continue, if not, end (or subscribe to file events on package.json to register itself later).

If there already is angular project detection in this repo, could you please point it out? I'm not sure what to search for :\ womp I did a cursory search and could only this in the client extension.ts file:

//Register the server for Angular templates
documentSelector: ['ng-template', 'html', 'typescript'],

This heuristic would only need to look in dependencies and search for any keys with the @angular prefix.

In addition, the server and the client should do the same heuristic (would this matter? Does one get started by the other? Not sure how extensions work :o ).

I'd be more than happy to contribute such a heuristic as a function, but I wouldn't know where to put it in - I'd assume client and server? Something like this psuedo-typescript:

const isAngularProject: (string) => boolean = dir => {
  /* get deps of package.json as array of strings, just package name for now */
  let deps = /* TODO */;
  var hasAnyAngularPackageReference = false;

  deps
    .map(s => s.indexOf('@angular') > -1)
    .forEach(isAngDep => {
      hasAnyAngularPackageReference = hasAnyAngularPackageReference || isAngDep;
    });

  return hasAnyAngularPackageReference;
}

or something like that, obviously the real code would actually be smarter about it.

Maybe related issue: Microsoft/vscode/issues/43658

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings