Support for overloading a typed method signature based on parameter value.

Topics: Language Specification
Oct 2, 2012 at 12:03 AM

For a description of what I mean, let me link the SO post I made:

http://stackoverflow.com/questions/12679888/how-would-you-use-typescript-to-improve-the-type-ahead-and-type-checking-for-jqu

Maybe via some sort of pattern matching? Would be very useful for jQuery UI. 

-Graham

Oct 2, 2012 at 12:50 AM

I think this was covered in Anders' video.  You can use a 'declaration' TS file that specifies the valid range of inputs.  He demonstrated a JQuery UI plugin.

Oct 2, 2012 at 4:23 AM

Did you see my Stack Overflow post? My question is a bit more complicated than just the basic JQuery UI Support in that sample.

Oct 4, 2012 at 4:47 AM

I see this has been answered on StackOverflow (namely you can't override the type of parameter X based on the value of a parameter Y).  We are aware of the use-cases this ability would have (especially me as I wrote the jQueryUI typing in the sample referred to :-) ), and have discussed it internally.  It's on our radar. (But no promises yet!).

Thanks.