mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
修复 @param 在类扩展时作用域污染的问题,完善interface
This commit is contained in:
1 parent
cd6938dd6c
commit
dd7914e1fb
31 files changed
+269
-179
No files matched your search
@@ -138,12 +138,13 @@ export function param(...args: any): MethodDecorator {
|
||||
}
|
||||
return function desc(target: any, funcName: string, obj: any) {
|
||||
if (!target.__param) target.__param = {};
|
||||
if (!target.__param[funcName]) {
|
||||
target.__param[funcName] = [{ name: 'domainId', type: 'string' }];
|
||||
if (!target.__param[target.constructor.name]) target.__param[target.constructor.name] = {};
|
||||
if (!target.__param[target.constructor.name][funcName]) {
|
||||
target.__param[target.constructor.name][funcName] = [{ name: 'domainId', type: 'string' }];
|
||||
const originalMethod = obj.value;
|
||||
obj.value = function func(rawArgs: any) {
|
||||
const c = [];
|
||||
const arglist: ParamOption[] = this.__param[funcName];
|
||||
const arglist: ParamOption[] = this.__param[target.constructor.name][funcName];
|
||||
for (const item of arglist) {
|
||||
if (!item.isOptional || rawArgs[item.name]) {
|
||||
if (!rawArgs[item.name]) throw new ValidationError(item.name);
|
||||
@@ -160,7 +161,7 @@ export function param(...args: any): MethodDecorator {
|
||||
return originalMethod.call(this, ...c);
|
||||
};
|
||||
}
|
||||
target.__param[funcName].splice(1, 0, ...d);
|
||||
target.__param[target.constructor.name][funcName].splice(1, 0, ...d);
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user