Fri, 10/01/2021 - 06:32 By Pham Ba Son Contributor Lloyd Sebag

Overview on D365 client API with DefinitelyTyped

When developing model-driven apps javascript web resource using either javascript or typescript, it’s hard to keep track with all the client API the environment gives us. This could be overcome by using typescript with the correct type definition for the client API. Type definitions can either be manually created/generated or imported using one of these 2 packages

  • XrmDefinitelyTyped: In its own words “It is the TypeScript equivalent of CrmSvcUtil, but instead of generating early-bound .NET classes for server-side code, it generates TypeScript interfaces for all your client-side coding.”
  • @types/xrm: This is more lightweight than the aforementioned package. It only contains the type definition required for client api with some system constants and enum values.

These 2 packages are community projects which targets to ease the development process for client-side requirements. In this article I want to share with you how to use the package @types/xrm in your project. For the package “XrmDefinitelyTyped” it has been discussed in this article.

@types/xrm is a sub-folder of project DefinitelyTyped. This project is a large community collaboration to create/store/maintain/distribute type definition for popular javascript libraries which smooth out the transition from javascript to typescript development. 

  1. @types/xrm is distributed using npm package manager. The first step should be to initialize an npm package in the directory that will contain your client-side project.
    npm-init
  2. Use npm to install @types/xrm
    Overview on D365 client API with DefinitelyTyped
    After the installation is complete your directory should look something like this
    Overview on D365 client API with DefinitelyTyped

That’s it, @types/xrm is very simple to setups and gets going. Now your client-side project is augmented with Intellisense for XRM client API which will be a massive boost for your development.

intellisense-support

This package has deprecated properties of the XRM client API with the tag “@deprecated”. They are included in the package for they are still usable (not removed by microsoft, yet). You can manually remove these properties to keep your code up to date with the API. Updates for this package depends on contribution of the community. You can also make a pull-request to contribute a fix or update following guidance in the project’s repository.

Overview on D365 client API with DefinitelyTyped

@types/xrm is a light-weight solution for client-side development. This tool does not support connection to dynamics organization to generate entities definition. For more strict and complex usage, I reccomend that you check the other package, XrmDefinitelyTyped, out.

Overview on D365 client API with DefinitelyTyped

Add new comment

Image CAPTCHA
Enter the characters shown in the image.