-
Notifications
You must be signed in to change notification settings - Fork 221
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
upgrade to ts 1.7.3 #3010
upgrade to ts 1.7.3 #3010
Conversation
@@ -72,7 +72,7 @@ module Plottable.Animators { | |||
* @param {number} startDelay The start delay in milliseconds. | |||
* @returns {Easing} The calling Easing Animator. | |||
*/ | |||
public startDelay(startDelay: number): Easing; | |||
public startDelay(startDelay: number): this; | |||
public startDelay(startDelay?: number): any { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are so many method return types annotated as any
? shouldn't it be Easing | number
here (or this | number
with TS 1.7.3)? was this code never updated to use union types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This last signature is the implementation, and has to be assignable to any of the previous signatures (called "overloads"), according to the spec:
When a function has overload declarations, the overloads determine the call signatures of the type given to the function object and the function implementation signature (if any) must be assignable to that type.
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#61-function-declarations
The problem is that number | this
isn't assignable to either number
or this
according to the casting rules, so you'll get a compiler error ("Overload signature is not compatible with function implementation.
"). We can't simply leave out the any
either, because that causes the error "No best common type exists among return expressions.
" Typescript's handbook includes an example where the implementation signature returns any
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, makes sense. looks like a shortcoming of TypeScript if we have to use any
so much to achieve the nice typings for getter/setter methods like this.
@ztsai There's some that were left out:
I'd do a global search for " |
No description provided.