When such an object is cloned the previously unbound SafeSerializableSceneObject.valueOf would change this context that would point to the newly (cloned) created instance. This creates an issue with the code generated by typescript when using private properties (#). The diff of the compiled code can be observed here:
https://www.diffchecker.com/WLJEvKvj/
The cloneDeepwill not call the cloned object constructor - this means that the originally bound valueOf function must preserve the this context of the source object.
📦 Published PR as canary version: 5.6.2--canary.844.10073760230.0
:sparkles: Test out this PR locally via:
```bash
npm install @grafana/scenes-react@5.6.2--canary.844.10073760230.0
npm install @grafana/scenes@5.6.2--canary.844.10073760230.0
# or
yarn add @grafana/scenes-react@5.6.2--canary.844.10073760230.0
yarn add @grafana/scenes@5.6.2--canary.844.10073760230.0
```
This PR fixes an issue that may occur when the data source that interpolates queries uses
cloneDeep
to clone the provided query request. For example:https://github.com/grafana/athena-datasource/blob/v2.17.1/src/datasource.ts#L104 https://github.com/grafana/grafana/blob/v11.1.2/public/app/plugins/datasource/cloudwatch/datasource.ts#L88
When such an object is cloned the previously unbound
SafeSerializableSceneObject.valueOf
would changethis
context that would point to the newly (cloned) created instance. This creates an issue with the code generated by typescript when using private properties (#). The diff of the compiled code can be observed here: https://www.diffchecker.com/WLJEvKvj/The
cloneDeep
will not call the cloned object constructor - this means that the originally boundvalueOf
function must preserve thethis
context of the source object.📦 Published PR as canary version:
5.6.2--canary.844.10073760230.0
:sparkles: Test out this PR locally via: ```bash npm install @grafana/scenes-react@5.6.2--canary.844.10073760230.0 npm install @grafana/scenes@5.6.2--canary.844.10073760230.0 # or yarn add @grafana/scenes-react@5.6.2--canary.844.10073760230.0 yarn add @grafana/scenes@5.6.2--canary.844.10073760230.0 ```