Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IReactionDisposer and IIsObservableObject Typing #3816

Merged
merged 4 commits into from
Mar 28, 2024

Conversation

barroij
Copy link
Contributor

@barroij barroij commented Jan 17, 2024

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

Copy link

changeset-bot bot commented Jan 17, 2024

🦋 Changeset detected

Latest commit: da624fb

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

@kubk
Copy link
Collaborator

kubk commented Jan 18, 2024

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

$mobx: ObservableObjectAdministration

@barroij
Copy link
Contributor Author

barroij commented Jan 18, 2024

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

@barroij barroij changed the title Fix IReactionDisposer Typing Fix IReactionDisposer and IIsObservableObject Typing Jan 18, 2024
@barroij
Copy link
Contributor Author

barroij commented Jan 18, 2024

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

@mweststrate mweststrate merged commit b28e0eb into mobxjs:main Mar 28, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants