2

Closed

string literal specilization in derived types

description

interface IBaseView {

    on(eventName: string, callback: () => void );
}
interface IDerivedView extends IBaseView {
    on(eventName: "click", callback: () => void );
}
the above code is showing error.

if u can permit "string literal specialization " in derived classes that will be awesome
Closed Jul 28 at 10:18 PM by jonturner
As part of our move to GitHub, we're closing our CodePlex suggestions and asking that people move them to the GitHub issue tracker for further discussion. Some feature requests may already be active on GitHub, so please make sure to look for an existing issue before filing a new one.

You can find our GitHub issue tracker here:
https://github.com/microsoft/typeScript/issues

comments

billti wrote Aug 6, 2013 at 9:56 PM

Thanks for the suggestion. As you may be aware, section 7.1 of the language spec is quite explicit that a signature hides the base type signature. We have had discussions on exactly the problem you outline, and we could make this experience better, but it does introduce some more significant changes to the language that we want to take right now.

I will assign this suggestion to Jonathan to track for consideration in future releases though. Thanks!

schungx wrote Aug 7, 2013 at 6:46 AM

Currently the only way to me is to duplicate the entire lot of overload-on-constant definitions for EVERY interface and class. This is a huge code bloat for overload-on-constant's and extremely prone to errors. Essentially, overload-on-constant is only useable on flat interfaces and classes not inheriting from anything.

So essentially the language spec says: Overload-on-constant and inheritance don't mix.