-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for TS type-only imports and exports (#532)
Fixes #520 The PR #523 already added parsing support for type-only import and export syntax, and there was already support for removing `import type` from Flow, so the only new logic was to fully support `export type`. The implementation here is a little ugly; Flow's version sets the tokens as type tokens, whereas the TS version sets the types as regular tokens and removes them at transform type. This seems to be necessary to follow the behavior that `export type` statements do not result in the imported value being elided. Ideally, Sucrase would support the `importsNotUsedAsValues` TS preference in some way, but for now, it keeps the old behavior of eliding type-only imports. The setting `importsNotUsedAsValues=error` should make the distinction irrelevant anyway, so it seems low priority to support.
- Loading branch information
1 parent
0a8413a
commit aae7da0
Showing
3 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters