Skip to content
Advertisement

Typescript,’NodeListOf’ is not an array type or a string type

Converting my JS to TS strict mode.

The following syntax looks fine to me but TS is complaining in the for loop on allSubMenus with:

JavaScript

What am I missing?

JavaScript

Advertisement

Answer

You need to set the target compiler option to es6 or higher for NodeListOf<T> to be iterable.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement