-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Mapped inference types do not work as I understand #21765
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I think you want |
You might have better luck sharing this on StackOverflow. This is not a support forum, it is one for reporting compiler/language bugs and suggestions. |
Here's the code that can work: type NS<T, P extends keyof T> = {
[U in keyof T]: T[P]
} but I want to get their flattened values because I have this code: function getFieds({
a: true,
q: true
}, function(res) {
res.s // string
res.n // boolean
res.w // number
res.h // number
}); or function getFieds(['a', 'q'], function(res) {
res.s // string
res.n // boolean
res.w // number
res.h // number
}); The first argument's subkey is unknown. I need to write its declaration file for this js function.But I think this should also work it: type NS<T, P extends keyof T> = {
[U in keyof T[P]]: T[P][U]
}
function getFieds<T>(options: T, callback: (res: NS<MapType , keyof T>) => void ): void; It typescript can solve this problem it? |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
Directly show my code, the text description may not be clear.
From the callback function used in the parameters
TypeScript Version: 2.6.2
Code
Expected behavior:
Actual behavior:
Playground Link:
Related Issues:
I think this is very helpful to me,But did not solve my problem.
17930
The text was updated successfully, but these errors were encountered: