-
Notifications
You must be signed in to change notification settings - Fork 12.8k
ReturnType break the original funtion return type if function is method of a class #42706
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
Comments
Please provide a repro that is both short and self-contained. We cannot investigate repros this large. |
Sure, sorry that the previous repro contains some code from npm package type-fest. I update the link, think this one is short enough: |
Shortened type Promisify<T> = T extends (...args: infer A) => infer R ? (...args: A) => Promise<R> : never;
type PromiseProxify<OriginalProxy> = {
[P in keyof OriginalProxy]: Promisify<OriginalProxy[P]>;
};
interface IConstants {
isDevelopment: boolean;
platform: string;
environmentVersions: { a: 3, b: 4 };
}
interface IContextService {
get<K extends keyof IConstants>(key: K): IConstants[K];
}
declare const m: PromiseProxify<IContextService>;
const ggg = m.get("platform"); The type expression |
Okay, should I keep this issue open? Will you reconsider this usage in the future? I think I will manually |
I think this is pretty unlikely to change unless we collect new use cases around generic synthesis, or redo inference completely (oh no). |
For posterity, this is essentially a duplicate of #39594 and I have posted a use case and some proposals over there |
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
π Search Terms
ReturnType method
ReturnType extends keyof
π Version & Regression Information
"typescript": "4.1.3",
β― Playground Link
Playground Link
π» Code
π Actual behavior
ReturnType gives Union of all
ReturnType<OriginalProxy[P]>
π Expected behavior
I hope it can give me the exact ReturnType for each method, so I can get async version of all class method.
The text was updated successfully, but these errors were encountered: