Commit b4897a0
fix: clone util should clone symbol properties of object (#1258)
The `clone` function only iterated over string-keyed properties via
`for...in`, missing symbol properties entirely.
### Changes
- Added `Object.getOwnPropertySymbols()` iteration to clone symbol-keyed
properties
- Added test case for nested symbol property cloning
### Example
```typescript
const sym = Symbol('test')
const obj = { a: 1, [sym]: { b: 2 } }
const cloned = clone(obj)
// Before: cloned[sym] was undefined
// After: cloned[sym] equals { b: 2 } (deep cloned)
```
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
> clone util should clone symbol properties of object
>
> if (isObject(value)) {
> const result: Record<PropertyKey, unknown> = {}
>
> for (const key in value) {
> result[key] = clone(value[key])
> }
>
> return result as any
> }
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: unnoq <64189902+unnoq@users.noreply.github.com>1 parent e565e67 commit b4897a0
File tree
2 files changed
+16
-0
lines changed2 files changed
+16
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
88 | 100 | | |
89 | 101 | | |
90 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| |||
0 commit comments