Skip to content
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

Operator/Operand overload checking issue #7408

Closed
tinganho opened this issue Mar 6, 2016 · 1 comment
Closed

Operator/Operand overload checking issue #7408

tinganho opened this issue Mar 6, 2016 · 1 comment

Comments

@tinganho
Copy link
Contributor

tinganho commented Mar 6, 2016

TypeScript should not give an error on the following case:

let diff = new Date() - new Date();

Because the Date objects has a valueOf method that will convert the Date object to a number value during arithmetic operations. Or any expression that expects a primitive type.

Source:
http://stackoverflow.com/questions/24764137/why-is-it-possible-to-subtract-date-objects-in-javascript-is-there-any-form-of

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf

@tinganho
Copy link
Contributor Author

tinganho commented Mar 6, 2016

Oops, already discussed in #5337 and #2361

@tinganho tinganho closed this as completed Mar 6, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant