Skip to content

feat: add the .toBeInstantiableWith() matcher#399

Merged
mrazauskas merged 46 commits intomainfrom
add-toBeInstantiableWith
Mar 2, 2026
Merged

feat: add the .toBeInstantiableWith() matcher#399
mrazauskas merged 46 commits intomainfrom
add-toBeInstantiableWith

Conversation

@mrazauskas
Copy link
Member

@mrazauskas mrazauskas commented Jan 4, 2025

Adding the .toBeInstantiableWith() matcher, which will be able to check if the generic type can be instantiated with the given type arguments.

import { type _, expect } from "tstyche";

interface Matchers<R, T = unknown> {
  [key: string]: (expected: T) => R;
}

expect<Matchers<_>>().type.toBeInstantiableWith<[void]>();
expect<Matchers<_>>().type.toBeInstantiableWith<[void, string]>();

expect<Matchers<_>>().type.not.toBeInstantiableWith<[]>();

Also the _ type is added which is useful to fill in the required type arguments of generic types.

The matcher handles generic type aliases, interfaces, functions and classes.

@codacy-production
Copy link

codacy-production bot commented Jan 4, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.05% (target: -1.00%) 98.90% (target: 85.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (ba28c48) 7400 7283 98.42%
Head commit (bfaf2c7) 7562 (+162) 7446 (+163) 98.47% (+0.05%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#399) 182 180 98.90%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@mrazauskas mrazauskas marked this pull request as ready for review March 2, 2026 08:56
@mrazauskas mrazauskas enabled auto-merge (squash) March 2, 2026 12:31
@mrazauskas mrazauskas merged commit 0ee3a2c into main Mar 2, 2026
37 of 38 checks passed
@mrazauskas mrazauskas deleted the add-toBeInstantiableWith branch March 2, 2026 12:39
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.

1 participant