plantain-00 / type-coverage

A CLI tool to check type coverage for typescript code
MIT License
1.26k stars 44 forks source link

Inaccurate any after non-null assertion #83

Closed danvk closed 3 years ago

danvk commented 3 years ago

Version(if relevant): 2.16.0

Environment(if relevant):

Code(if relevant):

document.querySelector('#toggle')!.addEventListener('click', e => {
  e.preventDefault();
}

Expected:

no anys

Actual:

e and preventDefault are flagged as having any types.

Maybe this is the same as #80, I couldn't quite tell.

I ran

type-coverage --ignore-catch --ignore-unread
plantain-00 commented 3 years ago

It should be --ignore-non-null-assertion rather than --ignore-unread

danvk commented 3 years ago

I put together a full repro here: https://gist.github.com/danvk/483d281abe0604e953872caba40ea505

I can only reproduce this issue if I add an exclude section to my tsconfig.json. Removing that section (even if it's an empty list) makes this work correctly. I tried passing --ignore-non-null-assertion but it had no effect.

plantain-00 commented 3 years ago

v2.16.2 should fix this

danvk commented 3 years ago

fix confirmed, thanks!