TypeScript-DOM-lib-generator icon indicating copy to clipboard operation
TypeScript-DOM-lib-generator copied to clipboard

`DOMStringList` missing iterator method

Open advaith1 opened this issue 3 years ago • 7 comments

TypeScript blocks using [...location.ancestorOrigins] with the error

Type 'DOMStringList' must have a '[Symbol.iterator]()' method that returns an iterator. ts(2488)

However, it is present in Chrome: image

advaith1 avatar Nov 26 '21 02:11 advaith1

It exists:

https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/2173711b06b303e39ba0c1c4a3c6921ba48f7616/baselines/dom.iterable.generated.d.ts#L37-L39

What does your tsconfig look like?

saschanaz avatar Dec 01 '21 12:12 saschanaz

here's the tsconfig: https://github.com/widgetbot-io/embed/blob/master/tsconfig.json

here are the DOMStringList definitions VSCode found:

image image

It's using VSCode's TS version (4.5.2) but I get the same error if I switch to the workspace version (4.2.2)

advaith1 avatar Dec 02 '21 18:12 advaith1

Ah sure, you also need to include "dom.iterable" next to "dom".

saschanaz avatar Dec 02 '21 18:12 saschanaz

@orta could this kind of thing be autosuggested? 🤔

saschanaz avatar Dec 02 '21 18:12 saschanaz

We've got a big chunk of checks in getCannotFindNameDiagnosticForName inside the compiler, (no point offering a link to the checker) but this can probably be added to that list. You have to manually set up your lib settings like this to trigger this case as the iteration version would be added by default if you include es2015/es6+ in your target

orta avatar Dec 02 '21 20:12 orta

Ah sure, you also need to include "dom.iterable" next to "dom".

Thanks, that worked! Is there a reason it isn't included in dom?

advaith1 avatar Dec 03 '21 00:12 advaith1

We've got a big chunk of checks in getCannotFindNameDiagnosticForName inside the compiler, (no point offering a link to the checker) but this can probably be added to that list.

There is no applicable identifier here (it's ...), so I guess there should be some tweak.

Thanks, that worked! Is there a reason it isn't included in dom?

target: es5 does not support iterators, so including it by default would be confusing. But not including it is also confusing in 2021. 🤔

saschanaz avatar Dec 03 '21 01:12 saschanaz

This is solved, right?

@github-actions close

saschanaz avatar Sep 17 '22 21:09 saschanaz

Closing because @saschanaz is one of the code-owners of this repository.

github-actions[bot] avatar Sep 17 '22 21:09 github-actions[bot]