简体   繁体   中英

Import specific types with alias in typescript

I can import specifc types as

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

I can import all types from a file with alias as

import * as fromApp from '../../../store/app.reducers';

How can I import specific types with alias, something like

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

The closest thing you can do:

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

const MyTypes = {Type1, Type2};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM