输入'{ id: number; }' 不满足约束 '{ id?: string; }'
Type '{ id: number; }' does not satisfy the constraint '{ id?: string; }'
基于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.
这是一个节点依赖项引入的重大更改,它不使用固定版本的依赖项(@types/react-router
的新版本需要字符串而不是数字)。最新版本的 JHipster 已修复此问题。
要在您的项目中解决它,请升级 generator-jhipster
并重新生成您的实体。如果您更喜欢手动修复它,请修复所有扩展 RouteComponentProps
的 React 组件,以便为 id
使用 string
道具,例如 in this commit
基于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.
这是一个节点依赖项引入的重大更改,它不使用固定版本的依赖项(@types/react-router
的新版本需要字符串而不是数字)。最新版本的 JHipster 已修复此问题。
要在您的项目中解决它,请升级 generator-jhipster
并重新生成您的实体。如果您更喜欢手动修复它,请修复所有扩展 RouteComponentProps
的 React 组件,以便为 id
使用 string
道具,例如 in this commit