New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support TypeScript 4.5 type-only import/export specifiers #13802
Merged
nicolo-ribaudo
merged 27 commits into
babel:main
from
sosukesuzuki:type-only-import-specifier
Oct 28, 2021
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
9b91e84
Implement parser
sosukesuzuki 1b20596
Add parser tests
sosukesuzuki 8daf3bc
Implement generator
sosukesuzuki 16b4bc1
Add generator tests
sosukesuzuki a2edbe3
Implement types
sosukesuzuki 6421008
Implement plugin-transform-typescript
sosukesuzuki 6a596b9
Add plugin-transform-typescript tests
sosukesuzuki 4929209
Remove imported-type from exports
sosukesuzuki d337f69
Use string literal instead of variable
sosukesuzuki 8cb6dc0
Use set instead of array
sosukesuzuki 4d1cde6
Keep import statement if all of specifiers are type-only one
sosukesuzuki 05d5183
Rename isTypeOnly to hasTypeSpecifier
sosukesuzuki 31b273c
Use isContextual instead of string comparison
sosukesuzuki ec6398e
Use tokenIsKeywordOrIdentifier instead of match
sosukesuzuki 6b79fd1
Remove import statement if all of specifiers are type-only one
sosukesuzuki 72b3c3b
Merge branch 'main' into type-only-import-specifier
sosukesuzuki ebf0a58
Fix type errors
sosukesuzuki d5c69eb
Merge branch 'main' into type-only-import-specifier
sosukesuzuki d459c8b
Extract parseExportSpecifier
sosukesuzuki 519f977
Extract parameters
sosukesuzuki cb0f943
Move the logic for error
sosukesuzuki 91918b7
Refactor exports
sosukesuzuki d074010
Refactor imports
sosukesuzuki ab1f5c2
Fix lint comments
sosukesuzuki c44171a
Fix babel-parser/types.js
sosukesuzuki bfd0f9d
Throw error for string local for import
sosukesuzuki 1f933af
check lval
sosukesuzuki File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
1 change: 1 addition & 0 deletions
1
packages/babel-generator/test/fixtures/typescript/type-only-export-specifier/input.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { type foo } from "foo"; |
1 change: 1 addition & 0 deletions
1
packages/babel-generator/test/fixtures/typescript/type-only-export-specifier/output.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { type foo } from "foo"; |
1 change: 1 addition & 0 deletions
1
packages/babel-generator/test/fixtures/typescript/type-only-import-specifier/input.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import { type foo } from "foo"; |
1 change: 1 addition & 0 deletions
1
packages/babel-generator/test/fixtures/typescript/type-only-import-specifier/output.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import { type foo } from "foo"; |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to avoid mixing TS/flow-specific code in the main parser, when possible.
Would it be possible to move
type
handling inparseModuleExportName()
? Or maybe we reorganize it like this:and in
typescript/index.js
This is similar to what we do for imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little different from the interface you suggested, but I modified it based on that. Please review again.
commits:
(Sorry for many commits..)