apollo-tooling icon indicating copy to clipboard operation
apollo-tooling copied to clipboard

generate `import type` instead of `import`

Open jimisaacs opened this issue 2 years ago • 5 comments

Hello, this is my attempt to fix codegen to be able to use "importsNotUsedAsValues": "error" in tsconfig.json. It definitely fixes my codebase, which is a pretty gigantic codebase.

At first I thought of maybe doing a more robust solution, but then I thought, I don't think the codegen actually needs any other type of import other than import type.

TODO:

  • [ ] Update CHANGELOG.md* with your change (include reference to issue & this PR)
  • [ ] Make sure all of the significant new logic is covered by tests
  • [ ] Rebase your changes on master so that they can be merged easily
  • [ ] Make sure all tests and linter rules pass

*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.

jimisaacs avatar Aug 22 '21 14:08 jimisaacs

@jimisaacs: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

apollo-cla avatar Aug 22 '21 14:08 apollo-cla

Thanks for your help on this @hwillson !!!

jimisaacs avatar Aug 26 '21 20:08 jimisaacs

Thanks for working on this @jimisaacs. Since this is a breaking change we'll have to be careful with how it's rolled out. We're discussing those plans internally, and will get back to you shortly.

hwillson avatar Aug 27 '21 14:08 hwillson

+1 for this change. If there is any help needed, please ping me.

Also, if this breaking change seems like a large step forward, an intermediate solution could be to introduce a config setting that would indicate if the generation would create import type or just import.

jakubzitny avatar Sep 01 '21 14:09 jakubzitny

@hwillson any update on the internal discussions? :) We really need this, we depend on codegen in our continuous integration flows. Thanks!

the21st avatar Nov 03 '21 13:11 the21st