rikukissa / typehole

TypeScript development tool for Visual Studio Code that helps you automate creating the initial static typing for runtime values

Home Page:https://marketplace.visualstudio.com/items?itemName=rikurouvila.typehole

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow typeholes in other files

andrew-ironforge opened this issue · comments

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...

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

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 🙂

Perfect! You're a legend.

I'll try it now

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 :)