【问题标题】:Type '{ id: number; }' does not satisfy the constraint '{ id?: string; }'键入'{ id:数字; }' 不满足约束 '{ id?: string; }'
【发布时间】:2018-09-18 20:25:24
【问题描述】:

基于Matt Raible's article,我创建了一个应用程序,除了身份验证类型和开发数据库之外,它具有相同的 JHipster 选项。使用他的 JH 实体文件,我收到以下错误

error  in /home/me/workspace/gallery/src/main/webapp/app/entities/album/album-delete-dialog.tsx

ERROR in /home/me/workspace/gallery/src/main/webapp/app/entities/album/album-delete-dialog.tsx(12,97):
TS2344: Type '{ id: number; }' does not satisfy the constraint '{ id?: string; }'.
  Types of property 'id' are incompatible.
    Type 'number' is not assignable to type 'string'.

在我看来,JHipster 中存在错误。我使用的是最新版本 5.2.1。

【问题讨论】:

    标签: jhipster


    【解决方案1】:

    这是由其中一个节点依赖项引入的一项重大更改,该节点依赖项不使用固定版本作为其依赖项(@types/react-router 的新版本需要字符串而不是数字)。 JHipster 的最新版本已修复此问题。

    要在您的项目中解决它,请升级 generator-jhipster 并重新生成您的实体。如果您更喜欢手动修复它,请修复所有扩展 RouteComponentProps 的 React 组件,以使用 string 属性来支持 id,例如 in this commit

    JHipster Dev Group Discussion

    【讨论】:

    • 感谢您的信息。我运行升级命令“yarn global upgrade generator-jhipster”。该命令运行正常,没有任何错误,但是 jhipster 由于某种原因没有升级。
    • 您可能同时安装了 npmyarn,尝试从两者中删除它,然后只安装一个
    猜你喜欢
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多