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

chore(deps): update dependency expect-type to ^0.17.0 - autoclosed #1014

Closed
wants to merge 1 commit into from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Oct 16, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
expect-type ^0.16.0 -> ^0.17.0 age adoption passing confidence

Release Notes

mmkal/expect-type (expect-type)

v0.17.3

Compare Source

v0.17.2

Compare Source

Diff(truncated - scroll right!):

test('toEqualTypeOf with tuples', () => {
  const assertion = `expectTypeOf<[[number], [1], []]>().toEqualTypeOf<[[number], [2], []]>()`
  expect(tsErrors(assertion)).toMatchInlineSnapshot(`
-    "test/test.ts:999:999 - error TS2344: Type '[[number], [2], []]' does not satisfy the constraint '{ [x: number]: { [x: number]: number; [iterator]: (() => IterableIterator<1>) | (() => IterableIterator<number>) | (() => IterableIterator<never>); [unscopables]: (() => { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }) | (() => { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }) | (() => { copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: boolean; values: boolean; }); length: 0 | 1; toString:  ... truncated!!!!'.
-      Types of property 'sort' are incompatible.
-        Type '(compareFn?: ((a: [] | [number] | [2], b: [] | [number] | [2]) => number) | undefined) => [[number], [2], []]' is not assignable to type '\\"Expected: function, Actual: function\\"'.
+    "test/test.ts:999:999 - error TS2344: Type '[[number], [2], []]' does not satisfy the constraint '{ 0: { 0: number; }; 1: { 0: \\"Expected: literal number: 2, Actual: literal number: 1\\"; }; 2: {}; }'.
+      The types of '1[0]' are incompatible between these types.
+        Type '2' is not assignable to type '\\"Expected: literal number: 2, Actual: literal number: 1\\"'.
    999 expectTypeOf<[[number], [1], []]>().toEqualTypeOf<[[number], [2], []]>()
                                                          ~~~~~~~~~~~~~~~~~~~"
  `)
})

v0.17.1

Compare Source

  • disallow .not and .branded together cf38918

(this was actually documented in the v0.17.0 release but really it was only pushed here)

v0.17.0

Compare Source

#​16 went in to - hopefully - significantly improve the error messages produce on failing assertions. Here's an example of how vitest's failing tests were improved:

Before:

image

After:

image

Docs copied from the readme about how to interpret these error messages


Error messages

When types don't match, .toEqualTypeOf and .toMatchTypeOf use a special helper type to produce error messages that are as actionable as possible. But there's a bit of an nuance to understanding them. Since the assertions are written "fluently", the failure should be on the "expected" type, not the "actual" type (expect<Actual>().toEqualTypeOf<Expected>()). This means that type errors can be a little confusing - so this library produces a MismatchInfo type to try to make explicit what the expectation is. For example:

expectTypeOf({a: 1}).toEqualTypeOf<{a: string}>()

Is an assertion that will fail, since {a: 1} has type {a: number} and not {a: string}. The error message in this case will read something like this:

test/test.ts:999:999 - error TS2344: Type '{ a: string; }' does not satisfy the constraint '{ a: \\"Expected: string, Actual: number\\"; }'.
  Types of property 'a' are incompatible.
    Type 'string' is not assignable to type '\\"Expected: string, Actual: number\\"'.

999 expectTypeOf({a: 1}).toEqualTypeOf<{a: string}>()

Note that the type constraint reported is a human-readable messaging specifying both the "expected" and "actual" types. Rather than taking the sentence Types of property 'a' are incompatible // Type 'string' is not assignable to type "Expected: string, Actual: number" literally - just look at the property name ('a') and the message: Expected: string, Actual: number. This will tell you what's wrong, in most cases. Extremely complex types will of course be more effort to debug, and may require some experimentation. Please raise an issue if the error messages are actually misleading.

The toBe... methods (like toBeString, toBeNumber, toBeVoid etc.) fail by resolving to a non-callable type when the Actual type under test doesn't match up. For example, the failure for an assertion like expectTypeOf(1).toBeString() will look something like this:

test/test.ts:999:999 - error TS2349: This expression is not callable.
  Type 'ExpectString<number>' has no call signatures.

999 expectTypeOf(1).toBeString()
                    ~~~~~~~~~~

The This expression is not callable part isn't all that helpful - the meaningful error is the next line, Type 'ExpectString<number> has no call signatures. This essentially means you passed a number but asserted it should be a string.

If TypeScript added support for "throw" types these error messagess could be improved. Until then they will take a certain amount of squinting.

Concrete "expected" objects vs typeargs

Error messages for an assertion like this:

expectTypeOf({a: 1}).toEqualTypeOf({a: ''})

Will be less helpful than for an assertion like this:

expectTypeOf({a: 1}).toEqualTypeOf<{a: string}>()

This is because the TypeScript compiler needs to infer the typearg for the .toEqualTypeOf({a: ''}) style, and this library can only mark it as a failure by comparing it against a generic Mismatch type. So, where possible, use a typearg rather than a concrete type for .toEqualTypeOf and toMatchTypeOf. If it's much more convenient to compare two concrete types, you can use typeof:

