Implement "export type {}"#11122
Merged
nicolo-ribaudo merged 2 commits intobabel:feat-7.9.0/ts-import-typefrom Feb 18, 2020
Merged
Implement "export type {}"#11122nicolo-ribaudo merged 2 commits intobabel:feat-7.9.0/ts-import-typefrom
nicolo-ribaudo merged 2 commits intobabel:feat-7.9.0/ts-import-typefrom
Conversation
JLHwung
reviewed
Feb 10, 2020
| @@ -0,0 +1 @@ | |||
| export type { T } from './mod'; | |||
Contributor
There was a problem hiding this comment.
Can you add a new test
export type from "./mod"where both exportDefaultFrom and typescript are enabled? So we can cover the situation when this.isContextual("type") is true but the lookahead char is not left bracket.
nicolo-ribaudo
commented
Feb 10, 2020
| { | ||
| "plugins": ["exportDefaultFrom", "typescript"], | ||
| "sourceType": "module", | ||
| "throws": "Unexpected token, expected \"=\" (1:17)" |
Member
Author
There was a problem hiding this comment.
Did this work before this PR?
Contributor
There was a problem hiding this comment.
It throws before this PR because isExportDefaultSpecifier returns false
It may be copied and revised from flow plugin. I think we should consider relax the constraint unless banned by the export-default-from proposal.
JLHwung
approved these changes
Feb 17, 2020
kaicataldo
approved these changes
Feb 17, 2020
nicolo-ribaudo
added a commit
that referenced
this pull request
Feb 26, 2020
* [typescript] Implement "export type {}"
* test: add test on default-type-with-typescript
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
nicolo-ribaudo
added a commit
that referenced
this pull request
Mar 2, 2020
* [typescript] Implement "export type {}"
* test: add test on default-type-with-typescript
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
nicolo-ribaudo
added a commit
that referenced
this pull request
Mar 16, 2020
* Add support for type only imports in TS (#11053) * Implement "export type {}" (#11122) * Add "exportKind: type" when needed with TS (#11157) * Add `onlyRemoveTypeImports` option to `transform-typescript` (#11173) * Add onlyRemoveTypeImports to preset-typescript (#11179) Co-authored-by: Brian Ng <bng412@gmail.com> Co-authored-by: Raja Sekar <rajasekarm.dev@gmail.com> Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com> Co-authored-by: Kai Cataldo <kai@kaicataldo.com> Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com> Co-authored-by: Henry Zhu <smiley.we@gmail.com> Co-authored-by: Siddhant N Trivedi <sidntrivedi012@gmail.com>
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Implement
export type { A }andexport type { A } from "mod"new TypeScript syntax in parser, transform and generator.When this syntax is used, the AST nodes have an
exportKind: "type"property, otherwise it is set toexportKind: "value".TODO (different PR):
exportKind: "type"for type-only export decarations likeexport type A = 2orexport interface B {}, etc.