如何實現(xiàn)打字稿裝飾器?TypeScript 1.5現(xiàn)在有裝飾器。有人可以提供一個簡單的例子來演示實現(xiàn)裝飾器的正確方法,并描述可能的有效裝飾器簽名中的參數(shù)是什么意思嗎?declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;另外,在實現(xiàn)裝飾器時是否應(yīng)該記住哪些最佳實踐注意事項?
如何實現(xiàn)打字稿裝飾器?
小怪獸愛吃肉
2019-08-14 17:28:22