Skip to content

Conversation

@mrazauskas
Copy link
Contributor

@mrazauskas mrazauskas commented Sep 23, 2025

This PR slightly improves type tests (as well as type definitions) and updates tstyche to latest beta. The release notes are here: https://tstyche.org/releases/tstyche-5


I would recommend testing types using most challenging compiler option. For instance, enabling exactOptionalPropertyTypes and noUncheckedIndexedAccess reveals some issues with type definitions. I have fixed these, of course.

Might be enabling these options was not possible with [email protected]. It was checking source files using the same TSConfig. That is too much, because tsc does that job already. This behaviour is removed in TSTyche 5. Now only the .d.ts files are checked.

I would also recommend avoiding brackets notation when testing types of properties. The brackets notation does not allow checking wherever a property is marker optional or readonly. And it adds | undefined to type of each property. Try playing with the AsyncMessage type (that I had to fix after refactoring the test).


And final news! The .tobeCallableWith() matcher now can be used to test types as per your request (tstyche/tstyche#592). This change was just published today (not yet documented, I was rushing because of my vacation).

The following example you provided, now works as expected:

expect<EnqueueFn<(arg: string) => string>>().type.toBeCallableWith("hello");
expect<EnqueueFn<(arg: number) => string>>().type.toBeCallableWith(1);
expect<EnqueueFn>().type.toBeCallableWith();

Not included in this PR. Left it for you to try out (;

@webJose webJose requested a review from Copilot September 23, 2025 14:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors type tests to improve reliability and updates tstyche to the latest beta version. The changes enable stricter TypeScript compiler options and update test syntax to avoid issues with optional property handling.

  • Updates tstyche from version 4.3.0 to 5.0.0-beta.2
  • Enables stricter TypeScript compiler options (exactOptionalPropertyTypes and noUncheckedIndexedAccess)
  • Refactors type tests to use Pick utility types instead of bracket notation for better type checking

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.

File Description
package.json Updates tstyche dependency and simplifies test command
tests/typetests/tsconfig.json Enables stricter compiler options and updates module settings
tests/typetests/index.test.ts Refactors type tests to use Pick utility and removes callable tests
src/misc/Queue.ts Adds explicit return type annotations to methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@webJose
Copy link
Contributor

webJose commented Sep 24, 2025

Thanks for the PR and the pointers/lessons on typing. Much appreciated!

@webJose webJose merged commit eeda51e into WJSoftware:main Sep 24, 2025
1 check passed
@mrazauskas mrazauskas deleted the update-type-tests branch September 24, 2025 08:37
@mrazauskas
Copy link
Contributor Author

You are welcome. Ping me with any questions, please. I learn by looking at real world usage.

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.

2 participants