Using Dojo w/ TypeScript

Topics: General
Apr 25, 2013 at 9:24 PM
I am trying to utilize Typescript to build a map w/ the ESRI Javascript API (

all the sample show the javascript in the HTML.

How do I get the javascipt into the typescript page...

I've tried several options (like trying to use requirejs.. like this ( ) but i always get errors that require is undefined...

How do i get this code into out of the html page into javascript......

<script src=""></script>

 function init() {

     var initExtent = new esri.geometry.Extent({ "xmin": -13635568.034589134, "ymin": 4541606.359162286, "xmax": -13625430.573712826, "ymax": 4547310.472398059, "spatialReference": { "wkid": 102100 } });

     map = new esri.Map("mapDiv", {
         center: [-56.049, 38.485],
         zoom: 3,
         basemap: "streets"

Apr 26, 2013 at 2:07 PM
TypeScript is usable wherever JavaScript can be used. When you're calling into JavaScript from TypeScript, you'll need to reference a .d.ts file that describes the types of the symbols in the JavaScript you're using.

A good place to get started to see how this works is to look through the samples. There are a variety there, some using Node and some JQuery. The idea would be generally the same for Dojo.

As for the require - if you use require rather than TypeScript's import keyword, you'll generally be using a dynamically-typed module rather than having the static type information there. So there's a trade-off.
May 24, 2013 at 2:16 PM
Edited May 24, 2013 at 2:17 PM
I have created a new Git project here:

It enables using TypeScript with the new AMD-style Dojo Toolkit 1.7+
Jun 24, 2013 at 7:10 PM

I developped the esri.d.ts you need and you can see a sample in the following project.

News : the esri.d.ts file built for ArcGIS for JavaScript 3.4 is completed today, 23/06/2013.

Please give it a try and help me find bugs and improve the esri definition file for TypeScript.

Everything is here :

You can download the library and a sample (with instructions to make it run with or without Visual Studio 2012). I'm waiting for your feedback..