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.)
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> | voidfor 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:
%variablerefers to an internal variable here.)Check
typeof result === "function"for class decoratorsCheck
typeof result === "object"for method and accessor decorators.