简体   繁体   English

打字稿导入模块作为变量不起作用

[英]typescript import module as variable not working

I am trying to import a variable from another file using and giving alias name for that but typescript throwing error alias name not defined. 我正在尝试使用另一个文件导入变量,并为其提供别名,但打字稿抛出错误的别名未定义。

Ex: 例如:

import { headerItems as TestHeader } from './headers';

Typescript version: 3.2.4
Ng cli: 7.3.7
webpack: 4.19.0

Thanks in advance! 提前致谢!

Refer https://github.com/angular/angular-cli/issues/13212 and https://github.com/IgorMinar/angular/commit/b7313ac2c619e96617258606d090f42ad73c44c0 请参阅https://github.com/angular/angular-cli/issues/13212https://github.com/IgorMinar/angular/commit/b7313ac2c619e96617258606d090f42ad73c44c0

It's unclear why import as results in the aliases to be undefined. 目前尚不清楚为什么import as结果导致别名未定义。

Plain tsc seems to do the right thing and emits the correct code, so it might be some kind of interaction in @angular/cli or webpack that are causing the failure. 普通的tsc似乎做正确的事并发出正确的代码,因此@ angular / cli或webpack中的某种交互可能会导致失败。

This should be investigated separately from the tsc update in angular/angular. 应该与角度/角度的tsc更新分开研究。 See angular/angular-cli#13212 参见angular / angular-cli#13212

-- Igor Minar -伊戈尔·米纳尔(Igor Minar)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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