CRM 2015 – Typescript is ready to go, definition files available on NuGet

I have written about Typescript before and I like the idea of Typescript so I want to promote it (and the work of Dave Berry).  Below is my previous Typescript article

What is TypeScript and how does it work with CRM 2011/2013

It’s time for an update.

I watched CRM MVP Dave Berry’s excellent presentation which is hosted on the XRMVirtual user group.

XRMVirtual group have lots of great past presentations, which you can find if you go to All Events –> Past

Not only did XRMVirtual group put on the presentation they put a recording so you can watch it if you missed the presentation

David Berry Presents an Introduction to TypeScript

I also recommend the Dave Berry CRM MVP Q&A, it’s informative and funny

It’s a LiveRecording which means you can download it watch it offline later.

The XRMVirtual group is a free group to join, so you have nothing to lose

I found watching the video very useful and it helped my understanding of how typescript can be used and how it works.

Quick recap of what Typescript is?

I will explain how I think and understand what TypeScript is and why’s its useful, this might not be the same view as everyone else.

Wiki definition first

TypeScript is a free and open source programming language developed and maintained byMicrosoft. It is a strict superset of JavaScript, and adds optional static typing and class-basedobject-oriented programming to the language. Anders Hejlsberg, lead architect of C# and creator of Delphi and Turbo Pascal, has worked on the development of TypeScript.[1][2][3][4]

TypeScript is designed for development of large applications and transcompiles to JavaScript.[5]As TypeScript is a superset of JavaScript, any existing JavaScript programs are also valid TypeScript programs.

Hosk description

Typescript works with Javascript and converts the typescript file into a javascript file.

What this means is you write your Typescript file and when you press compile it creates a plain Javascript version of your typescript file.  The end result is you end up with Javascript code, which is great because you can deploy this into Dynamics CRM.

Interesting why use Typescript?

Javascript is a dynamic language and .NET is strongly typed language.  What this means is when we have variables/objects/interfaces in .NET we write methods we define what variables/objects/templates should be passed.

If whilst developing some code a developer tries to call a method with a different type e.g. they try to pass an int into a method expecting a string, the compiler throws an error.

Typescript adds in this compiler/developer time type checking to your code

Hmmm I think I understand but I’m not convinced

The best way to explain the benefits of TypeScript is to compare it with CRM plugins using Early Bound.

Early bound code is creates a wrapper class round your entities.  It includes all the fields in your entity.  The benefits of of early bound classes

  • No typos
  • no type errors
  • easy to read and understand code

Early bound code means a lot of the potential errors in the CRM code are found at compile time instead of run time.  The big advantage of this is most of the errors are found and fixed by the developer rather than being found by the end customer.

Microsoft have a good post – Use the early bound entity classes in code

The advantages to using early-bound entity classes is that all type references are checked at compile time. The compiled executable contains the code necessary to invoke the types’ properties, methods, and events. For more information, see Use the early-bound entity classes for create, update, and delete.

Typescript is a bit like Early bound plugin code it brings the errors and type checking to compile time.

Early bound code uses an entity file (a file generated with all the fields on each entity) and Typescript uses a definitions file.

Typescript creates pure JavaScript files so the end result is the same as if you wrote JavaScript.

I’m interesting where can I find more information

My blog post

What is TypeScript and how does it work with CRM 2011/2013

Dave Berry’s Presentation

David Berry Presents an Introduction to TypeScript

TypeScript Introduction

What is typescript

Quick video

The video has a great quote, it’s preparing developers for what the future of Javascript will look like.

There are quite a few detailed videos on youtube, search for typescript

TypeScript available on NuGet

Dave Berry has been doing some great work creating the definition files for CRM 2013, CRM 2015, CRM 2015 service pack 1.

Dave has put in a lot of effort to help promote Typescript and CRM and he has succeeded on getting the typescript definition file on DefinitelyTyped(a website which holds definition files for typescript)

This is a great achievement because Dave had to put in a lot of effort creating tests for definition and this has (I believe) been a one man band effort.

You might be wondering why getting the definition files in NuGet is important, it means CRM developers can easily download the latest definition files right into visual studio.  This makes using typescript easier and will hopefully get more people trying typescript.

Hosk experience with Typescript

