Release Notes
This page lists breaking changes and notable new features. Please be sure to read the release notes before upgrading from a previous version.
The detailed changelog can be found in TSTyche repository on GitHub .
TSTyche 7.0
TSTyche 7.0 ships with the new .toBeInstantiableWith() matcher and redesigned tsconfig option.
Matchers
.toBeInstantiableWith()
Checks if a generic is instantiable with the given type arguments.
import { type , } from "tstyche";
interface <, = unknown> {
[: string]: (: ) => ;
}
<<>>()..<[void]>();
<<>>()..<[void, string]>();
<<>>()...<[]>();The _ type can be used to fill in the required type arguments.
This matcher works with generic interfaces, type aliases, classes and functions:
import { } from "tstyche";
function <, >(: <>, : (: ) => ): <> {
return .();
}
()..<[string, number]>();
()...<[string]>();.toRaiseError()
Breaking! The .toRaiseError() matcher is deprecated and planned to be removed. The suggested replacement is the ability matchers (like .toBeCallableWith() or .toBeConstructableWith()). They communicate the intent of a test more clearly and work without introducing type errors in the test code.
To learn more, see the Expect Errors page.
Configuration
Breaking! Default configuration file location has changed. Now ./tstyche.json is loaded instead of ./tstyche.config.json.
Schema
The configuration schema now ships with the package and can be referenced locally:
{
"$schema": "./node_modules/tstyche/schemas/config.json"
}Thanks to @f15u for the idea!
checkSuppressedErrors
TSTyche now checks errors suppressed by @ts-expect-error directives in multi-line comments.
This is useful in contexts where single-line comments are not supported. For example, in TSX files:
function ProfileCard(props: { userName: string }) {
return <>{props.userName}</>;
}
<>
{/* @ts-expect-error Type 'boolean' is not assignable to type 'string'. */}
<ProfileCard userName={true} />
</>;rootPath
Breaking! The rootPath configuration option is removed.
The root directory now defaults to the current directory. To use a different path, pass it with the --root command line option.
tsconfig
baseline is the new name of ignore.
{
- "tsconfig": "ignore"
+ "tsconfig": "baseline"
}Inline JSON
TSConfig can be provided as an inline JSON string.
Configuration file:
{
"tsconfig": "{\"extends\":\"./tsconfig.json\",\"compilerOptions\":{\"lib\":[\"es2020\"]},\"include\":[\"**/*\"]}"
}Command line:
tstyche --tsconfig '{"extends":"./tsconfig.json","compilerOptions":{"lib":["es2020"]},"include":["**/*"]}'Programmatic Usage
Breaking! The tstyche/tstyche entry point is renamed to tstyche/api.