gajus / gajus/flow-runtime

generated getters/setters for class property assertions break property ownership

Open
#192 7 comments 3 reactions 1 assignee Claimed by @jedwards1211 View on GitHub
bug
Dominant language
JavaScript
Stars
797
Forks
49
PR merge metrics
No merged PRs in 30d

Description

This is a:

- [x] Bug Report
- [ ] Feature Request
- [ ] Question
- [ ] Other

Which concerns:

- [x] flow-runtime
- [x] babel-plugin-flow-runtime
- [ ] flow-runtime-validators
- [ ] flow-runtime-mobx
- [ ] flow-config-parser
- [ ] The documentation website

---

When I trying to clone my object with lodash clone method, it loses values of object properties:

```js
// @flow

import { clone } from 'lodash'

class A {
prop: number

constructor(prop: number) {
this.prop = prop
}
}

test('cloning of typed objects', () => {
const a = new A(42)

const copy = clone(a)

expect(a).not.toBe(copy)
expect(copy.prop).toBe(42)
})
```

With example above I got a error from jest:

```
FAIL a.spec.js
✕ cloning of typed objects (6ms)

● cloning of typed objects

expect(received).toBe(expected)

Expected value to be (using ===):
42
Received:
undefined
```

### What is the expected behaviour?

It should returns cloned object with setted properties and works correctly with lodash, because it's popular package from npm.

---

### Which package versions are you using?

* flow-runtime - 0.16
* babel-plugin-flow-runtime - 0.15
* lodash - 4

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.