Commit 5b74eea
authored
fix(cloudflare): Account for static fields in wrapper type (#16303)
fixes #16247
By adjusting the generic, we'll make sure that we don't erase static
fields with the `instrumentDurableObjectWithSentry` function. See an
example below:
```js
class MyDurableObjectBase extends DurableObject {
public static readonly VERSION = '1.0.0';
}
const MyDurableObject = instrumentDurableObjectWithSentry(
() => ({
dsn: 'https://example.com/sentry',
tracesSampleRate: 1.0,
}),
MyDurableObjectBase,
);
console.log(MyDurableObject.VERSION); // This will now work correctly
```
By moving the `DurableObjectClass` into it's own generic (`new (state:
DurableObjectState, env: E) => T`), which we named `C`, it helps
preserve the exact constructor type of the input class, including all
its static properties and methods.
This was previously being lost by not aligning the `DurableObjectClass`
with the function return value.1 parent 33e965d commit 5b74eea
1 file changed
+5
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| |||
0 commit comments