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

Allow typeholes in other files #10

Open
andrew-ironforge opened this issue May 17, 2021 · 5 comments
Open

Allow typeholes in other files #10

andrew-ironforge opened this issue May 17, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@andrew-ironforge
Copy link

My biggest feature request would be to allow type holes to push output to other files. For example, I have a directory with the following structure:

Screen Shot 2021-05-17 at 2 55 13 PM

I would love to be able to create typeholes in each request that goes out to Quickbooks, and generate the types as the responses are received, and have those types go to internalTypes.ts instead of the file that the request was made in.

Loving the plugin so far! Really feels like it was developed by someone who understands that pain of not getting types from 3rd party APIs :) I could see this totally revolutionizing the creation of type files from existing Javascript libraries that have none...

@rikukissa
Copy link
Owner

Really feels like it was developed by someone who understands that pain of not getting types from 3rd party APIs

You got that right 😄

I wonder if that feature would make sense as a workspace-level configuration.. I've been meaning to add some code to typehole to resolve interface references not in the same file as your typehole. That should be relatively easy to do. When I have that feature in place, you should at least be able to create a placeholder type first to fileA.ts

export type MyPlaceholder = any

and then create a typehole with that type, so fileB.ts

const someValue: MyPlaceholder = typehole.t(someValue)

and the interface should now update in fileA

@rikukissa rikukissa added the enhancement New feature or request label May 18, 2021
@rikukissa
Copy link
Owner

The approach I described in the previous comment should be possible with the 1.5.1 version. Give it a try and see if something like this would be enough for your use case 🙂

@andrew-ironforge
Copy link
Author

Perfect! You're a legend.

@andrew-ironforge
Copy link
Author

I'll try it now

@bombillazo
Copy link

This feature would be awesome! I can confirm it works with relative imports, but not with aliased imports. It would be awesome if it supported alias imports as well :)

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

No branches or pull requests

3 participants