Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Supersedes #615
Fixes #791
This PR builds off of #615 with a number of additional tests and cases. High-level, it introduces a new option
keepUnusedImports
that disables all automatic import and export elision done by TypeScript, somewhat analogous to theverbatimModuleSyntax
TS option. For the most part, this is just a matter of flagging off the name tracking and elision codefor both imports and exports in the various places that they happen.
When this mode is enabled, some of the preprocessing steps can be skipped, and scope handling can be fully skipped with
the imports transform also disabled. Performance numbers measured by
yarn benchmark jest-dev
:imports
andtypescript
transforms: 855k -> 910k lines per second (6% faster)typescript
transform: 935k -> 1110k lines per second (19% faster)Some additional details:
flow-remove-types
won't do this, so SucrasekeepUnusedImports
matches the behavior offlow-remove-types
.onlyRemoveTypeImports
, whichseems to have the closest behavior.