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

strange non error implementing interface #370

Closed
lucamorelli opened this issue Aug 6, 2014 · 2 comments
Closed

strange non error implementing interface #370

lucamorelli opened this issue Aug 6, 2014 · 2 comments
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead

Comments

@lucamorelli
Copy link

Hi,
honestly I don't know if this is an issue, but I just noticed this using vs 2013 update 3 rtm

I have this interface

export interface ISoluzioniService {       
    ...       
    alberoSoluzione(idSoluzione: number, idPalmare: number);       
}

and a class that implements it this way

export class SoluzioniService implements Interfaces.ISoluzioniService {
    public alberoSoluzione() {
        var workUrl = this.GetBaseUrl();
        workUrl += "ListaSoluzioni";
        var deferred = this.q.defer();
    }
    ...

if I remove the implementation of the alberoSoluzione method int the class an error is given because the interface is not implemented, but if I add, like in this case, an implementation of the method with a different number of parameters no error is given.
Is this normal?

thanks,
luca

@basarat
Copy link
Contributor

basarat commented Aug 6, 2014

Is this normal?

yes. But not the other way around : https://github.com/Microsoft/TypeScript/wiki/Type-Compatibility#comparing-two-functions

interface ISoluzioniService {              
    alberoSoluzione(a:number);       
}

class SoluzioniService implements ISoluzioniService {
    public alberoSoluzione(a:number,b:number) { // ERROR
    }
}

Basically it is safe to call a function that expects fewer parameters with more arguments but not the other way around.

@lucamorelli
Copy link
Author

ok, thanks

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead
Projects
None yet
Development

No branches or pull requests

3 participants