迁移TS <amd-dependency>进行导入

时间:2019-02-01 07:01:18

标签: typescript requirejs amd

我正在将基于AMD的项目迁移到Typescript。 使用amd-dependency声明的模块将按预期进行翻译(在tsconfig.json中,我具有“ module”:“ amd”)。例如:

/// <amd-dependency path="model" name="mdl" />
"use strict";

import {Model} from "my-types";

declare var mdl: Model;

这正确翻译为:

define(["require", "exports", "model"], function (require, exports, mdl) {
    "use strict";
    ...

请注意,该模块是在RequireJS主文件中声明的:

require.config({
    baseUrl: ".",
    paths: {
        ...
        "model":        "js/model",
        ...
    }
});

“模型”将一组函数导出为:export = {fun1, fun2, ...}

但是不推荐使用amd-dependency,但是我找不到等效的import "module"。例如: import * as mdl from "model";引发以下错误:

writers.ts:4:22 - error TS2497: Module '"D:/Projects/GraphEditor/js/model"' resolves to a non-module entity and cannot b
e imported using this construct.

0 个答案:

没有答案