【发布时间】:2022-08-11 15:51:41
【问题描述】:
在数据库(MySQL)中,价格定义为decimal,然后我使用tRPC 获取数据,当我想使用它显示错误的值时。
Types of property \'price\' are incompatible.
Type \'Decimal | null\' is not assignable to type \'number\'.
Type \'null\' is not assignable to type \'number\'.
我试图找到我可以定义十进制但只找到数字的类型。
棱镜:
model project{
price Decimal? @db.Decimal(19, 4)
...
}
前端
type projectType = {
price:number
...
}
临时使用任何类型来跳过错误。 如何解决这个问题呢?
-
你要么有
number要么有BigInt
标签: typescript