-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: migrate type tests to TSTyche #894
Conversation
} else { | ||
// this type is currently wrong, typescript cannot remove the case because the input is not restricted enough | ||
expectAssignable<unknown>(someNewDoc); | ||
expect<unknown>().type.toBeAssignable(someNewDoc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t know what type is expected, but you could use expect.fail()
here.
} else { | ||
// this type is currently wrong, typescript cannot remove the case because the input is not restricted enough | ||
expectAssignable<unknown>(someFoundDoc); | ||
expect<unknown>().type.toBeAssignable(someFoundDoc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also good candidate for expect.fail()
@@ -405,7 +411,7 @@ function testFilterFunctionsType() { | |||
public refArr?: typegoose.Ref<Nested>[]; | |||
} | |||
|
|||
expectType<{ | |||
expect<Pick<Root, keyof Root>>().type.toEqual<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can simply compared as two types, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if i see the context correctly, i think i made it explicitly as another type (not using Root
) to know if something changed without me knowing (like in mongoose)
Forgot to mention:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reaching out about the deprecation and a path forward (and a migration PR), but for now i cannot adopt tsyche because of the following reasons:
- tstyche's minimal nodejs is 18.0, but typegoose 11.x is 14.17 (which this PR is basing on) and typegoose 12.x (in the beta branch)'s minimal is 16.20, so it will likely take a while before being able to transition (minimal nodejs matches what mongoose supports)
- there are currently no problems using tsd-lite / jest-runner-tsd
the only annoyance / problem i have / had with tsd-lite is that expectError
will error in vscode - but the error is actually expected so it shouldnt error, does tstyche change this in some way? (i have not yet tested if adding just saw mrazauskas/tsd-lite#48)// @ts-ignore
/ // @ts-expect-error
solves this while still having a working test
also some other questions:
- does tstyche support just running it against the currently installed typescript version without explicitly defining it (as defined in the package.json)?
- does tstyche have some kind of jest integration (like tsd-lite)?
- tstyche seems to be in pre-release, are any breaking changes expected before full release?
@@ -405,7 +411,7 @@ function testFilterFunctionsType() { | |||
public refArr?: typegoose.Ref<Nested>[]; | |||
} | |||
|
|||
expectType<{ | |||
expect<Pick<Root, keyof Root>>().type.toEqual<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if i see the context correctly, i think i made it explicitly as another type (not using Root
) to know if something changed without me knowing (like in mongoose)
thanks for the response, i now understand that it currently does not use the current installed typescript version for me i only ever support a specific typescript version, because supporting multiple is a real pain and may not even work (example is typescript 4.9 which completely broke a specific functions type narrowing requiring the types to be completely rewritten for that function ( but i guess it is good to know if the current types will break in a future (not officially supported version) typescript version |
I had time to think a bit. It makes sense to down level the Node.js requirement. TSTyche has zero dependencies and this should be its strength. Depending on APIs like Perhaps let's leave this PR open for now? Thanks again for you feedback! |
i will leave it open, though it may get marked "stale" at some point
well it has to handle typescript, which has its own engine requirement (like typescript 5.1 requires nodejs 14.17) |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #894 +/- ##
=======================================
Coverage 98.65% 98.65%
=======================================
Files 17 17
Lines 967 967
Branches 261 261
=======================================
Hits 954 954
Misses 13 13 ☔ View full report in Codecov by Sentry. |
@hasezoey Just to draw your attention, I upgraded TSTyche to the latest beta. It has a new The lowest supported is now Node.js Also note that replacing Of course, there is no rush. I am opening the migration PRs to gather feedback and I try to listen to the users. Targeting the |
didnt mean to close this issue, have not noticed the stale tag (wheres the message?) |
Something new: in the latest beta of TSTyche First I made it possible to load the installed UPDATE I checked older runs in this repo. Now we have 3s instead of 4.1s earlier. |
Trying out freshly released A stable release is planned to be published in 2 weeks. |
TSTyche 1.0.0 is published. I have nothing more to add here (; |
i didnt intend it to get closed (i thought it would add a comment again, and forgot to add a tag), though i also didnt intend to immediately merge it soon - sorry about that |
Got it. Thanks for clarifying. Many matchers will be renamed in TSTyche 2. So better I will put together a fresh PR after |
Some time ago I recommended to use
jest-runner-tsd
, which is using forkedtsd-lite
to test types (#731). I am maintaining the latter package,tsd-lite
. The bad news is that it is being sunset, see Deprecation notice.The good news: recently I published TSTyche, a mighty type testing tool. I was developing it for two years. TSTyche is using the same TypeScript's type checker to compare types. The rest is different.
Repo: https://github.com/tstyche/tstyche
Documentation: https://tstyche.org
This PR is a proposal to. migrate to TSTyche. I think you will like it.
Testing on Specific TypeScript Versions
TSTyche can test on several versions of Typescript:
tstyche --target 4.9,5.0,latest
. This simple.Assertions
It ships
expect
style assertions. Two types or two inferred types can be compared:Performance
It is faster.