Visual Studio 2017 Intellisense with Aurelia - javascript

I have been trying desperately for a month to figure out a way to get JavaScript intellisense to work for Aurelia in Visual Studio 2017. I know there is no definitions in npm #types. I tried to copy over the index.d.ts file from the local node_modules folders to a folder in the Salsa Cache at c:\Users\User\AppData\Local\Microsoft\Typescript\2.5\#types that is named the same as the Aurelia module, along with the package.json. It didn't work. I tried adding a jsconfig.json. Also didn't work. Is there anyone with Aurelia intellisense working in VS 2017????????

I'm not sure if this is applicable to your installation, but there is a known issue (https://github.com/jspm/jspm-cli/issues/1344) with type definitions when Aurelia is installed via jspm. The solution for now, unfortunately, is to also install Aurelia as a dev dependency via npm.
npm install --save-dev aurelia-framework aurelia-bootstrapper aurelia-pal-browser aurelia-polyfills
This takes up more space, but should resolve the issue until it's fixed properly.

Related

How to get intellisense for AngularJS in VSCode?

So can anyone help me get the AngularJS intellisense working in Visual Studio Code?
Is it possible to configure this globally or can it only per project? I'm preferably looking for a solution on how to do this globally, as in whenever I open VSCode AngularJS intellisense just works.
I'm currently using AngularJS 1.5.x. I do not know if it possible to configure according to the version of AngularJS being used. Additionally, I'm using VSCode 1.10.2 and VSCode - Insiders on Windows 10.
I've already searched in several places, but the solutions I've found did not work for me. Maybe it's because they are old.
There are many extensions available for intellisense in Angular (2+), but not for AngularJS. However, this article by Mike Barlow explains how to do it and it's fairly recent since you've asked your question (June 2016).
Here's the summary of what you need to do per the article:
Have the following tools installed: node.js 6.2+, npm 3.9+, and VSCode 1.2+.
Install the typings package globally: npm install -g typings. Make sure this is a 1.X version.
Install AngularJS types: typings install dt~angular --save --global
This should create a a folder typings\globals\angular\ with a file called "typings.json"
Create a file within this directory as a sibling to "typings.json" called "jsconfig.json". This file can remain empty unless you need to transpile code (ie, using typescript, coffeescript, etc.)
Restart VSCode

Visual Studio doesn't recognise imported npm package?

When importing npm packages into my project in Visual Studio, it always baffles me that sometimes, the packages just don't get recognised no matter how many times I refresh the folders.
The folder react-google-maps is definitely in my node_modules folder. However, for some reason, Visual Studio cannot see this error and highlights it as an error. And because of this, all relevant intellisense don't show up too. Strangely, it can actually recognise react!
What should I do to get Visual Studio to recognise new packages I just installed through npm in the console so that I can import them without the highlighted errors?
I beleive your issue is that react-google-maps is a JavaScript module. To let TypeScript import the module you need some typings translating JavaScript into TypeScript, e.g. from DefinitelyTyped repository.
A quick search found no such typings, why I'm assuming you didn't install any typings for this.
There are two solutions, if this is the case.
Write the typings and commit them to DefinitelyTyped or the Typings registry. This is the my recomended aproach. Give somthing back to the community by writing the typings and publishing it for others.
Declare a module in your project to silence the import. This one does not give you any IntelliSence, so it only silences the import.
To declare the module in your project, add a new file named react-google-maps.d.ts and paste this in:
declare module "react-google-maps" {
export var GoogleMap;
export var Marker;
}

Should you commit the typings folder for es6 projects when using vscode?

So I have been using Visual Studio Code (vscode) when playing with some sample es6 projects.
My understanding is that in order to get intellisense to work properly with node modules, you need to include the typings of the projects that you're working on (Link here).
What I also understand is that you can have a typings.json file that stores all the "type definitions" and you run a typings install to retrieve all the typings.
This is all to get the intellisense working in vscode. What I am not sure is whether you should exclude this (typings folder and typings.json) from version control altogether?
At the moment I think that the editor should not influence the source code structure. I'm pretty sure that you should exclude the typings folder. I am not sure about typings.json. It could be useful for vscode users, but will most likely be pointless for WebStorm/Atom/Sublime/Vim users?
The content of the typings folder can easily be recreated by running typings install. If you have any kind of build process like webpack, browserify, gulp or similar, then you also need to have these definitions to be able to run the typescript compiler in your continuous integration system for example.
So you should commit the typings.json and add some npm postinstall scripts to automatically download the typings when you run npm install to be able to build your code in an automated way.

VS 2015 Angular 2 import modules cannot be resolved

I have created an empty web project and added files using
Angular-cli
https://scotch.io/tutorials/use-the-angular-cli-for-faster-angular-2-projects
I can run the website fine using ng buid/serve but I get below error in editor:
I read somewhere that it is Resharper error in version 9, so I upgraded my Resharper to latest which fixes the problem but it cannot resolve the modules. any suggestions?
Edit: created a new typescript class and it's giving below error
As far as I know, Resharper still doesn't support TypeScript latest versions. It looks like Resharper ignores tsconfig.json file that exists inside src folder. I suggest you try VS Code instead. It's free and has much better support of new TypeScript features.
If you still want to stay with VS 2015, you can configure Resharper not to analyze .ts files. Here is how to do it.
open npm and run npm install typings and then typings install and if after that it still doesn't work, try build the project
Try installing VS2015 update 3.
I had that error before and I was due to my typescript version installed in VS2015.

Visual Studio Code not performing error checking in Javascript

I've tried following these instructions:
https://code.visualstudio.com/Docs/runtimes/nodejs
I am not getting the green/red swiggly lines at all. Is there something I'm missing?
You can also see the same thing in this video:
https://youtu.be/sE8_bTEBlFg?t=1m37s
As far as I know, they're running the default editor. I've tried installing typings and typescript using npm. I've Followed that tutorial to get Javascript intellisense for node.js, but I fail to get either error/warning checking or any type information for node.js modules.
Is there a location the type files should be installed to in order to make them global to every JS project you create in VS Code?
OK, so I managed get get some code suggestions working after reading up online. Without using the whole Typings tools, I acquired node.d.ts (found it on my computer inside C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions) and placed that in my project's directory structure inside the ".vscode" folder. At the top of my .js file I added the following line:
/// <reference path=".vscode/node.d.ts" />
The code seems to be recognized now.
I read up on this tip here: How to Import Intellisense files into vsCode (Visual Studio Code)
If you are using ESLint and you have an .eslint.js file in the project root you also need the eslint dependency installed in the project. Otherwise, if there is a .eslint.js file but the ESLint dependency is not installed Visual Studio Code will report nothing in the editor.
Maybe you didn't use the -g flag to install them globally? Alternately, perhaps it's a missing jsconfig.json file?

Categories