Skip to content

Commit

Permalink
Fix IReactionDisposer and IIsObservableObject Typing (#3816)
Browse files Browse the repository at this point in the history
* fix IReaction type

* add changeset

* fix IIsObservableObject too

* fix test
  • Loading branch information
barroij authored Mar 28, 2024
1 parent 7bbb523 commit b28e0eb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-rules-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"mobx": patch
---

Fix `IReactionDisposer` and `IIsObservableObject` interface definition so that Typescript knows the property key `$mobx` is a symbol and not a string
5 changes: 3 additions & 2 deletions packages/mobx/src/core/reaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
spyReportStart,
startBatch,
trace,
trackDerivedFunction, GenericAbortSignal
trackDerivedFunction,
GenericAbortSignal
} from "../internal"

/**
Expand Down Expand Up @@ -47,7 +48,7 @@ export interface IReactionPublic {

export interface IReactionDisposer {
(): void
$mobx: Reaction
[$mobx]: Reaction
}

export class Reaction implements IDerivation, IReactionPublic {
Expand Down
4 changes: 2 additions & 2 deletions packages/mobx/src/types/observableobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ export class ObservableObjectAdministration
this.keysAtom_.reportChanged()
}

ownKeys_(): ArrayLike<string | symbol> {
ownKeys_(): Array<string | symbol> {
this.keysAtom_.reportObserved()
return ownKeys(this.target_)
}
Expand All @@ -647,7 +647,7 @@ export class ObservableObjectAdministration
}

export interface IIsObservableObject {
$mobx: ObservableObjectAdministration
[$mobx]: ObservableObjectAdministration
}

export function asObservableObject(
Expand Down

0 comments on commit b28e0eb

Please sign in to comment.