You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.)
Check typeof result === "function" for class decorators
// Original
@decoratorclassC{}// CurrentclassC{}C=decorator(C)||C// ProposedclassC{}let%temp=decorator(C)if(typeof%temp==="function")C=%temp
Check typeof result === "object" for method and accessor decorators.
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.)Check
typeof result === "function"
for class decoratorsCheck
typeof result === "object"
for method and accessor decorators.The text was updated successfully, but these errors were encountered: