lit-analyzer
lit-analyzer copied to clipboard
[lit-analyzer] no-missing-import should have the ability to ignore inferred type-only imports
Consider this code:
import {List} from '@material/mwc-list';
interface Foo {
node: List;
}
// elsewhere...
class MyElement extends LitElement {
render() {
return html`<mwc-list></mwc-list>`;
}
}
lit-analyzer will detect this as having imported mwc-list
correctly.
though because we have imported and used only the type, it will be dropped once we transpile the code. This means mwc-list
will never actually be imported or defined.
In #139 i fixed this partially in that we ignored type-only imports. This means the following change would work:
import type {List} from '@material/mwc-list';
In this case, lit-analyzer will detect we haven't actually imported mwc-list
and will error.
Not everyone uses type-only imports, so it would be very helpful if we could do the same but for inferred type-only imports (i.e. infer that it is only used as a type and ignore it if so).