Skip to content

Commit 5170238

Browse files
authored
Remove extra casts and switch to use Object.entries (microsoft#163900)
1 parent 42d9928 commit 5170238

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/vs/base/common/objects.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,11 @@ export function deepClone<T>(obj: T): T {
1010
return obj;
1111
}
1212
if (obj instanceof RegExp) {
13-
// See https://github.com/microsoft/TypeScript/issues/10990
14-
return obj as any;
13+
return obj;
1514
}
1615
const result: any = Array.isArray(obj) ? [] : {};
17-
Object.keys(<any>obj).forEach((key: string) => {
18-
if ((<any>obj)[key] && typeof (<any>obj)[key] === 'object') {
19-
result[key] = deepClone((<any>obj)[key]);
20-
} else {
21-
result[key] = (<any>obj)[key];
22-
}
16+
Object.entries(obj).forEach(([key, value]) => {
17+
result[key] = value && typeof value === 'object' ? deepClone(value) : value;
2318
});
2419
return result;
2520
}

0 commit comments

Comments
 (0)