本文整理汇总了TypeScript中@tsed/core.getDecoratorType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getDecoratorType函数的具体用法?TypeScript getDecoratorType怎么用?TypeScript getDecoratorType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDecoratorType函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {
switch (getDecoratorType(args, true)) {
case "method":
return Store.decorate((store: Store) => {
store.set(guardAuth, options);
if (options.responses) {
const {responses} = options;
store.merge("responses", responses);
}
if (options.security) {
const {security} = options;
store.merge("operation", {security});
}
return UseBefore(guardAuth);
})(...args);
case "class":
decorateMethodsOf(args[0], UseAuth(guardAuth, options));
break;
default:
throw new UnsupportedDecoratorType(UseAuth, args);
}
};
示例2:
return <T>(target: Type<any>, targetKey?: string, descriptor?: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
if (getDecoratorType([target, targetKey, descriptor]) === "method") {
EndpointRegistry.useAfter(target, targetKey!, args);
return descriptor;
}
Store.from(target).merge("middlewares", {
useAfter: args
});
};
示例3: return
return (...args: any[]) => {
const type = getDecoratorType(args);
switch (type) {
case "method":
return Operation({title})(...args);
case "parameter":
return BaseParameter({title})(...args);
default:
originalTitleDecorator(title)(...args);
}
};
示例4: return
return (...parameters: any[]) => {
switch (getDecoratorType(parameters)) {
case "property":
return PropertyRegistry.decorate((propertyMetadata: PropertyMetadata) => {
propertyMetadata.store.merge(MONGOOSE_SCHEMA, options as SchemaTypeOpts<any>);
})(...parameters);
case "class":
const [target] = parameters;
createSchema(target, options as MongooseSchemaOptions);
break;
}
};
示例5: return
return (...args: any[]) => {
const type = getDecoratorType(args);
switch (type) {
case "parameter":
return BaseParameter({name})(...args);
case "class":
Store.from(...args).set("name", name);
break;
default:
throw new Error("Name is only supported on parameters and class");
}
};
示例6: return
return (...args: any[]) => {
const type = getDecoratorType(args);
switch (type) {
case "parameter":
return BaseParameter({description})(...args);
case "method":
return Operation({description})(...args);
case "class":
Store.from(...args).set("description", description);
default:
Schema({description})(...args);
}
};
示例7: return
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
const type = getDecoratorType([target, propertyKey, descriptor], true);
switch (type) {
default:
throw new Error("MulterOptions is only supported on method");
case "method":
Store.fromMethod(target, propertyKey).merge(MultipartFileMiddleware, {
options
});
return descriptor;
}
};
示例8: return
return (...args: any[]) => {
if (getDecoratorType(args) === "method") {
fn = args[0][args[1]].bind(args[0]);
}
applySchemaOptions(args[0], {
post: [
{
method,
fn: fn as MongoosePostHookCB<any> | MongoosePostErrorHookCB<any>
}
]
});
};
示例9: return
return (...args: DecoratorParameters) => {
const type = getDecoratorType(args, true);
switch (type) {
case "method":
return Store.decorate((store: Store) => {
store.merge("responses", {[status]: response});
})(...args);
case "class":
decorateMethodsOf(args[0], Responses(status, response));
break;
default:
throw new UnsupportedDecoratorType(Responses, args);
}
};
示例10: return
return (...args: DecoratorParameters) => {
const type = getDecoratorType(args, true);
switch (type) {
case "method":
return Store.decorate((store: Store) => {
store.merge("operation", operation);
})(...args);
case "class":
decorateMethodsOf(args[0], Operation(operation));
break;
default:
throw new UnsupportedDecoratorType(Operation, args);
}
};