-
Notifications
You must be signed in to change notification settings - Fork 12.8k
error TS2365: Operator '+' cannot be applied to types 'string | number' and 'string | number'. #49661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Operations are evaluated according to the types of their operands, not their identities. The left-hand type is |
Experienced something similar. function universalAdd(monoid1: string|number){
return monoid1 + monoid1;
} It took me sometime to understand your statement "types of their operands, not their identities". But I got it thanks @RyanCavanaugh |
can we close this issue already? |
I'm sorry but I'm still not clear on the problem here. If I replace the union type of Thank you! |
If you are sure about the type by type guard operator "typeof". and then assume the type using "as" |
Bug Report
Code does not compile.
🔎 Search Terms
"Operator '+' cannot be applied to types".
🕗 Version & Regression Information
4.7.4
💻 Code
🙁 Actual behavior
🙂 Expected behavior
No error.
The text was updated successfully, but these errors were encountered: