Skip to content

V3#32

Merged
SerhiyGreench merged 5 commits into
masterfrom
v3
Jul 18, 2026
Merged

V3#32
SerhiyGreench merged 5 commits into
masterfrom
v3

Conversation

@SerhiyGreench

Copy link
Copy Markdown
Contributor

No description provided.

parseComment() used a greedy /\{([\s\S]+)\}/ regex to capture a tag's
{type}, so any later } in the description (e.g. a code span like
`{ id, name }`) extended the capture and corrupted or emptied the
inferred type, degrading generated client args to broken/any types.

Replace the regex with a depth-aware extractType() that captures the
leading brace type by matching braces by depth. This fixes braces in
descriptions while correctly preserving nested object-literal types
such as {{ x: number, y: number }} (which a naive non-greedy regex
would truncate at the first }).

Adds a regression test covering both a brace-in-description and an
object-literal parameter type.
The service description derives argument/return types exclusively from
JSDoc parsed out of Class.toString(). Dev runners that transpile on the
fly with comment stripping (tsx, ts-node/esbuild) erase that JSDoc, so
every exposed method silently degraded to 'any' in the description and
in generated clients.

Keep the runtime source as the primary type source, and add a dev-mode
fallback: the expose() factory captures the defining module's file path
from the call stack, and when the runtime class source yields no JSDoc
at all, method docs are re-extracted textually from that file on disk
(which may be TypeScript, unparseable by acorn) and fed through the
same JSDoc parser.

- runtime JSDoc always wins; disk is consulted only when runtime has none
- extraction misses degrade to current behavior (any), never corrupt
- no new dependencies; file reads are cached per path

Verified end-to-end under real tsx: a probe service run from .ts now
reports its documented types instead of 'any'.
Includes:
- fix(expose): parse JSDoc types with balanced braces
- feat(expose): recover JSDoc types from on-disk source in dev mode
@SerhiyGreench
SerhiyGreench merged commit b503680 into master Jul 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant