Skip to content

refactor: add type safety in utils.test.ts #4091

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

Merged
merged 1 commit into from
Sep 16, 2022
Merged

refactor: add type safety in utils.test.ts #4091

merged 1 commit into from
Sep 16, 2022

Conversation

jsjoeio
Copy link
Contributor

@jsjoeio jsjoeio commented Sep 16, 2022

This makes a few changes to the typings in
site/src/components/GlobalSnackbar/utils.test.ts to more accurately
represent the types we're using. It allows us to remove from type
assertion and one eslint-disable comment.

This makes a few changes to the typings in
site/src/components/GlobalSnackbar/utils.test.ts to more accurately
represent the types we're using. It allows us to remove from type
assertion and one eslin-disable comment..
}

beforeEach(() => {
dispatchEventMock = jest.fn()
window.dispatchEvent = dispatchEventMock
window.dispatchEvent = dispatchEventMock as unknown as typeof window.dispatchEvent
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is the only way to properly type this:

  1. as unknown "Don't worry, I'm casting my thing unknown type before my assertion"
  2. as typeof window.dispatchEvent "This is what it actually is"

@jsjoeio jsjoeio self-assigned this Sep 16, 2022
@jsjoeio jsjoeio marked this pull request as ready for review September 16, 2022 15:55
@jsjoeio jsjoeio requested a review from a team as a code owner September 16, 2022 15:55
@jsjoeio jsjoeio requested review from code-asher and removed request for a team September 16, 2022 15:55
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.

2 participants