【问题标题】:Cannot find name of exported Interface找不到导出接口的名称
【发布时间】:2017-02-19 23:33:55
【问题描述】:

我在导出界面时遇到问题... 我在 my-config.ts 中这样定义它:

export interface MyConfig{
  useTitleSuffix: boolean;
  defaults: {};
}

我在 index.ts 中像这样导出它

export { MyConfig} from './my-config';
export { MyService } from './my.service';
export { MyModule } from './my.module';

当我像这样在另一个模块中导入它时:

import { MyConfig, MyModule } from 'my-module';

然后会找到 MyService 和 MyModule,但没有找到 MyConfig。 “找不到名称 'MyConfig'”...

有人有想法吗?

【问题讨论】:

  • 你确定你的路径是正确的吗?看来它必须是 export { MyConfig} from './my.config';
  • 路径绝对正确...

标签: angular typescript interface module


【解决方案1】:

(对不起,我还不能发表评论,所以我写了这个作为答案)
假设所有文件名都是正确的,我能想到的唯一真正的可能性是界面使用中的拼写错误。

对应行的完整错误(即来自 tsc)有助于锁定问题。

另外,如果这是一个 IDE 错误,请知道 VSCode 在您创建新文件时会显示这些错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-23
    • 2017-04-12
    • 2018-05-15
    • 2021-04-15
    • 2020-06-19
    • 2017-08-14
    • 1970-01-01
    • 2019-02-20
    相关资源
    最近更新 更多