October 12, 2012

TypeScript CRM 2011 client scripting definition file

CodePlex project page

Last week Microsoft went public with a JavaScript super-set language called TypeScript. The idea behind this language was to keep it compatible with JavaScript (all JavaScript code is TypeScript code) and add a few features which make it easier to manage large code bases.
This features include compile time type checking and well known OOP structures like classes, interfaces and modules. OOP structures were possible to emulate in JavaScript but required the developer to write code that wasn't very easy to read and understand.

Off course TypeScript code is not understood by browsers. The code you write in TypeScript is compiled to pure JavaScript using the type script compiler (tsc). You then reference that JavaScript in you're web pages. The compiler tries to keep the structure of the generated JavaScript code as close to the original TypeScript code as possible, so it's easy to debug.

In one sentence TypeScript makes JavaScript easier to write, maintain and safer.

The TypeScript team also created a plugin for Visual Studio 2012 that provides syntax highlighting, automatic background compiling and more importantly IntelliSense for TypeScript code. In order to use that feature for existing JavaScript code it is required to create a definition file (something like header files in C/C++). Because I'm mainly a Dynamics CRM developer I thought it would be worthwhile to create such a definition file for Dynamics CRM 2011 client scripting - the Xrm.Page JavaScript library.

Simple manual (if you already have TypeScript installed):
1. Download the Xrm2011.d.ts file from the link above.
2. Add it to your project.
3. In your TypeScript code reference the definition file by adding
/// <reference path="Xrm2011.d.ts" />
on top of the file.

Advanced manual (if you don't have TypeScript installed):
1. Download & install the TypeScript plugin from here.
2. Optionally download  & install the Web Essentials 2012 extension for Visual Studio 2012 for improved code handling.
3. Proceed with the Simple Manual

Why should I use TypeScript instead plain JavaScript?
The simple answer is that it makes coding much easier and less error prone. Please look at the following examples:
Design time type information

IntelliSense code completion

Design time check

If you see any errors or possibilities to improve the definition file, please write a comment.

October 8, 2012

Dynamic CRM + IE 10. Scrollbar position indicator barely visible

When I started working on Windows 8 right after the RTM release for partners I noticed an annoying issue. The scrollbar position indicators are barely visible. Maybe my monitor isn’t a professional Eizo, but I didn’t have this issues in previous versions of IE.

Look at this screenshot:
The color difference between the background of the scrollbar and the position indicator is very small. You have to really concentrate to see where it is.

Look at the close up:

image                          image

On the left the original, on the right with marked position of indicator. Doesn’t look very clear, does it?

The colors are:

Indicator: #E9EDF1

If someone knows a good solution, please post it in the comments. It’s a minor issue, but quite annoying.