Skip to content

fix(compiler): include null in TS map value types for optional map values - #4108

Open
ayush00git wants to merge 2 commits into
apache:mainfrom
ayush00git:fix/js-map-value-nullability
Open

ayush00git wants to merge 2 commits into
apache:mainfrom
ayush00git:fix/js-map-value-nullability

Conversation

@ayush00git

Copy link
Copy Markdown
Contributor

What does this PR do?

For a schema field like map<string, optional string> attrs = 1;, the JavaScript generator declared the TypeScript type as Map<string, string> while the same generated file's runtime schema registration correctly emits .setNullable(true) on the map value type, so the declared TS type contradicted the runtime schema and deserialized null values violated it. The fix is one line: the MapType branch of generate_type now passes nullable=field_type.value_optional for the value type, producing Map<string, string | null>, matching how list elements already handle optionality.

Verified with a new regression test that fails without the generator change; the full compiler suite (fory_compiler/tests) passes.

…lues

For a field like `map<string, optional string> attrs = 1;`, the JavaScript
generator emitted the TypeScript type `Map<string, string>` while the
runtime schema registration correctly marked the map value nullable with
`.setNullable(true)`, so deserialized null values violated the declared
type. Pass `nullable=field_type.value_optional` for the map value type in
generate_type, matching how list elements already handle optionality, so
the type becomes `Map<string, string | null>`.

Claude-Session: https://claude.ai/code/session_01YcPbRyTJYmU8t6mkGCbnUf
@ayush00git
ayush00git requested a review from chaokunyang October 1, 2026 12:26

This branch has not been deployed

No deployments
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