Skip to content

fix(bindCallback): add better type overloads#3480

Merged
benlesh merged 1 commit into
ReactiveX:masterfrom
benlesh:bindCallback-improved-typing
Mar 29, 2018
Merged

fix(bindCallback): add better type overloads#3480
benlesh merged 1 commit into
ReactiveX:masterfrom
benlesh:bindCallback-improved-typing

Conversation

@benlesh

@benlesh benlesh commented Mar 27, 2018

Copy link
Copy Markdown
Member

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

@cartant

cartant commented Mar 27, 2018

Copy link
Copy Markdown
Collaborator

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

benlesh commented Mar 28, 2018

Copy link
Copy Markdown
Member Author

Blocked by microsoft/TypeScript#22952

@cartant

cartant commented Mar 28, 2018

Copy link
Copy Markdown
Collaborator

@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

lock Bot commented Jun 6, 2018

Copy link
Copy Markdown

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