angular - Angular 使用带有命名空间的接口
问题描述
我正在使用带有类型脚本 2.7.2 的 Angular 6。我在单独的文件中创建了模型接口,但具有相同的命名空间:
模型1.ts:
namespace Api {
export interface Model1 {
field1: string;
field2: number;
}
}
模型2.ts
namespace Api {
export interface Model2 {
field1: string;
field2: number;
field3: Api.Model1; // this caused the error
}
}
使用接口 Model1 到接口 Model2 会导致错误。
(TS) Namespace 'Api' has no exported member 'Model1'.
这样做的正确方法是什么?
解决方案
推荐阅读
- python - 为什么我不能在 Pycharm 上安装 pygame?
- java - Java 在评估表达式时的自动类型转换
- sql-server - 数据库项目中的 SQL Server 存储过程错误 [Visual Studio]
- python - 使用 Pandas 删除特定行时出错
- mysql - Magento 2 - 违反完整性约束:1062 重复条目 - 设置错误:从社区升级到企业后升级
- android - Android - 从代码更改微调器的字体大小
- python - 发布到 Google Analytics,在 Node 上工作,在 Python 上失败......为什么?
- django - Django - 用户个人资料视图和编辑个人资料视图的 URL 问题
- visual-studio-code - VSCode 扩展有 golang.go,但没有 ms-vscode.go
- git - git:部分恢复文件的先前版本