Description
TypeScript Version: 2.8.1
VS Code Version:
Version 1.22.2
Commit 3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9
Date 2018-04-12T16:38:45.278Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
Search Terms:
useCapture
addListener
lib.dom.d.ts
Code
const htmlElement: HTMLDivElement;
htmlElement.addEventListener("scroll", event => console.log(event), true);
Before entering the last parameter (just after writing the last comma in the editor):
htmlElement.addEventListener("scroll", event => console.log(event), <----- When the cursor is here
I get code completion that looks like this:
And the second overload:
It is very confusing to see options?: boolean
part not as a separate overload, but as a smushed definition of:
options?: boolean | AddEventListenerOptions | undefined
Expected behavior:
To have separate overloads for boolean
version and AddEventListenerOptions
one, as seen in CodeSandbox (Playground link).
Actual behavior:
Described above.
Playground Link:
https://codesandbox.io/s/r0l6j9olpn
Related Issues:
Didn't find.
The interesting thing is that while trying to reproduce the issue in CodeSandbox, I got exactly what I wanted to see: useCapture: boolean | undefined
So, my question is why does VS Code have a version of types that is confusing and can also be found here:
https://github.com/Microsoft/TypeScript/blob/master/lib/lib.dom.d.ts#L5450
And why CodeSandbox has a proper one? And how can we solve this?
Is this VS Code's bug or the lib.dom.d.ts
bundled with TypeScript is simply out-of-date?