-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
RevisitAn issue worth coming back toAn issue worth coming back toSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 2.6.1
Code
let func = () => "func";
+func; // no error
-func; // no error
let obj = { foo: "bar" };
+obj; // no error
-obj; // no errorExpected behavior:
Unary + or - is only applicable to a number or maybe a string. I would expect the lines listed as // no error to be errors.
Actual behavior:
Unary + and - never generates a warning no matter what crazy stuff I try to apply it to.
I was made aware of this behavior by a recent Stack Overflow question. I see from #7019 that unary + and - on strings is supported, and I guess I can understand that as a way to parse a string into a number (for +, anyway. Is - really used like this in practice?). But functions? objects? Seems more likely to be an error than intentional to me. Thoughts?
lmcarreiro, jwbay, aluanhaddad, kujon, parkerault and 6 morefvilante
Metadata
Metadata
Assignees
Labels
RevisitAn issue worth coming back toAn issue worth coming back toSuggestionAn idea for TypeScriptAn idea for TypeScript