durandal typescript bootloader -


i create wrapper around durandal using typescript make easy create new spa apps easy development team.

let me shortly describe way structure wrapper; there initial bootstrap class , configuration developer needs configure set new application. here achieve now.

appcore.d.ts

declare module 'system/app' {     var appcore: spaapp;     export = appcore; }  interface spaapp {     isindebugmode: boolean;     initroute: initialroute;     apptitle: knockoutobservable<string>;     init: () => void; } interface initialroute {     viewmodel: string;     animationmode: string; } 

app.ts

import app = require('durandal/app'); import viewlocator = require('durandal/viewlocator'); import system = require('durandal/system');  class bootloader implements spaapp {     isindebugmode: boolean;     initroute: initialroute;      apptitle: knockoutobservable<string>;      init: () => void;      constructor(title: string)     {         this.apptitle = ko.observable<string>();         this.initroute = { viewmodel: 'dsasda', animationmode: 'entrance' };         this.init = this.initapp;     }      private initapp()     {         system.debug(this.isindebugmode);         app.title = this.apptitle();         app.configureplugins({             router: true,             dialog: true,             widget: true         });          app.start().then(() => {             viewlocator.useconvention();             app.setroot(this.initroute.viewmodel, this.initroute.animationmode);         });     } }  export = bootloader; 

this compiles , app.ts compiled amd module, real problem begins when tried create main enty point application

main.ts

requirejs.config({     paths: {         'text': '../libs/text',         'durandal': '../libs/durandal',         'plugins': '../libs/durandal/plugins',         'transitions': '../libs/durandal/transitions',         'knockout': '../libs/knockout'     } });  var apphost = require('system/app'); 

after typing apphost. not see intellisence apphost. achieve have main.ts in way.

requirejs.config({     paths: {         'text': '../libs/text',         'durandal': '../libs/durandal',         'plugins': '../libs/durandal/plugins',         'transitions': '../libs/durandal/transitions',         'knockout': '../libs/knockout'     } });  var apphost = require('system/app');  apphost.apptitle('my sample spa app'); apphost.isindebugmode = true; apphost.initroute = {     viewmodel: 'viewmodels/shell',     animationmode: 'entrance' };  apphost.init(); 

and compiled main.js requirejs load application.

my question is: doing wrong , why can not see properties , init method after type apphost.

if want intellisense / typesafety after require call need use import foo = require('filename') syntax.

so,

import apphost = require('system/app'); 

these known , external modules in typescript , need compile code --module compiler flag.

ps: have video on subject http://www.youtube.com/watch?v=kdrwlmuy0r0&hd=1


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -