This repository was archived by the owner on Mar 7, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 26
Update devDependencies (major) #294
Open
renovate
wants to merge
1
commit into
main
Choose a base branch
from
renovate/major-devdependencies
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c780325 to
293426f
Compare
293426f to
3f10b15
Compare
3f10b15 to
7b9aa83
Compare
51994f0 to
0e6ac77
Compare
df2344d to
b3335c9
Compare
7df6ab6 to
a102a3b
Compare
62ca207 to
dc3d452
Compare
dc3d452 to
f299833
Compare
f299833 to
1ec81d0
Compare
b15d5c3 to
7f7b390
Compare
35e8b4d to
0887b67
Compare
17e4d29 to
7d83bee
Compare
26fae48 to
01a52a2
Compare
e3a513d to
576ec3d
Compare
949b187 to
eb4d9be
Compare
1686677 to
1c0c68a
Compare
a7ff5e6 to
46976f3
Compare
82825ba to
965936c
Compare
6f8e298 to
d2b9cec
Compare
3f2f7bf to
af99ef3
Compare
1988db8 to
307ad1a
Compare
307ad1a to
31b0af8
Compare
3707f73 to
f9b3e60
Compare
f9b3e60 to
496ee94
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
~8.56.7->~9.6.120.12.4->22.13.9~0.19.0->~1.2.0~13.1.2->~15.0.4~6.1.2->~7.0.2~3.2.4->~4.1.0~5.0.5->~6.0.1Release Notes
mmkal/expect-type (expect-type)
v1.2.0Compare Source
What's Changed
❗
toMatchTypeOfis now deprecated. There are no plans to remove it any time soon, so it's not critical to immediately remove usages, but if you want to avoid squigglies in IDEs complaining about deprecations, here's what you should do:If you have an assertion like this:
There are a few options for upgrading it. The easiest is
toExtendwhich is identical to the behaviour oftoMatchTypeOf:This will work in all cases. But, there is now a stricter option that will work in many cases and be slightly more likely to catch things like
readonlyproperties matching:But, as the name suggests, this will only work on plain object types, it will fail for union types, and some other complex types.
If you have code like this:
You'll need to use
typeofbecausetoExtendandtoMatchObjectTypedo not accept argumentsFull Changelog: mmkal/expect-type@v1.1.0...v1.2.0
v1.1.0Compare Source
What's Changed
.toBeBigInt()by @aryaemami59 in https://github.com/mmkal/expect-type/pull/123Full Changelog: mmkal/expect-type@v1.0.0...v1.1.0
v1.0.0Compare Source
v1! 🎉🎉🎉
After many years being commitment-phobic, expect-type is now in v1.
This release does not add any user facing features on top of v0.20.0 or v1.0.0-rc.0. It's just "making it official". For anyone new to the project, or coming here from vitest or viteconf (👋 ), the usage docs from the readme are pasted below.
For anyone on an old-ish v0 version, here are links to the non-trivial changes that have gone in since v0.15.0:
.pickand.omitthanks to @aryaemami59.brandedhelper for the old behaviour. Also support functionthisparameters - thank to @trevorade and @papbFull usage docs below, for newbies (head to the readme to keep up to date):
docs from readme
Installation and usage
Documentation
The
expectTypeOfmethod takes a single argument or a generic type parameter. Neither it nor the functions chained off its return value have any meaningful runtime behaviour. The assertions you write will be compile-time errors if they don't hold true.Features
Check an object's type with
.toEqualTypeOf:.toEqualTypeOfcan check that two concrete objects have equivalent types (note: when these assertions fail, the error messages can be less informative vs the generic type argument syntax above - see error messages docs):.toEqualTypeOfsucceeds for objects with different values, but the same type:.toEqualTypeOffails on excess properties:To allow for extra properties, use
.toMatchTypeOf. This is roughly equivalent to anextendsconstraint in a function type argument.:.toEqualTypeOfand.toMatchTypeOfboth fail on missing properties:Another example of the difference between
.toMatchTypeOfand.toEqualTypeOf, using generics..toMatchTypeOfcan be used for "is-a" relationships:Assertions can be inverted with
.not:.notcan be easier than relying on// @​ts-expect-error:Catch any/unknown/never types:
.toEqualTypeOfdistinguishes between deeply-nestedanyandunknownproperties:You can test for basic JavaScript types:
.toBe...methods allow for types that extend the expected type:.toBe...methods protect againstany:Nullable types:
More
.notexamples:Detect assignability of unioned types:
Use
.extractand.excludeto narrow down complex union types:.extractand.excludereturn never if no types remain after exclusion:Use
.pickto pick a set of properties from an object:Use
.omitto remove a set of properties from an object:Make assertions about object properties:
.toEqualTypeOfcan be used to distinguish between functions:But often it's preferable to use
.parametersor.returnsfor more specific function assertions:Up to ten overloads will produce union types for
.parametersand.returns:Note that these aren't exactly like TypeScript's built-in Parameters<...> and ReturnType<...>:
The TypeScript builtins simply choose a single overload (see the Overloaded functions section for more information)
More examples of ways to work with functions - parameters using
.parameter(n)or.parameters, and return values using.returns:.toBeCallableWithallows for overloads. You can also use it to narrow down the return type for given input parameters.:.toBeCallableWithreturns a type that can be used to narrow down the return type for given input parameters.:.toBeCallableWithcan be used to narrow down the parameters of a function:You can't use
.toBeCallableWithwith.not- you need to use ts-expect-error::You can also check type guards & type assertions:
Assert on constructor parameters:
Constructor overloads:
Check function
thisparameters:Distinguish between functions with different
thisparameters:Class instance types:
Promise resolution types can be checked with
.resolves:Array items can be checked with
.items:You can also compare arrays directly:
Check that functions never return:
Generics can be used rather than references:
Distinguish between missing/null/optional properties:
Detect the difference between regular and
readonlyproperties:Distinguish between classes with different constructors:
Known limitation: Intersection types can cause issues with
toEqualTypeOf:To workaround for simple cases, you can use a mapped type:
But this won't work if the nesting is deeper in the type. For these situations, you can use the
.brandedhelper. Note that this comes at a performance cost, and can cause the compiler to 'give up' if used with excessively deep types, so use sparingly. This helper is under.brandedbecause it deeply transforms the Actual and Expected types into a pseudo-AST:Be careful with
.brandedfor very deep or complex types, though. If possible you should find a way to simplify your test to avoid needing to use it:So, if you have an extremely deep type that ALSO has an intersection in it, you're out of luck and this library won't be able to test your type properly:
Another limitation: passing
thisreferences toexpectTypeOfresults in errors.:Overloads limitation for TypeScript <5.3: Due to a TypeScript bug fixed in 5.3, overloaded functions which include an overload resembling
(...args: unknown[]) => unknownwill excludeunknown[]from.parametersand excludeunknownfrom.returns:This overload, however, allows any input and returns an unknown output anyway, so it's not very useful. If you are worried about this for some reason, you'll have to update TypeScript to 5.3+.
Why is my assertion failing?
For complex types, an assertion might fail when it should if the
Actualtype contains a deeply-nested intersection type but theExpecteddoesn't. In these cases you can use.brandedas described above:Where is
.toExtend?A few people have asked for a method like
toExtend- this is essentially whattoMatchTypeOfis. There are some cases where it doesn't precisely match theextendsoperator in TypeScript, but for most practical use cases, you can think of this as the same thing.Internal type helpers
🚧 This library also exports some helper types for performing boolean operations on types, checking extension/equality in various ways, branding types, and checking for various special types like
never,any,unknown. Use at your own risk! Nothing is stopping you from using these beyond this warning:For a dedicated internal type library, feel free to look at the source code for inspiration - or better, use a library like type-fest.
Error messages
When types don't match,
.toEqualTypeOfand.toMatchTypeOfuse a special helper type to produce error messages that are as actionable as possible. But there's a bit of a 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 aMismatchInfotype 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 misleading.The
toBe...methods (liketoBeString,toBeNumber,toBeVoid, etc.) fail by resolving to a non-callable type when theActualtype 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 callablepart 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 messages could be improved. Until then they will take a certain amount of squinting.
Concrete "expected" objects vs type arguments
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 type argument for the
.toEqualTypeOf({a: ''})style and this library can only mark it as a failure by comparing it against a genericMismatchtype. So, where possible, use a type argument rather than a concrete type for.toEqualTypeOfandtoMatchTypeOf. If it's much more convenient to compare two concrete types, you can usetypeof:Overloaded functions
Due to a TypeScript design limitation, the native TypeScript
Parameters<...>andReturnType<...>helpers only return types from one variant of an overloaded function. This limitation doesn't apply to expect-type, since it is not used to author TypeScript code, only to assert on existing types. So, we use a workaround for this TypeScript behaviour to assert on all overloads as a union (actually, not necessarily all - we cap out at 10 overloads).Within test frameworks
Vitest
expectTypeOfis built in to vitest, so you can importexpectTypeOffrom the vitest library directly if you prefer. Note that there is no set release cadence, at time of writing, so vitest may not always be using the very latest version.Limitations
A summary of some of the limitations of this library. Some of these are documented more fully elsewhere.
.brandin these cases - and accept the performance hit that it comes with.toBeCallableWithwill likely fail if you try to use it with a generic function or an overload. See this issue for an example and how to work around it..parameterand.parametershelpers. This matches how the built-in TypeScript helperParameters<...>works. This may be improved in the future though (see related issue).expectTypeOf(this).toEqualTypeOf(this)inside class methods does not work.Similar projects
Other projects with similar goals:
tsdis a CLI that runs the TypeScript type checker over assertionsts-expectexports several generic helper types to perform type assertionsdtslintdoes type checks via comment directives and tslinttype-pluscomes with various type and runtime TypeScript assertionsstatic-type-asserttype assertion functionsComparison
The key differences in this project are:
actualandexpectedclear. This is helpful with complex types and assertions.expectTypeOf(...).notany(as well asunknownandnever) (see issues outstanding at time of writing in tsd for never and any).not, to protect against functions returning too-permissive types. For example,const parseFile = (filename: string) => JSON.parse(readFileSync(filename).toString())returnsany, which could lead to errors. After giving it a proper return-type, you can add a test for this withexpect(parseFile).returns.not.toBeAny()expectTypeOf(square).toMatchTypeOf<Shape>()tsc.Thanks to everyone who has helped with this over the years!
Full Changelog: mmkal/expect-type@v0.20.0...v1.0.0
v0.20.0Compare Source
Breaking changes
This change updates how overloaded functions are treated. Now,
.parametersgives 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@internalJSDoc tag (#104)4c40b07overloads.tsfile (#107)5ee01810bbeffaFull Changelog: mmkal/expect-type@v0.19.0...v0.20.0
bcherny/json-schema-to-typescript (json-schema-to-typescript)
v15.0.4Compare Source
v15.0.3Compare Source
v15.0.2Compare Source
v15.0.1Compare Source
v15.0.0Compare Source
62cc052Fixed bug where intersection schemas didn't generate complete types. Improved output readability for intersection types (#603)v14.1.0Compare Source
3e2e1e9AddedinferStringEnumKeysFromValuesoption (#578)v14.0.5Compare Source
b7fee29Added .yaml support for CLI (#598)v14.0.4Compare Source
v14.0.3Compare Source
v14.0.2Compare Source
9ec0c70Added .yaml support (#577)v14.0.1Compare Source
2f29f19AddedcustomNameoptionv14.0.0Compare Source
967eb13Require Node v16+bcomnes/npm-run-all2 (npm-run-all2)
v7.0.2Compare Source
Merged
#164#161Commits
45a9e19285967a5d1aea5v7.0.1Compare Source
Commits
b2e849bv7.0.0Compare Source
Merged
#158Commits
49b95f0c661ffcc77e085v6.2.6Compare Source
Commits
d928f9av6.2.5Compare Source
v6.2.4Compare Source
Merged
whichcommand#154Fixed
whichcommand#153v6.2.3Compare Source
Commits
c43fa2bdc2d7dav6.2.2Compare Source
Commits
fc35f0dv6.2.1Compare Source
Merged
#143#142#141#138v6.2.0Compare Source
Merged
#134#136#131simonhaenisch/prettier-plugin-organize-imports (prettier-plugin-organize-imports)
v4.1.0: 4.1.0Compare Source
Bumped the peer dependency range for
vue-tscto^2.1.0because there was a breaking change in its API. If you're using Vue support, upgrade both packages simultaneously, e.g.npm i -D prettier-plugin-organize-imports vue-tsc.v4.0.0: 4.0.0Compare Source
Version
4.0.0upgrades/replaces the Volar packages used for Vue support, to use the latestvue-tscpackage that's part of Volar 2. To migrate, you just have to remove@volar/vue-typescriptand if you're using it, also@volar/vue-language-plugin-pug, and replace it withvue-tscand@vue/language-plugin-pugrespectively. There are no breaking changes other than this.Thanks @johnsoncodehk for contributing this 🎉
isaacs/rimraf (rimraf)
v6.0.1Compare Source
v6.0.0Compare Source
v5.0.10Compare Source
v5.0.9Compare Source
v5.0.8Compare Source
v5.0.7Compare Source
v5.0.6Compare Source
Configuration
📅 Schedule: Branch creation - "* 0-3 * * 1" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
This PR was generated by Mend Renovate. View the repository job log.