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

Bugfix/ts expect error is a bug #205

Merged
merged 3 commits into from
Dec 16, 2023

Conversation

Crisfole
Copy link

Description

This fixes a few type places where you opt out of TS with 'expect-error' in the flow branch. Most are just instances of missing extends that you actually already had elsewhere. One is using an as instead of an ts-expect-error.

The problem with the expect-error is that if you miss something else you could introduce bugs since it is line level ignoring. By using an as you assert to the compiler it's getting something wrong, but in exchange the compiler trusts you and continues checking everything else that it can.

Related Issue

Link to the related issue: None

Type of Change (select one and follow subtasks)

  • Documentation (README.md)
  • Maintenance or repo-level work (e.g. linting, build, tests, refactoring, etc.)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
    • I have included test coverage
  • Breaking change (fix or feature that would cause existing functionality/userland code to not work as expected)
    • Explain why a breaking change is necessary:
  • This change requires (or is) a documentation update
    • I have added necessary local documentation (if appropriate)
    • I have added necessary itty.dev documentation (if appropriate)

In this case the 'as' is asserting "I know better than the compiler" and it
is both true and more accurate than saying "I expect typescript to error out
here." As an added benefit, `as` does more type checking than 'expect error',
so you get just a small bit more type safety.
@kwhitley kwhitley changed the base branch from v4.x to flow December 16, 2023 23:29
@kwhitley kwhitley merged commit ea83f52 into kwhitley:flow Dec 16, 2023
1 of 3 checks passed
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