Hi,
Version: VS 2015/TS 1.6.2
There are few issues with intellisense in the following snippet
const f = (foo: (bar: string[]) => void) => { };
f(a=> {
const aa = a[0];
aa.charAt(0); // Okay: inferred as string
});
f(([a, b]) => {
a.charAt(0); // Not okay: inferred as `any`
});
Points to note:
- Hovering over
[a, b] in the very last function call shows the type of a to be any and the type of b to be string.
- Furthermore, this is not constant. Adding
b.charAt(0); to the function body, and then hovering over a, b shows a to be string and b to be any.
- In either case, there is no completion for either
a or b, when they are dotted off.
This is only a problem with quick info and completion. If I were to change the function to have a number array parameter
const f = (foo: (bar: number[]) => void) => { };
Then all charAt calls are underlined in red as expected and the file fails to compile.
Hi,
Version: VS 2015/TS 1.6.2
There are few issues with intellisense in the following snippet
Points to note:
[a, b]in the very last function call shows the type ofato beanyand the type ofbto be string.b.charAt(0);to the function body, and then hovering overa, bshowsato be string andbto beany.aorb, when they are dotted off.This is only a problem with quick info and completion. If I were to change the function to have a number array parameter
Then all
charAtcalls are underlined in red as expected and the file fails to compile.