在typescript中连接import url

时间:2017-02-07 12:40:11

标签: javascript typescript import string-concatenation tslint

我正在使用typescript 2.0.3和tslint 4.0.2和angular开发软件。
我有一个问题,因为我的导入网址太长,不符合tslint标准。在我的情况下,无法更改tslint中的行限制。我尝试将网址分开并将它们连接起来,但它并不起作用。 基本上这就是我所拥有的:

import {  blabla } from
'./really long string (around 200 characters)';

这就是我需要的:

import { blabla } from
'100 characters here' + '100 characters there';

有什么建议吗?

1 个答案:

答案 0 :(得分:4)

您无法拆分导入字符串。 如果你的路径是a / b / very_long_c / blabla,你可以在a / b里面创建一个index.ts

export * from './very_long_c/blabla';

并在您的代码中使用它:

import { blabla } from 'a/b/index';