node.js - ES2017 NEST JS @IsEmpty 在作为表达式调用时无法解析属性装饰器的签名。此表达式不可调用。不为空
问题描述
大家好,我是 Nest JS 的新手,我尝试添加 dto 验证器,但例如当我尝试添加 isNotEmpty 或 Max 编译器时,会显示此错误:
当作为表达式调用时,无法解析属性装饰器的签名。此表达式不可调用。
DTO:
import { Transform, Type } from 'class-transformer';
import { IsInt, isNotEmpty } from 'class-validator';
export class MessagesQueryDTO {
@isNotEmpty()
@IsInt()
@Type(() => Number)
readonly limit: number;
@isNotEmpty()
@Type(() => Number)
@IsInt()
readonly skip: number;
}
我的 config.json
{
"exclude": ["**/*spec.ts"],
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"esModuleInterop": true,
}
}
解决方案
isNotEmpty 装饰器应该是 IsNotEmpty,首字母大写。
推荐阅读
- php - vcs 子文件夹中的 Composer 包 - 如何引用?
- javascript - 将 TypeScript 参数类型编译为 JS 类型检查?
- android - 添加新插件后 Unity 游戏错误
- android - 声池音量级别
- node.js - 编译后在 Electron 子进程上访问 Node 模块
- database - 无法弄清楚为什么 oracle 数据库需要更多时间来插入全部
- laravel - Laravel 急切加载为空,具有多态关系
- c# - 防止对象在流畅的构建器模式C#中实例化
- android - ViewModel 在权限更改中被清除
- laravel - 如何在 Laravel nova 中的索引上显示降价字段?