For the TS compiler: If you took each generation step, closed any partial JSON objects (ie close any open `{`), checked that it was valid JSON and then validated it using a deep version of Partial<T>, that should do the trick.
Eg, given even the type:
{"aLongerKey": "value"}
The generation prefix: {"a
would by your algorithm produce the following invalid output: {"a}