I have the following TypeScript / Javascript codes for producing multiple line using jQuery.
let evenLine = false;
const divs = clientsInfo.map((m) => {
const div = $('<li/>', { class: 'hubClientInfo' + (evenLine ? ' even' : ' odd') });
evenLine = !evenLine;
div.append($('<span/>', { class: 'hc-userAgent' }).text(m.userAgent));
div.append($('<span/>', { class: 'hc-ip' }).text(m.ipAddress));
div.append($('<span/>', { class: 'time' }).text(m.connectedTimeUtc.toString()));
div.append($('<span/>', { class: 'hc-user' }).text(m.username));
div.append($('<span/>', { class: 'hc-id' }).text(m.id));
return div;
});
TSLint reports Shadowed name regarding to "evenLine".
Is this a false alarm? or is there a way to improve the codes to avoid such alarm?
Eventually I had found that down the bottom of the TS file there's a "evenLine" declared globally outside any class or module. So renaming those "evenLine" within a function scope had fixed the TSLint warning, while the program has been working properly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.