【问题标题】:Ngrx, Ionic2 error "Return type of exported function has or is using name from external module.."Ngrx,Ionic2 错误“导出函数的返回类型具有或正在使用来自外部模块的名称..”
【发布时间】:2016-11-09 21:17:02
【问题描述】:

我将我的项目从 Ionic2 Beta11 更新到 RC0。我还将ngrx/store 更新到了最新版本(2.2.1)。一切正常,但我的减速器 index.ts 出现错误:

Return type of exported function has or is using name 'Post' from external module 'PathToPostInterface' but cannot be named.

我在以下函数中得到错误:

export function getPost(id: number) {
  return compose(fromPosts.getPost(id), getPostsState());
}

有没有人经历过同样的事情?我该如何解决这个问题?我想它与 TypeScript 有关,但由于我对它比较陌生,所以我不知道是什么......

【问题讨论】:

    标签: angular typescript redux ionic2 ngrx


    【解决方案1】:

    我设法通过将“Post”导入 index.ts 来解决问题。 但是我不知道为什么要解决它,因为该文件中的任何地方都没有使用“发布”...

    【讨论】:

      【解决方案2】:

      我猜是因为你在 tsconfig.json 中有声明:true。为此,编译器应该知道在哪里可以找到它。

      如果我不想在其他项目中使用它,它会按预期工作。即使这个函数的返回类型是正确的,导入到不同的项目中也会是any,所以不能使用,所以我必须在目标项目中创建reducer选择器而不是在存储项目中。有什么解决办法吗?

      【讨论】:

        猜你喜欢
        • 2017-09-06
        • 2018-07-09
        • 2017-02-13
        • 1970-01-01
        • 2017-02-23
        • 2017-10-09
        • 2019-08-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多