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

[No QA] [TS migration] Migrate 'react-freeze.js' mock to TypeScript #35474

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions __mocks__/react-freeze.js

This file was deleted.

11 changes: 11 additions & 0 deletions __mocks__/react-freeze.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type {Freeze} from 'react-freeze';

type ReactFreezeMock = {
Freeze: typeof Freeze;
};

const reactFreezeMock: ReactFreezeMock = {
Freeze: (props) => props.children as JSX.Element,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHy do we need the assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lack of that assertion causes the following error:

Type 'ReactNode' is not assignable to type 'Element'.
  Type 'undefined' is not assignable to type 'ReactElement<any, any>'.

Alternatively, I could change the file extension to .tsx and wrap it in <></>, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, this way is fine, thanks for explanation

};

export default reactFreezeMock;
Loading