Skip to content

callback inside generated object type doesn't allow implicit arguments types #30238

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

Closed
cevek opened this issue Mar 6, 2019 · 4 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@cevek
Copy link

cevek commented Mar 6, 2019

TypeScript Version: 3.4.0-dev.20190223

Search Terms:

Code

declare function x<T>(obj: T, args: {[P in keyof T]: (arg: number) => void}): void;
x({get: 1}, {get: arg => arg + 1});
// Parameter 'arg' implicitly has an 'any' type.

Expected behavior:

Actual behavior:

Playground Link:

Related Issues:

@dragomirtitian
Copy link
Contributor

Just as a workaround you can do the following:

declare function x<T>(obj: T, args: Record<keyof T, (arg: number) => void> & Record<string, (arg: number) => void>): void;
x({ get: 1 }, { get: arg => arg + 1 });

arg would be correctly inferred but you will still get errors if the key was not in T.

@cevek
Copy link
Author

cevek commented Mar 6, 2019

Yeah, but I want something more complex, this example just a repro
for example arg should be ReturnType<T[P]>

@yortus
Copy link
Contributor

yortus commented Mar 7, 2019

Duplicate of #24694? There's a PR to fix it, to be discussed 'next week' on the Design Meeting Docket - but I think it's been on 'next week' for quite a few weeks now.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 7, 2019
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants