Is there a way to check the types coverage?

Not the code coverage (which checks the coverage of unit tests), but the types coverage (what is typed, what isn’t, what uses an any…)

[original thread by Mathieu Agopian]

We are not yet using tscov in Theia. I do not know if we plan to. What is your use-case? Why do you need it?

[Mathieu Agopian]

Well my question is somewhat controversial: typescript (and the types) are somewhat of a chore (a bit like unit test). And if we use unit tests coverage, it’s to have a sense of “how safe the codebase is” (how tested it is).
With types, it’s a bit the same, we try to have a safer codebase… but there are so called type black holes (this post is about flow, but I believe it also applies to typescript on this specific matter, and i’ve seen many uses of any in the code).
If I understand correctly, this means that some types are rendered useless, lowering the “gain/loss” ratio of using types.

[Mathieu Agopian]

So I guess my question is: do we have a rough indication of how “safe” the codebase is (thanks to the types), and how to make it “safer”, to benefit more from the types.

[Mathieu Agopian]

note from my own experience: on a past project at Mozilla we started using flow. But after some time, we realized that (in part because of those type black holes) the pain and effort needed to use the types didn’t make up for the safety in exchange (we had all the drawbacks, but few to no benefits). So we decided to drop flow.

[Mathieu Agopian]

also some context: I use elm daily, which is a strongly statically typed language, that requires full typing (no any, so no types black holes). This means that you get the full benefit from the types (and also that you need somewhat more efforts to write the code in the first place).

I personally prefer using types because they are communicating to readers and more importantly to the tooling not so much because of safety.

But we use types everywhere, and yes sometimes the appropriate type is any. If you see something in the code base that should be better typed, please go ahead and create a PR.

[Mathieu Agopian]

@svenefftinge what tooling are you referring too? The compiler that helps you understand the (potential) issues in the code you’re writing?

the language service (content assist, find references, etc.) But also compiler errors, yes.

[Mathieu Agopian]

ah, i understand, in the editor, yes indeed