【发布时间】:2017-05-12 09:21:31
【问题描述】:
有没有办法导入一些库生成的没有export 变量的代码?应该在tsconfig.json 文件中设置哪些module 选项?
文件
环境
- 打字稿@2.3.2
- js-routes@1.3.3
示例
js-routes根据@987654327@生成如下代码:
/*
File generated by js-routes 1.3.3
Based on Rails routes of MyApplication
*/
(function() {
...
return root.Routes;
};
if (typeof define === "function" && define.amd) {
define([], function() {
return createGlobalJsRoutesObject();
});
} else {
createGlobalJsRoutesObject();
}
}).call(this);
如果您以 'module=es2015' 样式导入,
import { Routes } from '../path/to//generated/js_routes';
tsc 警告:
[ts] File '/path/to/client/generated/js_routes.js' is not a module.
【问题讨论】:
标签: ruby-on-rails typescript js-routes