2016-11-16 56 views
7

假设我有以下源结构。使用SystemJS模块系统时从索引文件导入WebStorm

/home 
    home.component.ts 
/shared 
    /domain 
    car.domain.ts 
    house.domain.ts 
    person.domain.ts 
    index.ts 

所有域文件包含有类似

export interface Car { 
    someProperty: number; 
} 

索引文件看起来像这样

export * from './car.domain'; 
export * from './house.domain'; 
export * from './person.domain'; 

然后在工作完全正常导入像这样在我家的组成部分。

import { Car, Person } from '../shared/domain'; 

import { Car, Person } from '../shared/domain/index'; 

但是,当自动导入WebStorm上导入接口,这样

import { Car } from '../shared/domain/car.domain'; 
import { Person } from '../shared/domain/person.domain'; 

坚持有什么办法有WebStorm喜欢从索引文件导入?

回答

5

您需要打开文件|设置|编辑|一般|自动导入设置并启用该选项[使用目录导入]

注:需要WebStorm 2016.3或更高

enter image description here

+0

神奇。我半期待WebStorm不支持​​这一点。很高兴我错了。 – Hampus

+3

从Webstorm 2017.2开始,此设置将迁移到* File |设置|编辑|代码样式| Typescript(Imports标签)* – FunkyOne