Closed
Labels
SuggestionNew feature or requestNew feature or request
Description
Typechat currently assumes that schemas are self-contained in one file. In reality, schemas are often spread out over multiple files. Ideally, typechat would enable the usage of multi-file schemas out of the box by resolving imports before stringifying the result.
Reacted by scal
Metadata
Metadata
Assignees
Labels
SuggestionNew feature or requestNew feature or request
Activity
robgruen commentedon Nov 5, 2026
I think the idea behind keeping it single file is to that the schema is self contained. This lets you easily track it's token size and keep ancillary types out of the prompt. If we were to allow schemas that span multiple files we would have to re-compose the schema into a single string that has just the schema necessary for the prompt. Ideally don't want to include schemas in the prompt that are not going to be used because that could affect the models attention and eat up context. A multi-file allowance could pull in all sorts of things that we would then have to filter out or otherwise recompose into just the schema the model needs for it's translation.
In places where we use TypeChat heavily (https://aka.ms/TypeAgent) the translation schemas are leaf files (i.e. they are imported by other schemas, not the other way around). We have not yet encountered a scenario where you cannot accomplish translation with something that needs multiple files.
Is there a specific scenario you want to support or is this just a "nice to have?"
robgruen commentedon Nov 6, 2026
/typechat reply
github-actions commentedon Nov 6, 2026
You can author your application types across multiple files, but the built-in TypeScript validator currently needs a self-contained schema string. createTypeScriptJsonValidator places that string in an isolated, in-memory schema file, and the default translator includes the same text in the prompt. It does not load imported files from your project.
A build step that combines only the target type and the types it needs could supply that string through the existing API. It would need to preserve useful type comments and resolve names correctly; simply concatenating files is not generally enough. Keeping that output focused addresses the prompt-size concern raised above, while preserving the schema checks performed before a model request.
pcdeadeasy's existing multiSchema example handles a different case: routing requests to separate schemas, rather than assembling one schema from imported types.
Could you share a small, non-sensitive example showing the target type, its imports, and what becomes difficult to maintain as a self-contained translation schema? Would generating a focused schema during your build meet the need, or must imports be resolved when the application runs?
Related contributions: #172, #460.
Automated response requested by the project owner. This does not accept work or authorize implementation.
robgruen commentedon Nov 10, 2026
:) This request is >3years old so it may no longer apply. I'm going to close this issue out due to it being stale. Please reopen or open a new issue if you'd like to pursue this further.