This is more of a TypeSc…

1 minute read

This is more of a TypeScript questions, hoping someone has some insight, is there a way to determine if a property has a decorator attached to it (in this case @Input) when declaring a type?

export type NonInputProps<T> = Exclude<T, "@input decorated props"> or the inverse only the @Input props

Not sure if this is possible as I believe decorators are compiled down to metadata on the property once it is compiled using reflect metadata?


i dont think with default TypeScript. You could probably extend the language service to do those checks

*It’s not for the faint of heart

Extending the language service sounds like a lot of work :laughing: But I will look into it! Thanks Jon! I have been wanting to create a generic Type for Angulars SimpleChanges so that you get type checking on the props that actually change (@Inputs). There have been multiple PRs opened about it but none get it completely right, I have tried myself but got stuck on it suggesting props that aren’t inputs but just member variables on the class itself :disappointed:

I don’t think a plugin will work TypeScript Language Service Plugins ("plugins") are for changing the _editing experience_ only. The core TypeScript language remains the same. Plugins can't add new language features such as new syntax or different typechecking behavior... maybe I will try and contirbute to TypeScript itself then.

Ahh ok