const one = valueFromFunctionOne({some: {complex: inputs}})
const two = valueFromFunctionTwo({some: {other: inputs}})

expectTypeOf(one).toEqualTypeof<typeof two>()

Kinda-breaking changes: essentially none, but technically, .branded no longer returns a "full" ExpectTypeOf instance at compile-time. Previously you could do this:

expectTypeOf<{a: {b: 1} & {c: 1}}>().branded.not.toEqualTypeOf<{a: {b: 1; c: ''}}>()
expectTypeOf<{a: {b: 1} & {c: 1}}>().not.branded.toEqualTypeOf<{a: {b: 1; c: ''}}>()

Now that won't work (and it was always slightly nonsensical), so you'd have to use // @&#8203;ts-expect-error instead of not if you have a negated case where you need branded:

// @&#8203;ts-expect-error
expectTypeOf<{a: {b: 1} & {c: 1}}>().branded.not.toEqualTypeOf<{a: {b: 1; c: ''}}>()

What's Changed

New Contributors

Full Changelog: mmkal/expect-type@v0.16.0...v0.17.0


Configuration

📅 Schedule: Branch creation - "after 9pm on sunday" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@stackblitz
Copy link

stackblitz bot commented Oct 16, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot
Copy link

changeset-bot bot commented Oct 16, 2023

⚠️ No Changeset found

Latest commit: 87b4b2e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 16, 2023

Estimated impact to a consuming app, depending on which bundle is imported

js min min + gzip min + brotli
/index.js 26.22 kB 5.71 kB 2.1 kB 1.85 kB
├── core/class-based/index.js 9.39 kB 2.48 kB 1.16 kB 999 B
├── core/function-based/index.js 15.01 kB 4.12 kB 1.55 kB 1.35 kB
└── core/use.js 11.18 kB 3.46 kB 1.4 kB 1.22 kB
/link.js 2.67 kB 376 B 233 B 185 B
/service.js 20.59 kB 5.74 kB 2.12 kB 1.86 kB
/util/debounce.js 3.07 kB 861 B 445 B 373 B
/util/ember-concurrency.js 5.07 kB 1.59 kB 750 B 640 B
/util/fps.js 3.16 kB 919 B 480 B 386 B
/util/function.js 10.06 kB 2.77 kB 1.02 kB 911 B
/util/helper.js 2.12 kB 303 B 218 B 177 B
/util/keep-latest.js 2.08 kB 412 B 261 B 209 B
/util/map.js 5.95 kB 2.44 kB 1.1 kB 924 B
/util/remote-data.js 7.96 kB 2.37 kB 808 B 705 B

@github-actions
Copy link
Contributor

github-actions bot commented Oct 16, 2023

@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from d5aca97 to 7f7433a Compare October 16, 2023 20:32
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch 4 times, most recently from 357d2a0 to bc533d3 Compare October 20, 2023 04:26
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from bc533d3 to 9f982cd Compare October 20, 2023 05:01
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch 3 times, most recently from 2d62e41 to 5c9032e Compare October 20, 2023 05:24
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch 2 times, most recently from b4c5bf4 to 7066fe2 Compare October 20, 2023 05:57
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch 3 times, most recently from 66bfb4a to 6dcbf90 Compare October 23, 2023 09:45
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 6dcbf90 to 945b004 Compare October 23, 2023 15:03
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch 2 times, most recently from 67012ba to fa5c0d9 Compare October 23, 2023 15:37
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 2502045 to f581043 Compare November 25, 2023 10:26
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from f581043 to 3beeee7 Compare November 28, 2023 11:38
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 3beeee7 to b93a598 Compare November 28, 2023 13:29
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from b93a598 to e0f5f29 Compare November 28, 2023 20:43
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from e0f5f29 to 13381ce Compare November 29, 2023 01:57
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 13381ce to 6c81183 Compare November 29, 2023 13:00
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 6c81183 to 2a5f815 Compare November 30, 2023 09:58
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 2a5f815 to 1656000 Compare December 7, 2023 18:48
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 1656000 to eabf13b Compare December 11, 2023 09:02
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from eabf13b to 67ebbbe Compare December 11, 2023 13:44
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 67ebbbe to 5d20305 Compare December 13, 2023 16:17
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 5d20305 to 6076411 Compare December 13, 2023 16:54
@renovate renovate bot force-pushed the renovate/expect-type-0.x branch from 6076411 to 87b4b2e Compare December 13, 2023 21:39
@renovate renovate bot changed the title chore(deps): update dependency expect-type to ^0.17.0 chore(deps): update dependency expect-type to ^0.17.0 - autoclosed Dec 14, 2023
@renovate renovate bot closed this Dec 14, 2023
@renovate renovate bot deleted the renovate/expect-type-0.x branch December 14, 2023 00:17
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.

0 participants