9

I am using Angular2 with Visual studio code. In visual studio code It shows me error as shown below :

enter image description here

As seen in the image Promise is highlighted with red underline. Also I have another query is if we define inline function then Visual studio code will also shows red underline below the name of function. Like response is shown with red underline in above image.

However my code works fine in browser. but in VS Code it shows me red underline.

I don't want any red underline in my code. Is it possible ? Can anyone help me to resolve this ?

2

2 Answers 2

1

As the visual studio has functionality for visible intellisense for any language, you can just add the typings.json file in root level and add below code to it.

-- your typings.json

{
  "globalDependencies": {
    "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459"
  }
}

and just hit the below command in cmd to current working project directory (install typings globally(-g) if not installed on your machine).

typings install

So only in visual studio, you will get the intellisense and remove the error.

1

One solution is to install the typings of es6-shim.

First install typings with:

npm install typings --global

Install the es6-shim typings with:

typings install es6-shim --save

You should have a typings folder now, with es6-shim.d.ts.

If you don't have a jsconfig.json file you will need to reference those typings by placing this on the top of your file:

/// <reference path='./path/to/typings' />

10
  • I have already installed both typings and es6-shim but still VS Code shows me red underline. HOWEVER my application works smoothly. I think something is not configured properly in VS code. Commented Jun 6, 2016 at 11:13
  • @HardipsinhJadeja did you add the reference path? Commented Jun 6, 2016 at 13:50
  • I am using typescript so, added reference to tsconfig.json file like this : prntscr.com/bdaji2. But still i am not getting intallisense and VS code showing red underline. shown as in my question. Commented Jun 7, 2016 at 4:49
  • @HardipsinhJadeja have you tried adding /// <reference path="/typings"> to the file where you need promises? instead of the tsconfig? Commented Jun 7, 2016 at 8:12
  • @HardipsinhJadeja is your typings folder in the root or inside node_modules? Commented Jun 7, 2016 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.