Hookyns / tst-reflect

Advanced TypeScript runtime reflection system
MIT License
338 stars 11 forks source link

Unable to access parameter decorators #72

Closed avin-kavish closed 1 year ago

avin-kavish commented 2 years ago
function a(obj: Object, key: string, prop: number) {}

class Foo {
  boo?: boolean | null

  foo(@a x: string) {}
}

console.dir(
  getType<Foo>()
    .getMethods()
    .map(p => p.getParameters().map(p => p.type.getDecorators())),
)

Returns empty, I think getDecorators should be on the parameter itself and not the type?

Hookyns commented 2 years ago

You are accessing decorators of the type, ie. you are accessing decorators of the string type, which has no decorators. There are no parameter decorators yet.

Hookyns commented 2 years ago

Implemented for the v1. Not in the current version.