Skip to content

Commit 6be559a

Browse files
chore: don't redeclare inherited observable Session.name (#34034)
* fix: don't redeclare inherited observable Session.name `Session extends Instrument` (Log), which declares `name` and converts it to a MobX observable in its constructor. `Session` redeclared `name: string` only to narrow the type, but under `useDefineForClassFields: true` that subclass field's define-semantics initializer runs after `super()` and re-defines the property MobX already installed — throwing `TypeError: Cannot redefine property: name` when a Session model is constructed (surfaces in the test-replay viewer's esbuild bundle, which emits the field; the app's babel build erased it). Removing the redeclaration (rather than using `declare`, which the app's babel class-properties pipeline can't strip) fixes it for both build pipelines. `name` is only assigned in Session, never read, so the inherited type suffices. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Apply suggestion from @ryanthemanuel --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 437a08e commit 6be559a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/reporter/src/sessions/sessions-model.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export interface SessionProps extends InstrumentProps {
1515
}
1616

1717
export default class Session extends Instrument {
18-
name: string
18+
// `name` is inherited from Instrument (and made observable in its
19+
// constructor). Do NOT redeclare it as a class field: under
20+
// useDefineForClassFields a subclass field re-defines the inherited
21+
// observable and throws "Cannot redefine property: name" when
22+
// reporter is embedded into test-replay as a submodule.
1923
status: string
2024
isGlobalSession: boolean = false
2125
tagType: string

0 commit comments

Comments
 (0)