-
Notifications
You must be signed in to change notification settings - Fork 7
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.20.0 #196
base: main
Are you sure you want to change the base?
Conversation
|
b13be73
to
afecfa5
Compare
8710b76
to
263f20f
Compare
263f20f
to
dde5a65
Compare
a20275d
to
322f68d
Compare
952862e
to
8a2ca80
Compare
1c06d6b
to
e8dfe22
Compare
e8dfe22
to
21347f2
Compare
44dcdb5
to
cb1c0ea
Compare
eed1f99
to
c9adc5e
Compare
28f82f6
to
cbb2d5a
Compare
4a44f3c
to
55cf084
Compare
2032a6e
to
edbba3a
Compare
eb3993a
to
a98723b
Compare
1030364
to
9d3a153
Compare
3cfbe68
to
7815137
Compare
1b96b44
to
0d9f3e7
Compare
aa5f7e1
to
0495712
Compare
56c7f5f
to
26e76f1
Compare
26e76f1
to
bc98112
Compare
This PR contains the following updates:
^0.14.2
->^0.20.0
^0.15.0
->^0.20.0
Release Notes
mmkal/expect-type (expect-type)
v0.20.0
Compare Source
Breaking changes
This change updates how overloaded functions are treated. Now,
.parameters
gives you a union of the parameter-tuples that a function can take. For example, given the following type:Behvaiour before:
Behaviour now:
There were similar changes for
.returns
,.parameter(...)
, and.toBeCallableWith
. Also, overloaded functions are now differentiated properly when using.branded.toEqualTypeOf
(this was a bug that it seems nobody found).See #83 for more details or look at the updated docs (including a new section called "Overloaded functions", which has more info on how this behaviour differs for TypeScript versions before 5.3).
What's Changed
1e37116
@internal
JSDoc tag (#104)4c40b07
overloads.ts
file (#107)5ee0181
0bbeffa
Full Changelog: mmkal/expect-type@v0.19.0...v0.20.0
v0.19.0
Compare Source
What's Changed
.omit()
to work similarly toOmit
by @aryaemami59 in https://github.com/mmkal/expect-type/pull/54test
import inREADME.md
by @aryaemami59 in https://github.com/mmkal/expect-type/pull/65Full Changelog: mmkal/expect-type@0.18.0...0.19.0
v0.18.0
Compare Source
What's Changed
.pick
and.omit
by @aryaemami59 in https://github.com/mmkal/expect-type/pull/51New Contributors
Full Changelog: mmkal/expect-type@v0.17.3...0.18.0
v0.17.3
Compare Source
907b8aa
v0.17.2
Compare Source
4b38117
Diff(truncated - scroll right!):
v0.17.1
Compare Source
.not
and.branded
togethercf38918
(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:
After:
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 aMismatchInfo
type to try to make explicit what the expectation is. For example: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: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 (liketoBeString
,toBeNumber
,toBeVoid
etc.) fail by resolving to a non-callable type when theActual
type under test doesn't match up. For example, the failure for an assertion likeexpectTypeOf(1).toBeString()
will look something like this: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:
Will be less helpful than for an assertion like this:
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 genericMismatch
type. So, where possible, use a typearg rather than a concrete type for.toEqualTypeOf
andtoMatchTypeOf
. If it's much more convenient to compare two concrete types, you can usetypeof
:Kinda-breaking changes: essentially none, but technically,
.branded
no longer returns a "full"ExpectTypeOf
instance at compile-time. Previously you could do this:Now that won't work (and it was always slightly nonsensical), so you'd have to use
// @​ts-expect-error
instead ofnot
if you have a negated case where you needbranded
:What's Changed
New Contributors
Full Changelog: mmkal/expect-type@v0.16.0...v0.17.0
v0.16.0
Compare Source
What's Changed
this
parameters by @mmkal and @papb in https://github.com/mmkal/expect-type/pull/15Equal
to use the equality check fromReadonlyEquivalent
exclusively by @trevorade in https://github.com/mmkal/expect-type/pull/21Note that #21 has affected behavior for intersection types, which can result in (arguably) false errors:
Full Changelog: mmkal/expect-type@v0.15.0...v16.0.0
v0.15.0
Compare Source
What's Changed
New Contributors
Full Changelog: mmkal/expect-type@v0.14.2...v0.15.0
Configuration
📅 Schedule: Branch creation - "after 9pm on sunday" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR was generated by Mend Renovate. View the repository job log.