Background
Currently, when I work, we use dojo.requires to import all of our required classes, which we use with each class. However, in Dojo 2.0, they get rid of dojo.require and switch to amd require style ( http://livedocs.dojotoolkit.org/releasenotes/migration-2.0 ):
require(["dijit/form/Button", "dojox/layout/ContentPane", ...], function(Button, ContentPane, ...){
Currently we have dojo / dijit classes defined in their own .d.ts files:
module dijit.form{ export class Button extends dijit.form._FormWidget { showLabel : bool; _onClick (e:any) : any; _onButtonClick (e:any) : any; _setShowLabelAttr (val:any) : any; _clicked (e:any) : any; setLabel (content:String) : any; _setLabelAttr (content:String) : any; _setIconClassAttr (val:String) : any; } }
This allows us to extend these classes as follows:
class CustomButton extends dijit.form.Button {}
Problem
We would like typescript to be able to generate Dojo 2.0 (amd) style and do something like the following:
import Button = module("dijit/form/Button") class CustomButton extends Button {}
We would hope to compile something like the following:
define(["require", "exports", "dijit/form/Button"], function(require, exports, Button) {
However, this does not work, since import only works for modules, not classes. We get an error, for example:
The name '"dijit/form/Button"' does not exist in the current scope A module cannot be aliased to a non-module type
We also tried to define dijit classes, for example:
declare module "dijit/form" { export class Button.... }
Is there a way to achieve what we are trying to do?
thanks