Using Visual Studio Code with Dynamics CRM part II

In a blog post I’ve written a few months ago, I wrote about using Visual Studio Code with Dynamics CRM. At that point in time VS Code was still in beta. Now it had it’s first major release and continues to get updates and popularity.

One other thing that has changed since that blog post is the release of TypeScript 2.0. And with that there’s a new way to use typings in your project. In this post I will explore the latest with VS Code and Typings in the context of CRM.

How to get started

If you haven’t already, you need to download two things:

If you have these installed, create a folder, open a command prompt and type:

You can enter through all the default settings if you want. The process will create a package.json file where all these settings are stored and where you can change them later on.

You might also want to run:

To check the version of TypeScript you are using. If the tsc command is not known or if you have a version lower than 2.x.x, you can run

to install typescript or update it to the latest version.

Typings

Previously you needed to install the TypeScript Definition Manager to get Typings. Now this has changed to a npm package. If you are still on the command prompt type:

This will get the typings file for jQuery and add it to your project. Same for the CRM typings file that Dave Berry created for CRM:

The files are all stored in you node_modules folder in your project. Since we added –save to the command line, the dependencies are also added to the package.json. So when you are working with source control, you can exclude the node_modules folder and run npm install to restore all the packages.

JavaScript project configuration

If you want intellisense from these typings files in your JavaScript project, you need to add a jsconfig.json file in the root of your project. This will tell Visual Studio code that you are creating a JavaScript project.

A sample jsconfig.json:

If all things worked out you get great intellisense:
visual-studio-code-with-crm-demo

Leave a Reply

Your email address will not be published. Required fields are marked *