# Dojo Definitions Usage Notes ## Overview Anyone that has used Dojo for any length of time has probably discovered three things: * Dojo is very powerful * Dojo can be challenging to learn * Dojo doesn't always play well with other Having said that, there are ways that Dojo can be coerced out of its shell to work with other JavaScript technologies. This README is intended to describe some techniques for getting the full power of Dojo to work in an environment where almost everything can take advantage of TypeScript. *Disclaimer*: Dojo is VERY big framework and, as such the type definitions are generated by a [tool](https://github.com/vansimke/DojoTypeDescriptionGenerator) from dojo's [API](dojotoolkit.org/api) docs. The generated files were then hand-polished to eliminate any import errors and clean up some obvious errors. This is all to say that the generated type definitions are not flawless and are not guaranteed to reflect the actual implementations. ## Basic Usage A normal dojo module might look something like this: ```js define(['dojo/request', 'dojo/request/xhr'], function (request, xhr) { ... } ); ``` When using the TypeScript, you can write the following: ```ts import request = require("dojo/request"); import xhr = require("dojo/request/xhr"); ... ``` Inside of the define variable, both `request` and `xhr` will work as the functions that come from Dojo, only they are strongly typed. ## Advanced Usage Dojo and TypeScript both use different and conflicting class semantics. This causes some issues when trying to create custom class modules that are strongly typed in other modules. The following technique is presented as **A** solution to the problem, but not necessarily the best one. Other ideas a welcomed! Using pure JavaScript, a class that has a base class and mixins can be defined in Dojo as follows: ```js define(['dojo/_base/declare', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dojo/request'], function(dojoDeclare, _WidgetBase, _TemplatedMixin, request) { var Foo = dojoDeclare([_WidgetBase, _TemplatedMixin], { templateString: '