This is not possible, as typescript (still, unfortunately) doesn't support runtime code generation for its type information.
Nevertheless, ChatGPT tried various approaches to "make it work". It reminded me very much of a brainstorming session with Junior Engineers.
I couldn't get it to simply state "Not possible". Even after four iterations.
Could share the conversation, but would prefer to only share if someone wants me to.
TL;DR: LLMs, even the most sophisticated ones, continue to disappoint and underdeliver¹. Posting this as a former ChatGPT4-Enthusiast. I still think we're using LLMs in the wrong way and do not exploit the full potential yet, and there is space (lots of!) to improve, or alternatively, there are limits to accept.
¹ in this case, it's really easy to pinpoint why the answer is wrong because it requires just a little bit of knowledge of the specific technology. But a so-easy-to-spot error, produced by the most expensive, hardest-to-train LLM model we currently have is a telltale sign that something is off. And will continue to be off, even for ChatGPT5.