Consider the following code:
const getDisabledFieldsSet = function(form: HTMLFormElement) {
const disabledFields: Element[] = [];
//Using for-of to open this loop, e.g.
//for(let input of form) {
//fails w/err: Type 'HTMLFormElement' must have a '[Symbol.iterator]()' method that returns an iterator.ts(2488)
//However, Sonar insists on using for-of.
//Expected a `for-of` loop instead of a `for` loop with this simple iteration.sonarlint(typescript:S4138).
//It does not appear possible to simultaneously satisfy both checkers.
for(let i = 0; i < form.length; i++) {
const input = form[i];
if(input.hasAttribute('disabled')) {
disabledFields.push(input);
}
}
return disabledFields;
}
Sonar should not report a TypeScript issue seeking a for-of field in cases where TypeScript prohibits it, even if the prohibition is a TypeScript issue associated with not properly including the “dom.iterable” option in the “lib” compiler option.