Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 在typescript中使用别名导入特定类型_Angular_Typescript_Import - Fatal编程技术网

Angular 在typescript中使用别名导入特定类型

Angular 在typescript中使用别名导入特定类型,angular,typescript,import,Angular,Typescript,Import,我可以将特定类型导入为 import { Type1, Type2 } from '../../my-file'; 我可以从别名为的文件导入所有类型 import * as fromApp from '../../../store/app.reducers'; 如何使用别名导入特定类型,例如 import { Type1, Type2 } as MyTypes from '../../my-file'; // of-course, this does not work 你能做的最接近的事情

我可以将特定类型导入为

import { Type1, Type2 } from '../../my-file';
我可以从别名为的文件导入所有类型

import * as fromApp from '../../../store/app.reducers';
如何使用别名导入特定类型,例如

import { Type1, Type2 } as MyTypes from '../../my-file'; // of-course, this does not work

你能做的最接近的事情是:

import {Type1, Type2} from '../../my-file';

const MyTypes = {Type1, Type2};

那么你认为类型的最终用法是什么呢?如果您正在查找
MyTypes.Type1
MyTypes.Type2
,则可以将
import*用作MyTypes
语句。但如果存在不需要的
Type3
,则,只为
Type1
Type2
定义一个别名应该很好。您知道,对于构建过程来说,需要更少的类型并不会改变任何事情,只需使用
*就可以了,无论什么
,如果您只是谈论类型的话