NoHomey / bind-decorator

The fastest automatic method.bind(this) decorator
MIT License
68 stars 11 forks source link

Question: syntax #7

Closed alexsasharegan closed 6 years ago

alexsasharegan commented 6 years ago

Thanks for the useful decorator! I was hoping you could explain the syntax at the line below, specifically the usage of the negation operator. It looks like it's being used as an existential operator, but that follows a different syntax. Just trying to demystify this so I can understand more about writing my own decorators.

https://github.com/NoHomey/bind-decorator/blob/master/src/index.ts#L14

NoHomey commented 6 years ago

It's to ensure type validity since TypedPropertyDescriptor<T>.value is optional value of type T.

alexsasharegan commented 6 years ago

Ah! Finally found it! Thanks for helping me learn a new TS trick!

image