Feature Request: Support type-aware code generation via plugins #11059
escaton
started this conversation in
Plugin request / idea
Replies: 2 comments 1 reply
-
I'm open to maintaining it if someone implements an initial version and send a PR |
Beta Was this translation helpful? Give feedback.
1 reply
-
@Hookyns I saw your comments in microsoft/typescript-go#455 (reply in thread) I think this could be relevant to your plans for Rttist? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
I've recently experimented with typia (+ nestia) in a NestJS backend project, and was impressed by how clean the developer experience is:
This leads to a much cleaner codebase compared to decorator-heavy approaches.
In short, this is what Typia build pipeline does:
typia.assert<T>()
, etc.).<T>
into full type info.The Problem
Currently, Typia depends on the TypeScript compiler itself and ts-patch to inject its logic.
This has two limitations:
Worth noting that what is really needed from Typescript in this whole thing is: just to resolve the type info at a given place in the source.
Proposal
Typia-style AoT type-aware transformations could live directly in the SWC plugin system, instead of requiring a separate build step with additional tooling.
Benefits of doing this inside SWC:
What's possible today:
Thanks to #9132, plugins can now consume the TypeScript AST.
What's missing:
A way for plugins to access type information (via a TS/ts-go service or their own).
Open Questions
Plugin <-> Type Service communication:
WASI (wasip1) currently does not allow spawning subprocesses for IPC, so plugins cannot directly start a tsserver/LSP process.
Is there any way for a plugin to act as (or connect to) a singleton service to handle type queries across files?
Possible approaches:
Plugins manage their own TS service (preferred):
SWC provides a standard type-service interface:
I lean toward (1) because it gives plugins more flexibility, but I’d love to hear your perspective on feasibility.
Why This Matters
If this works, it would unlock a new class of type-driven AoT code generators in the SWC ecosystem — enabling projects like Typia (and others we haven’t seen yet) to run without tying themselves to current tsc internals.
Beta Was this translation helpful? Give feedback.
All reactions