ts-unused-exports
ts-unused-exports copied to clipboard
Add option to ignore exported names used only in same file
Currently ts-unused-exports
will emit an error about FooProps
if it's not imported in another file:
export interface FooProps {
// ...
}
class Foo extends React.Component<FooProps> {
// ...
}
I'd like to have a command-line option to change the behavior so that no error would be emitted for exported names that are only used in the same file where they're declared in.
One use case would be to allow my IDE (WebStorm) to offer auto-completion and auto-import if I need to use FooProps
in another file in the future, without having to edit the declaration of FooProps
first. FooProps
not being exported seems to prevent WebStorm from providing auto-completion and auto-import for it in other files.
Agreed. Especially since the main use for this tool is to detect unused code.
@emlai if it helps, there is now a feature to disable errors for a particular line:
// ts-unused-exports:disable-next-line
export interface FooProps {
// ...
}
How to name the option?
What about:
-
--onlyReportDeadCode
-
--ignoreIfUsedLocally
-
--ignoreLocallyUsed
(I like the last one)
I like --ignoreLocallyUsed
too.
Released in 9.0.5 !
thank you to @DLeyland for implementing this feature 🥇