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

Type not suggested when implementing an interface's overloaded method #18384

Closed
bruce965 opened this issue Sep 11, 2017 · 2 comments
Closed

Type not suggested when implementing an interface's overloaded method #18384

bruce965 opened this issue Sep 11, 2017 · 2 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@bruce965
Copy link

TypeScript Version: 2.5.2 / nightly (2.6.0-dev.20170910)

Code

interface MyInterface {
	exec(action: 'action_1'): void;
	exec(action: 'action_2'): void;
	exec(action: string): void;
}

const test: MyInterface = {
	exec(arg) {
		// `arg` type is `any`
	}
};

Expected behavior:

I would expect arg type to be "action1"|"action2"|string.

Actual behavior:

arg type is any.

@mhegazy
Copy link
Contributor

mhegazy commented Sep 11, 2017

Contextual types do not flow from overloads. this issue has been reported in #16019 and there is a proposed change for it in #17819

@mhegazy mhegazy added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Sep 11, 2017
@RyanCavanaugh
Copy link
Member

Declining due to lack of interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants