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

fix(bindCallback): add better type overloads #3480

Merged
merged 1 commit into from
Mar 29, 2018

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Mar 27, 2018

This is currently blocked, as it doesn't seem that TypeScript can really handle inferring types here like I hoped it could

@cartant
Copy link
Collaborator

cartant commented Mar 27, 2018

Have you tried re-ordering the signatures so that those with the most parameters precede those with fewer parameters? The most specific signatures should come first.

I saw the issue you created and it looked to me like your approach would be fine.

This seemed similar to something that bit me a few months ago, but it appears that re-ordering won't help, here.

@benlesh
Copy link
Member Author

benlesh commented Mar 28, 2018

Blocked by microsoft/TypeScript#22952

@cartant
Copy link
Collaborator

cartant commented Mar 28, 2018

@benlesh I think you can disregard the amendment I made to the comment above. It most likely is only the ordering that's the problem.

I messed up my minimal repro and bound a generic function:

declare function func<T>(callback: (t: T) => void): void;
declare function bindCallback<T>(f: (callback: (t: T) => void) => void): T;
const result = bindCallback(func); // inferred as {}

I'm such a doofus. 😬

This is currently blocked, as it doesn't seem that TypeScript can really handle inferring types here like I hoped it could
@benlesh benlesh force-pushed the bindCallback-improved-typing branch from 4112fc3 to beccf84 Compare March 29, 2018 18:58
@benlesh benlesh removed the blocked label Mar 29, 2018
@benlesh benlesh merged commit 037cf34 into ReactiveX:master Mar 29, 2018
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants