V3#32
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.