Suppose I'm writing a library in a statically typed language. I want to ensure that certain types of mistakes cause type errors, so my users are protected from the mistakes. I'd like tests (or something) that ensure that those mistakes cause type errors. How do I do it?
-
Show this thread
-
This is in the context of TypeScript. I'd rather not build all of the infrastructure to invoke the compiler and assert that it emits a certain error.
13 replies 0 retweets 15 likesShow this thread -
Replying to @garybernhardt
This is what we had to do in rust :/
1 reply 0 retweets 7 likes -
Replying to @steveklabnik @garybernhardt
really? like there's no internal API that takes a crate and returns a list of type errors?
2 replies 0 retweets 0 likes -
Replying to @mountain_ghosts @garybernhardt
too many compiler guts to make stable
2 replies 0 retweets 0 likes -
doing this correctly involves dealing with dependencies, which rustc doesn't know how to do anyway it's not even a matter of stability
2 replies 0 retweets 0 likes -
I'm surprised by this. I already know how to use the TypeScript compiler API to do this; I'd just rather reuse someone else's work if possible. I would've assumed that Rust has equivalent APIs.
2 replies 0 retweets 0 likes
I'm surprised TS has a stable compiler API.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.