using amd modules with typescript

我的未来我决定 提交于 2021-01-29 04:27:40

问题


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 {}

来源:https://stackoverflow.com/questions/42552364/using-amd-modules-with-typescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!