Skip to content
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

feat: support type imports #3706

Merged
merged 1 commit into from Jul 26, 2020
Merged

Conversation

SimenB
Copy link
Contributor

@SimenB SimenB commented Mar 24, 2020

Very rough start on #3695. Not sure how you want to handle this. I'll probably just do the ones we need at work (which means Apollo TS), but it should be fine to expand as we go?

(is there some watch mode I can run that builds as we go? right now I do a full yarn build every time I change something, which seems suboptimal)

@SimenB
Copy link
Contributor Author

SimenB commented Mar 24, 2020

Only reason for an option rather than being default behavior is that it requires TS 3.8. Maybe some "minimum TS version" rather than an explicit option makes more sense?

@dotansimha
Copy link
Owner

dotansimha commented Apr 6, 2020

This is awesome! Thank you @SimenB !

This could work, and could be optional via configuration. What about importing enums and other things? how is it effected? because mappers can import not only TS types

@SimenB
Copy link
Contributor Author

SimenB commented Apr 6, 2020

Are enums imported as values anywhere? The test should probably try to compile the module we generate with isolatedModules: true and importsNotUsedAsValues: error. I don't think I know enough about your setup to add that, though

https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function

@ardatan
Copy link
Collaborator

ardatan commented Apr 6, 2020

For example, there are const enums used as values not types. So I think import type would break this behavior.

@SimenB
Copy link
Contributor Author

SimenB commented Apr 6, 2020

const enum aren't supported by isolatedModules regardless, so I wouldn't want them 😃

@dotansimha dotansimha force-pushed the master branch 5 times, most recently from 3ec140a to 4f425e8 Compare June 11, 2020 14:14
@vatosarmat
Copy link

Any chances this useful feature to be merged? 😺
Since it is optional and disabled by default, it shouldn't break anything for anyone.

@dotansimha
Copy link
Owner

@vatosarmat merging :)
I'm merging it now, and will push some fixes soon to make sure all codebase supports that.

Thanks @SimenB , sorry it took so long.

@dotansimha dotansimha merged commit f389301 into dotansimha:master Jul 26, 2020
@theguild-bot
Copy link
Collaborator

The latest changes of this PR are available as alpha in npm: 1.17.5-alpha-f389301a.0

Quickly update your package.json by running:

npx match-version @graphql-codegen 1.17.5-alpha-f389301a.0

@SimenB SimenB deleted the type-import branch July 26, 2020 14:53
@SimenB
Copy link
Contributor Author

SimenB commented Jul 26, 2020

Thanks @dotansimha! I believe this was still incomplete, happy to hear you'll fix the missing parts 👍

I wanted to add some tests with isolatedModules: true and importsNotUsedAsValues: error, but didn't get around to it. I believe such tests would be quite useful to ensure no regressions. Never got around to it, though 😅

@SimenB
Copy link
Contributor Author

SimenB commented Jul 27, 2020

Tested this out now in the new release, and it works for some cases. However, it does not affect

@dotansimha My OSS backlog is really long right now, so I won't be able to work on this to properly polish it. 🤞 you can 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants