You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey and thanks for this lib - I started using it to day, coming from using plain .ts files with typed variable assignments & forced errors with // @ts-expect-error on top. It worked well, but I want to get to something more structured.
I see I also have to use // ts-expect-error to catch expected errors in ts-expect-error, which is fine.
I'm also in the habit of documenting the expected errors, like we do in out code tests, but it's purely for documentation & future reference, as it's not possible to be checked. For example:
const identity = <T>(val: T): T => val
// @ts-expect-error: TS2322: Type number is not assignable to type string
const str: string = identity(123)
In ts-expect we have the expectType<number>("test"); // Compiler error example, but we don't document the error somehow, so it can be checked.
An exotic new version could support something like:
expectTypeError<number>("test", `TS2345: Argument of type string is not assignable to parameter of type number`);
and perhaps do some magic to obtain error codes & descriptions.
I know this is much much harder, and probably not just a lib, as it perhaps would have to incorporate information from the IDE or TS compiler to do the trick, but there might be a way ;-) Maybe an IDE plugin? Who knows!
Anyway, just a thought, just sharing!
The text was updated successfully, but these errors were encountered:
much more useful than simple expectType, but when it fails during development it doesn't show the real error, instead it only shows TS2345: Argument of type true is not assignable to parameter of type false.
I resort to assignment to a variable, which is not always desirable... I think if this is fixed in will make the library 5x more useful!
Definitely agree with both of these, and I'll keep them in mind if anyone else wants to work on it or I find time, but I think they both require hooking into the TypeScript compiler directly.
Hey and thanks for this lib - I started using it to day, coming from using plain .ts files with typed variable assignments & forced errors with
// @ts-expect-error
on top. It worked well, but I want to get to something more structured.I see I also have to use
// ts-expect-error
to catch expected errors ints-expect-error
, which is fine.I'm also in the habit of documenting the expected errors, like we do in out code tests, but it's purely for documentation & future reference, as it's not possible to be checked. For example:
In
ts-expect
we have theexpectType<number>("test"); // Compiler error
example, but we don't document the error somehow, so it can be checked.An exotic new version could support something like:
and perhaps do some magic to obtain error codes & descriptions.
I know this is much much harder, and probably not just a lib, as it perhaps would have to incorporate information from the IDE or TS compiler to do the trick, but there might be a way ;-) Maybe an IDE plugin? Who knows!
Anyway, just a thought, just sharing!
The text was updated successfully, but these errors were encountered: