Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

装饰器 #77

Open
gogoend opened this issue Sep 17, 2022 · 0 comments
Open

装饰器 #77

gogoend opened this issue Sep 17, 2022 · 0 comments
Labels
5% 写作进度 5% es

Comments

@gogoend
Copy link
Owner

gogoend commented Sep 17, 2022

类装饰器

/**
 * @param { TFunction } target 被装饰的类
 */
type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;

属性装饰器

/**
 * @param { TFunction } target 被装饰的类
 * @param { string | symbol } propertyKey 属性的key
 */
type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;

方法装饰器

/**
 * @param { TFunction } target 被装饰的方法
 * @param { string | symbol } propertyKey 方法的key
 * @param { TypedPropertyDescriptor<T> } descriptor 属性描述符
 */
type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;

参数装饰器

/**
 * @param { TFunction } target 被装饰的方法
 * @param { string | symbol } propertyKey 方法的key - 若被装饰的参数位于constructor,此处key将为`undefined`
 * @param { number } parameterIndex 参数所在索引
 */
type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
@gogoend gogoend added es 5% 写作进度 5% labels Sep 17, 2022
@gogoend gogoend changed the title 装饰器、reflect-metadata、TypeScript 装饰器 Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5% 写作进度 5% es
Projects
None yet
Development

No branches or pull requests

1 participant