Will TypeScript compiler still remove unused imports by default after deprecating `preserveValueImports`?

28 Views Asked by At

As title. I was trying to find the exact source of statement about whether TypeScript tsc command will remove unused imports by default. I found and confirmed it. But now I have a new question as the title. To be clear let me restate it again:

Since the default behaviour relies on an option preserveValueImports that is deprecated in favor of verbatimModuleSyntax, would the default behaviour of TypeScript tsc change in the future, i.e. not removing unused imports? Tried with nightly playground and unused imports are still removed.

By reading the PR it seems that removing unused imports has been the default since 2015: https://github.com/microsoft/TypeScript/issues/2812. Unfortunately, the two links to the language specs are dead.

1

There are 1 best solutions below

0
NeoZoom.lua On

Yes, for now.

While it might not be clear at first, you can always test it in the playground. At nightly version
v5.5.0-dev.20240309, the value of preserveValueImports is ignored in favor of the value of verbatimModuleSyntax you have mentioned and it's default to false currently at the time of my writing.