Is it possible in TypeScript to implement a decorator @important and a utility type PickImportantProps in a way that type B becomes { b: string } in the following example?
Many thanks in advance :)
// decorator
function important(...): ... {
...
}
type PickImportantProps<T> = ...
class A {
a = 'a'
@important()
b = 'b'
}
type B = PickImportantProps<A> // <= should result in { b: string }
At the moment it isn't possible to get this information at compile-time.
The answer to this question shows a possible workaround that essentially gives up the decorator syntax (
@decoratorName).