-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Use import type
in typescript for all imports
#4029
Conversation
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.
Thank you for PR! This looks good to me!
Can you add a test for these changes?
412acee
to
91df62e
Compare
js_module_format: JsModuleFormat::Haste, | ||
typegen_config: TypegenConfig { | ||
language: TypegenLanguage::TypeScript, | ||
use_import_type_syntax: true, |
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.
This is the only difference to the typescript
fixtures. I wasn't able to use the %project_config%
form of specifying the config in each, because that ends up in a dependency cycle.
The fixtures in relay_codegen
also aren't quite appropriate, because they only check the metadata content, not the entire file, and I need to check the imports
Those "other paths for implementation" mentioned would cover where this is done, but would be a significant reshuffle of code
@alunyov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
1ddd84f
to
05592c8
Compare
@alunyov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
05592c8
to
33e1a7c
Compare
Removed the missing newline at EOF, because I'm guessing that was the internal lint warning |
Hmm, @tomgasson for some reason this breaks one of the internal typescript tests (we should probably move these to OSS) It removes the import type of
|
Hmmm. Are those tests using It's a bit hard to see how this change would remove something if it's only the relay generated output |
33e1a7c
to
22c8e13
Compare
22c8e13
to
ddb288f
Compare
This makes the following change to typescript artifacts:
Using the existing
useImportTypeSyntax
config.As stated in the config, the
import type
syntax introduced in Typescript version 3.8 and prevents warnings fromimportsNotUsedAsValues
. This setting also assists naive bundlers from taking a dependency onrelay-runtime
, when only the types are needed.I kept this simple. Other paths for implementation would be
write_import_type
function