Skip to content

chore: introduce TSTyche for type testing#16024

Merged
vkarpov15 merged 6 commits intoAutomattic:masterfrom
mrazauskas:introduce-tstyche
Feb 23, 2026
Merged

chore: introduce TSTyche for type testing#16024
vkarpov15 merged 6 commits intoAutomattic:masterfrom
mrazauskas:introduce-tstyche

Conversation

@mrazauskas
Copy link
Contributor

Summary

Reference #15980

This PR is introducing TSTyche for type testing. Documentation: https://tstyche.org

For the beginning I only used the tool to check errors suppress by // @ts-expect-error.

The next possible step could be to test agains several TypeScript versions. For example, tstyche --target '>=5.6'. I would recommend adding that for CI only.

Since assertions are not touched, TS7 could be used in CI as well. TSTyche does not support TS7, because it does not have programmatic API yet.

@@ -1,4 +1,4 @@
import { Schema, model, Document, Model, Types } from 'mongoose';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not used.

schema.post('save', function(res) {
ExpectAssignable<HydratedDocument<IDocument>>()(this);
// @ts-expect-error res should be a document, no query type
// @ts-expect-error Type 'Document...' is missing the following properties from type 'Query...'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The messages can be truncated using .... This is a good example.

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

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

One minor question but otherwise I love it. This is awesome 😃

package.json Outdated
"test-rs": "START_REPLICA_SET=1 mocha --timeout 30000 --exit ./test/*.test.js",
"test-rs:ci": "npm run test-rs -- --reporter min",
"test:types": "tsc --project test/types/tsconfig.json",
"test:types": "tsc --project test/types/tsconfig.json && tstyche",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor question - is the tsc still required here? I think this script can just be "tstyche"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. In this case, tsc doesn’t do anything additional. I simplified the script.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great thank you! Merging 👍 🚀

@vkarpov15 vkarpov15 added this to the 9.2.2 milestone Feb 23, 2026
@vkarpov15 vkarpov15 merged commit 7c9a03e into Automattic:master Feb 23, 2026
29 checks passed
@mrazauskas mrazauskas deleted the introduce-tstyche branch February 24, 2026 05:28
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