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
docs: add onlyRemoveTypeImports to (preset|plugin-transform)typescript #2185
Conversation
Deploy preview for babel ready! Built with commit 183d619 |
It's not critical, but I personally think we should backport :) |
@existentialism Which parts do you think we should backport? Everything but the new option? |
We should also add the equivalent tsc option to the "TypeScript Compiler Options" section. |
docs/plugin-transform-typescript.md
Outdated
@@ -198,6 +206,8 @@ equivalents in Babel can be enabled by some configuration options or plugins. | |||
``` | |||
- `--importHelpers` | |||
This is the equivalent of the `@babel/plugin-transform-runtime` package. | |||
- `---importsNotUsedAsValues` | |||
You can the `onlyRemoveTypeImports` option to replicate this behavior. `onlyRemoveTypeImports: true` is equivalent to `importsNotUsedAsValues: preserve`, while `onlyRemoveTypeImports: false` is equivalent to `importsNotUsedAsValues: remove`. There is no equivalent for `importsNotUsedAsValues: error`. |
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.
Does this seem correct/clear?
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.
Maybe we can't mention that onlyRemoveTypeImports: false
isn't 100% accurate because we don't do any type analysis, and link to babel/babel#8361 as an example? Also, it's the reason why we don't support importsNotUsedAsValues: error
.
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.
Do you mind clarifying what you mean?
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.
Sure!
Consider this example:
// dep.ts
export type T = string;
// main.ts
import { T } from "./dep";
export { T };
onlyRemoveTypeImports: false
leave main.ts
as-is, because we don't have the type information necessary to understand that T
is a type.
However, TypeScript's importsNotUsedAsValues: remove
transforms it to an empty file because it knows that T
is a type.
Thanks for the comments! Ready for re-review :) |
Co-Authored-By: Brian Ng <bng412@gmail.com>
Thanks for updating this! |
Refs babel/babel#11173 (comment)
This PR adds documentation for the new
onlyRemoveTypeImports
configuration option in the upcoming 7.9.0 release.Questions: