Search code examples
javascripttypescriptimportstring-concatenationtslint

concatenate import url in typescript


I'm developing a software using typescript 2.0.3 and tslint 4.0.2 and angular.
I have an issue since my import url is too long for tslint standard. Changing line limit in tslint is not possible in my case.
I tried separate the url to pieces and concatenate them, but it doesn't work. Basically this is what I have:

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

and this is what I need:

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

Any suggestions?


Solution

  • You cannot split the import string. If your path is a/b/very_long_c/blabla, You can create an index.ts inside a/b containing

    export * from './very_long_c/blabla';
    

    and use this in your code:

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