canadaduaneC
Denoβ€’14mo agoβ€’
1 reply
canadaduane

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>>;
}


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!
Was this page helpful?