plantain-00/type-coverage

Inaccurate any after non-null assertion

Closed this issue · 4 comments

danvk commented

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

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

danvk commented

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.

v2.16.2 should fix this

danvk commented

fix confirmed, thanks!