Skip to content

Conversation

@theharsh999
Copy link

@theharsh999 theharsh999 commented Dec 30, 2025

Why?

JavaScript xlang schema-based struct serialization currently treats all fields as nullable and always writes a per-field null flag.
This introduces unnecessary overhead when a field is known to be non-nullable by schema design.

What does this PR do?

  • Adds schema-based per-field nullable support for JS xlang struct serialization.
  • Preserves backward compatibility by treating fields as nullable by default.
  • When nullable: false is explicitly specified:
    • Skips writing the per-field null flag.
    • Throws a clear runtime error if the field value is null or undefined (includes field name).
  • Extends StructTypeInfo field schema typing to allow nullable?: boolean.
  • Adds a minimal unit test verifying:
    • Non-nullable fields throw on null.
    • Fields without nullable keep existing behavior.

Related issues

Does this PR introduce any user-facing change?

Yes.
This PR introduces an opt-in schema-level configuration (nullable: false) for JS xlang serialization.
Existing schemas are unaffected unless nullable: false is explicitly set.

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

This change is opt-in and only affects schema-based fields explicitly marked as nullable: false.
No performance regression is expected for existing schemas.

@theharsh999 theharsh999 changed the title JS xlang: add schema-based per-field nullable support (backward compatible) feat(js): add schema-based per-field nullable support for xlang Dec 30, 2025
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