Closed aspirisen closed 4 years ago
I agree, as long as this a behavior you can opt-in / out with a command-line switch.
Having floating types that are unused can make large code-bases hard(er) to follow (e.g. multiple copies of similarly-named interfaces with slightly different implementations).
That being said, your use-case makes perfect sense and we should support it.
What is the best name for such an option?
Could be:
(default is off)
I prefer excludeCompileTimeTypes as its more general/future proof
I prefer excludeCompileTimeTypes as its more general/future proof
Agreed, but here are two more to consider:
excludeTypes
(since all types in TS are compile-time)allowUnusedTypes
Yes - allowUnusedTypes
Is this literally only for type
and interface
?
(not for class
for example)
Well, unlike type
and interface
, class
is a runtime construct so pining this unused type does have runtime implications (even if only a bloated bundle).
IMO we should exclude only type
and interface
. That should cover the scenario that inspired this issue (the PropTypes
interface for a react component).
If there is enough interest to actually allow unused classes we can talk about it in a separate issue (and a separate option).
I think it would be good to exclude from result things that doesn't affect runtime like interface or type. For example I have a file where i export react functional component and export interface with its props, this interface can be unused but it is ok, it just in case, but if the function is unused it is important.