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

Rewrite Equal to use the equality check from ReadonlyEquivalent exclusively #21

Merged
merged 9 commits into from May 10, 2023

Commits on Nov 28, 2022

  1. Rewrite Equal to use the equality check from ReadonlyEquivalent e…

    …xclusively.
    
    This is a breaking change as I opted to remove the types that were no longer needed. They are exported though so it's likely some people depend on them.
    
    This took a lot of tinkering. This topic and this equality check is discussed extensively at microsoft/TypeScript#27024
    
    The main three work-arounds this implementation added are:
    1. Explicitly handling `any` separately
    2. Supporting identity unions
    3. Supporting identity intersections
    
    The only known issue is this case:
    
    ```ts
      // @ts-expect-error This is the bug.
      expectTypeOf<{foo: number} & {bar: string}>().toEqualTypeOf<{foo: number; bar: string}>()
    ```
    
    @shicks and I could not find a tweak to the `Equality` check to make this work.
    
    Instead, I added a workaround in the shape of a new `.simplified` modifier that works similar to `.not`:
    
    ```ts
      // The workaround is the new optional .simplified modifier.
      expectTypeOf<{foo: number} & {bar: string}>().simplified.toEqualTypeOf<{foo: number; bar: string}>()
    ```
    
    I'm not entirely sure what to do with documenting `.simplified` because it's something you should never use unless you need it. The simplify operation tends to lose information about the types being tested (e.g., functions become `{}` and classes lose their constructors). I'll definitely update this PR to reference the `.simplified` modifier but I wanted to get a review on this approach first. One option would be to keep around all the `DeepBrand` stuff and to have `.deepBranded` or something being the modifier instead. That would have the benefit of preserving all the exported types making this less of a breaking change.
    trevorade committed Nov 28, 2022
    Configuration menu
    Copy the full SHA
    44d7f67 View commit details
    Browse the repository at this point in the history

Commits on Apr 8, 2023

  1. Configuration menu
    Copy the full SHA
    27142ee View commit details
    Browse the repository at this point in the history

Commits on Apr 13, 2023

  1. Use options bag

    mmkal committed Apr 13, 2023
    Configuration menu
    Copy the full SHA
    8944ede View commit details
    Browse the repository at this point in the history
  2. ts-expect-errors

    mmkal committed Apr 13, 2023
    Configuration menu
    Copy the full SHA
    bd7275a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b39fe06 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3081e2e View commit details
    Browse the repository at this point in the history

Commits on May 10, 2023

  1. Add test for #29

    mmkal committed May 10, 2023
    Configuration menu
    Copy the full SHA
    5d5b1eb View commit details
    Browse the repository at this point in the history
  2. add to readme, update snapshots

    mmkal committed May 10, 2023
    Configuration menu
    Copy the full SHA
    f4dab98 View commit details
    Browse the repository at this point in the history
  3. prettier?

    mmkal committed May 10, 2023
    Configuration menu
    Copy the full SHA
    241e1e5 View commit details
    Browse the repository at this point in the history