mobx icon indicating copy to clipboard operation
mobx copied to clipboard

Fix IReactionDisposer and IIsObservableObject Typing

Open barroij opened this issue 2 years ago • 4 comments

This is typing only PR.

Current interface definition for IReactionDisposer is

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

but that's wrong because because like so typescript considers the property key $mobx to be a string, whereas it is a symbol. The correct indexing type is given by

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

[Edit] : same thing for IIsObservableObject

barroij avatar Jan 17 '24 22:01 barroij

🦋 Changeset detected

Latest commit: da624fb514aa1151669ac0b849a89c75daa96e44

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mobx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Jan 17 '24 22:01 changeset-bot[bot]

@barroij Thank you. Do you think it makes sense to update IIsObservableObject as well?

https://github.com/mobxjs/mobx/blob/13a222ea21bd55b7158d48a998846da608080ded/packages/mobx/src/types/observableobject.ts#L650

kubk avatar Jan 18 '24 01:01 kubk

@kubk You are right, I'm gonna change it too.

barroij avatar Jan 18 '24 08:01 barroij

Note : fixing typing for IIsObservableObject resulted in a test failure (packages/mobx/src/api/tojs.ts:57:28 - error TS2339: Property 'forEach' does not exist on type 'ArrayLike<string | symbol>'.).

I had to change the return type of function ObservableObjectAdministration.ownKeys_ from ArrayLike<string | symbol> to Array<string | symbol> to fix it

barroij avatar Jan 18 '24 08:01 barroij