Skip to content

Commit 87aebfb

Browse files
committed
fix(types): default typeMap to empty Map for non-TS native results (#569)
patchNativeResult now initializes typeMap to an empty Map when the native engine omits it (common for Python, Go, Rust, etc.), ensuring the returned object satisfies the ExtractorOutput contract and callers can safely access .entries()/.size without null checks.
1 parent 92ce3c0 commit 87aebfb

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/domain/parser.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,12 @@ function patchNativeResult(r: any): ExtractorOutput {
303303
}
304304
}
305305

306-
// typeMap: native returns an array of {name, typeName}; normalize to Map
307-
if (r.typeMap && !(r.typeMap instanceof Map)) {
306+
// typeMap: native returns an array of {name, typeName}; normalize to Map.
307+
// Non-TS languages may omit typeMap entirely — default to empty Map so
308+
// callers can safely access .entries()/.size without null checks.
309+
if (!r.typeMap) {
310+
r.typeMap = new Map();
311+
} else if (!(r.typeMap instanceof Map)) {
308312
r.typeMap = new Map(
309313
r.typeMap.map((e: { name: string; typeName: string }) => [
310314
e.name,

0 commit comments

Comments
 (0)