我已经在 Project A (主库)中创建了一个装饰器,并希望在应用程序在 Project B 中启动时自动加载所有这些装饰器(使用项目A)进行项目。反正有这样做吗?
index.ts 看起来像这样:
export function MyDecorator<T extends Controller>() {
return (target: new () => T) => {
// Do stuff with the decorator
}
}
const server = http.createServer((req,res) => {
})
server.listen(8080)
是否可以执行项目B 中的所有类上的@MyDecorator()
自动执行操作,而不必执行项目B ?
MyClass1.ts
import { MyDecorator } from 'project-a'
@MyDecorator()
export class ProjectBClass1 {}
MyClass2.ts
import { MyDecorator } from 'project-a'
@MyDecorator()
export class ProjectBClass2 {}