2

I am working on an Durandal spa and would like to write new code in typescript.

Is there a way to mix amd modules with typescript classes? This an example of an amd module. I removed some code from the module to make it more readable.

define(['durandal/app', 'durandal/system', 'config', 'amplify'],
function (app, system, config, amplify) {

    var exports = {};

    var init = function () {
        ...
    };

    var onRequestError = function(response, status) {
        ...
    };

    exports.getTablePresentation = function (lemmaId, languageKey) {
        ...
    };

    exports.getSuggestions = function (searchdirection, term, level) {
        ...
    };

    init();

    return exports;
});

I am using VS Code as my editor. In tsconfig.json I have set allowJs = true and this is the import syntax I am trying to use.

import * as config from '../config.js';
export class AppSecurity {}
Martin Andersen
  • 2,460
  • 2
  • 38
  • 66
  • Please read my question again. I am trying to introduce typescript for new features and reuse existing code without modifying – Martin Andersen Mar 02 '17 at 15:22
  • Would these help? These people have ideas at least. http://stackoverflow.com/questions/20079464/whats-the-correct-way-to-use-requirejs-with-typescript and http://www.codebelt.com/typescript/typescript-amd-with-requirejs-tutorial/ It would still likely need the full range of amd idioms such as returning a 'class' (object constructor), returning an object. – joshp Apr 12 '17 at 00:22

0 Answers0