We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The following code break the intelisense for TS.
export function get<T, K1 extends keyof T, K2 extends keyof T[K1]>( obj: T, keys: [K1, K2] ): T[K1][K2]; export function get< T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2] >(obj: T, keys: [K1, K2, K3]): T[K1][K2][K3]; export function get(obj: any, keys: any[]): any { for (const key of keys) obj = obj[key]; return obj; }
These are the TS suggestions
However, they are wrong, because the third value needs to be property of the object on path 'a.b', precisely only value 'c'.
'a.b'
'c'
The typings are correct, because intelisense is able to infer the result
Furthemore, it rejects all values except 'c', which means the intelisense should be able to provide correct suggestions.
The text was updated successfully, but these errors were encountered:
Tested with [email protected]
Complete example:
export function get<T, K1 extends keyof T, K2 extends keyof T[K1]>( obj: T, keys: [K1, K2] ): T[K1][K2]; export function get< T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2] >(obj: T, keys: [K1, K2, K3]): T[K1][K2][K3]; export function get(obj: any, keys: any[]): any { for (const key of keys) obj = obj[key]; return obj; } const obj = { a: { b: { c: 'x ' } } } get(obj, ["a", 'b', ''])
Sorry, something went wrong.
I'm interested to try on this one. Maybe some pointers where I should start looking into?
No branches or pull requests
The following code break the intelisense for TS.
These are the TS suggestions
![bad_intelsense1](https://user-images.githubusercontent.com/22679154/58330121-7c48f280-7e36-11e9-8806-5e7fd627e7f2.png)
However, they are wrong, because the third value needs to be property of the object on path
'a.b'
, precisely only value'c'
.The typings are correct, because intelisense is able to infer the result
![bad_intellisense2](https://user-images.githubusercontent.com/22679154/58330300-e3ff3d80-7e36-11e9-82d9-5ccff813628e.png)
Furthemore, it rejects all values except
![bad_intelisense3](https://user-images.githubusercontent.com/22679154/58330577-730c5580-7e37-11e9-9a30-acef792d456f.png)
'c'
, which means the intelisense should be able to provide correct suggestions.The text was updated successfully, but these errors were encountered: