wycats / javascript-decorators

2.4k stars 127 forks source link

Reuse original decorator only if not `Type(result) is Object` for methods, etc. #68

Open dead-claudia opened 8 years ago

dead-claudia commented 8 years ago

The current specification relies on truthiness to determine whether to keep the decorator, but I think it might be a little cleaner to spec out checking the result of calling the decorator, instead of relying on truthiness. TypeScript already follows this logic itself, where it requires TypedPropertyDescriptor<T> | void for the return type. This change would also put it more in line with the rest of the spec.

A few minimal examples to demonstrate:

(Note: %variable refers to an internal variable here.)