chore: use TSTyche assertions in the document type test#16068
chore: use TSTyche assertions in the document type test#16068vkarpov15 merged 3 commits intoAutomattic:masterfrom
document type test#16068Conversation
document type testdocument type test
|
|
||
| ItemSchema.pre('validate', function preValidate() { | ||
| ExpectType<Model<unknown>>(this.$model('Item1')); | ||
| expect(this.$model('Item1')).type.toBe<unknown>(); |
There was a problem hiding this comment.
Model<unknown> does not pass. The type seems to be plain unknown. Is that correct?
There was a problem hiding this comment.
Probably some type widening quirk - $model uses generics. I think we could just expect assignable here, or test const model: Model<unknown> = this.$model('Item1'), what do you think? I don't like expecting that the type is strictly unknown here
| expect(user.$model()).type.toBe<unknown>(); | ||
| expect(user.model()).type.toBe<unknown>(); |
There was a problem hiding this comment.
typeof User or simply .type.toBe(User) does not pass. The type seems to be plain unknown. Is that correct?
There was a problem hiding this comment.
Similar type widening. Maybe we just check assignability?
|
@vkarpov15 Thanks for feedback. I took a better look and found out the following. The argument of Two possible solutions:
What sounds better for you? Another detail. Right now I try to show that other unrelated APIs infer the |
|
I merged #16081 |
Summary
Same as #16067, but with some mismatch of expected types. Therefore, I think this needs an extra attention (see inline comments).