在 d.ts 中通过 import 声明模块依赖第三方模块时,Vscode 提示“找不到模块”,有什么解决办法吗?
tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"target": "es5",
"lib": ["esnext", "dom.iterable","dom", "scripthost", "es2015.symbol"],
"sourceMap": true,
"noImplicitAny": true,
"jsx": "react",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowJs": true,
"module": "commonjs",
"isolatedModules": false,
"esModuleInterop": true
},
"include": ["src/**/*","typings/*"],
"exclude": ["node_modules"]
}
Run Code Online (Sandbox Code Playgroud)
打字/index.d.ts
{
"compilerOptions": {
"outDir": "./dist/",
"target": "es5",
"lib": ["esnext", "dom.iterable","dom", "scripthost", "es2015.symbol"],
"sourceMap": true,
"noImplicitAny": true,
"jsx": "react",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowJs": true,
"module": "commonjs",
"isolatedModules": false,
"esModuleInterop": true
},
"include": …Run Code Online (Sandbox Code Playgroud) If I want to validate the role which user post to api to create if is unique of relation enterprise
@Injectable({ scope: Scope.REQUEST })
@ValidatorConstraint({ name: 'Ddd', async: true })
export class IsUnqiueForEnterpriseConstraint implements ValidatorConstraintInterface {
constructor(@Inject(REQUEST) private request: Request) {}
async validate(value: any, args: ValidationArguments) {
const { enterprise } = this.request.user as any
const { model } = args.constraints[0] as IParams;
if(!enterprise) return false;
if (!model) return false;
const repo = getManager().getRepository(model as ObjectType<any>);
const item = await …Run Code Online (Sandbox Code Playgroud)