Skip to content

Typing of act broken #1207

Closed
Closed
@mstykow

Description

@mstykow

Describe the bug

The act function exported by @testing-library/react-native is always of type (callback: () => void) => void. However, the underlying function coming from react-test-renderer also has overloads for promises which are incorrectly suppressed.

This error in typing leads to linter errors when one tries to pass promise-returning callbacks to act or tries to await a promise-returning act.

Expected behavior

The act function should have the same typing as the underlying function from react-test-renderer.

Steps to Reproduce

The following snippet will produce linter errors such as this one, depending on one's linter configuration.

import { act } from '@testing-library/react-native'

await act(async () => {
  await Promise.resolve();
});

Versions

@testing-library/react-native: ^11.3.0 => 11.3.0 
react: 18.0.0 => 18.0.0 
react-native: 0.69.6 => 0.69.6 
react-test-renderer: ^18.2.0 => 18.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions