preferNativeCollectionCopyUse table.clone for this shallow collection copy.small-rules/prefer-native-collection-copyPrefer table.clone over a manual shallow Map or Set copy loop.
A loop that inserts every Map or Set value unchanged is a shallow copy written the long way.
table.clone states that operation directly.
The rule only reports when syntax and scope analysis prove that both collections have the same native kind.
It skips opaque iterables, weak collections, conversions, filtering, and transformed values. A report may
omit its fix when some other table shadows the global, or attached comments make it unsafe to delete the
loop.
preferNativeCollectionCopyUse table.clone for this shallow collection copy.This rule does not accept options.
const current = new Map<number, NodePosition>(entries);const updated = new Map<number, NodePosition>();for (const [key, value] of current) updated.set(key, value);After auto-fix
const current = new Map<number, NodePosition>(entries);const updated = table.clone(current);const current = new Map(entries);const updated = table.clone(current);