I have had a play with Typescript using Visual studio 2012.  The one question I had was it didn’t fit in very well with CRM Developer toolkit, there wasn’t a good development flow.  I was hoping Dave’s presentation would show me how this was done but unfortunately for me Dave uses Visual Studio 2013 (where Typescript is bundled in with Visual Studio) and he doesn’t use the CRM Developer toolkit.

I could easily create the TypeScript project and create the Javascript but it had to be in a separate project to my CRM Developer toolkit project, which made it a bit clunky.  If anyone has a good solution to this problem I would be interested

I’m at the stage where I need to do to use TypeScript more before I use the Javascript in a CRM project.  I also need to change my mindset from writing quick non OO Javascript and moving to writing more structured Javascript.

I’m not entirely sure how this fits in with a lot of the validation Javascript which is written for CRM projects but I think this is because I haven’t used Typescript much yet.

There is a little downside to using Typescript, except learning to write Typescript because the end result will be a pure Javascript file.

The benefits are strongly typed Javascript, this should capture lots of errors in compile time and create more readable code which should be well designed like server side code.  The advantage of well designed code is it will be easier to understand, maintain, debug and extend.  Basically the benefits lists in this post – Why your CRM code and customizations should be simple

 

Give it a go and leave me some comments of your adventures and links to blog posts about CRM and Typescript.

May the CRM force be with you

 

Hosk’s Top CRM articles of the week 3rd October 2014

Thumbs up for friday everyone

Articles of the Week

I will add this as one of my top articles, it’s not really an article but it’s very useful because the blogs on the list are excellent

The top 25 CRM blogs

 

This article from Guido is great, it takes a question from the forum, an answer from CRM MVP Scott Durow, followed by some hard work by Guido to create the full solution, great work.

Check if a User has a specific Privilege

 

I will add another because I can, it’s from the snooze Berry, Dave Berry.  It was written when Dave use to blog (pre snooze), although I have been informed from the great Berry himself he is busying doing great things with TypeScript and CRM

Entity.GetAttributeValue<T> Explained

 

Best of the Rest

 

Interesting article showing  you how to compare 2 lines in your fiddler trace

Comparing Sessions in Fiddler

 

A quick definition on business rules
CRM 2013 – Quick Guide to Business Rules

 

Add CRM DLL’s via the internet not you local drive

Don’t load CRM dll’s from the local folder, go to the internet

 

How to convert HTML to plain text for an email with a plugin

CRM 2013 – Convert Email HTML to Plain Text

 

The error and the solution

Assembly generation failed — referenced assembly does not have a strong name

 

Great article from Guido with a reference to Dave Berry

http://www.crmanswers.net/2014/09/getattributevalue-activityparty.html

 

An error caused by Odata query with null guid value

CRM 2011 – UnRecognized ‘Edm.Guid’ literal ‘guid’null

 

Are people starting to like Microsoft again?

Common things to check if your CRM is down

Microsoft Dynamics CRM not working? check these common causes

 

Hosk learnt a few things whilst reviewing javascript

CRM 2011 – Things learnt when reviewing Javascript code on form loads

A quick start to getting started with fiddler

Getting Started with Fiddler and CRM

 

A tool you can add (at a cost) to performance test CRM 2013 using fiddler

Performance testing with stress Stimulus in CRM 2013

Timers in CRM 2013 and ways to use them

The Best Little Microsoft Dynamics CRM 2013 Feature You Might Not Know What To Do With: Timers

How to debug those pesky ribbons
CRM Ribbon Problems

 

A new CRM 2015 feature

Nested Quick Create in Microsoft Dynamics CRM 2015

 

Using goals to schedule a daily job, very clever

Scheduling Recurring Workflows for a Nightly Processing Service

 

CRM 2013 interview question and things to consider

CRM 2013 Interview Question – What things should you consider when choosing between CRM online or on Premise

 

Great description of leads

Leads are like Zombies

 

CRM Exams are reduced in price until December

15 percent of CRM exams until DEC with these codes

 

How will Microsoft Social Listening sell?

 

Quick Guide – What are Rollups in CRM 2013

great idea allowing people to write their own help, good listening Microsoft

Write custom help in CRM 2015

Question on the Hosk CRM Career blog

I have passed MB2-703 should I take the equivalent CRM 2011 certification

 

OTHER HOSK STUFF

Watch out for career climate change

Don’t be afraid to ask stupid questions

Are people starting to like Microsoft again?

How will Microsoft Social Listening sell?