canadaduane
canadaduane3w ago

How to reveal a long inferred type in order to publish to jsr

I've published a package to jsr (@schoolai/ts-prompt) and everything went well. Now, I'm improving the package and I have a function whose type is quite complex. Typescript is inferring its type correctly. However, when I go to publish to JSR, I get the "this function is missing an explicit return type" error/warning. Normally, I would just hover over the function in my editor (Zed, in this case) and it would oblige and show me the full inferred type--I'd then copy paste it into the code and call it a day. However, now that I have a very large/complex type, the editor elides some of the type information:
const buildInferenceFunctionsForOpenAI: <OpenAI extends OpenAIInterface>(openai: OpenAI) => {
$inferImage: (renderedTemplate: string, request: ImageParamBody) => Promise<ImageResult>;
... 5 more ...;
respondWithJson: <T extends ZodType>(schema: T) => (params: ChatParams) => Promise<z.TypeOf<T>>;
}
const buildInferenceFunctionsForOpenAI: <OpenAI extends OpenAIInterface>(openai: OpenAI) => {
$inferImage: (renderedTemplate: string, request: ImageParamBody) => Promise<ImageResult>;
... 5 more ...;
respondWithJson: <T extends ZodType>(schema: T) => (params: ChatParams) => Promise<z.TypeOf<T>>;
}
What tool or method can I use to retrieve the full inferred type, so I don't have to figure this out manually just to publish to JSR? Thank you!
1 Reply
canadaduane
canadaduaneOP3w ago
Not sure if this is helpful to others, but I ended up using dnt to create a node package out of my deno package, and that shipped a few .d.ts files that I was able to inspect and get the types from. Not ideal, but at least it works.