-
Notifications
You must be signed in to change notification settings - Fork 405
chore: use TSTyche for type testing #2234
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
@@ -72,6 +70,7 @@ | |||
"strip-ansi": "^6.0.1", | |||
"swc-node": "^1.0.0", | |||
"ts-jest": "^29.2.4", | |||
"tstyche": "^4.0.0-beta.6", |
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.
Only the latest version has .toBeCallableWith()
matcher. It is still in beta. Stable version will be available in month. CLI usage will not break any more.
@@ -33,19 +33,19 @@ expectAssignable<LinguiConfig>({ | |||
tsExperimentalDecorators: false, | |||
}, | |||
fallbackLocales: {} as FallbackLocales, | |||
format: "po", | |||
format: "po" as const, |
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.
The behaviour is the same as discussed here: https://github.com/lingui/js-lingui/pull/1622/files#r1178201302
More details in documentation: https://tstyche.org/reference/expect-api#type-widening
@@ -1,6 +1,7 @@ | |||
{ | |||
"compilerOptions": { | |||
"target": "ESNext", | |||
"module": "Node16", |
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.
This was required by TypeScript.
"scripts": { | ||
"test:tsd": "tsd" | ||
}, |
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.
There are no type tests in this package.
@@ -72,7 +72,7 @@ jobs: | |||
run: yarn test:ci:coverage | |||
|
|||
- name: Test Public Typings | |||
run: yarn test:tsd | |||
run: yarn test:types |
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.
As an example, you can state that TypeScript 5.4 and above is supported and run tests like this:
run: yarn test:types | |
run: yarn test:types --target '>=5.4' |
The tests will run agains each minor release, currently: 5.4
, 5.5
, 5.6
, 5.7
, 5.8
. New TypeScript versions are added automatically as soon as they are published to npm.
//////////////////////// | ||
//// React useLingui() | ||
//////////////////////// | ||
function MyComponent() { | ||
test("useLingui", () => { |
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.
Since diff looks even better, here I used the test()
helper instead of that comment (just for fun).
Description
This PR migrates type tests to TSTyche. As it was mentioned here: #2153 (comment)
How TSTyche is better?
typescript
package you already have installedtest()
anddescribe()
with.only
and.skip
tstyche file-name
), test against specific TypeScript version (tstyche --target 5.8
), range of versions (tstyche --target >=5.4
) and moreTry it out (;
Types of changes
Checklist