fix(javascript): accept user type id 0 in struct, ext, and enum factories - #4014
Merged
Conversation
…ries Type.struct(0, ...), Type.ext(0), and Type.enum(0, ...) threw because a truthiness check treated the id 0 as absent, although TypeInfo documents user type ids in [0, 0xfffffffe]. Check for undefined instead.
chaokunyang
approved these changes
Sep 3, 2026
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.
What was the error
Type.struct(0, ...),Type.ext(0), andType.enum(0, ...)threwtype name and type id should be set at least onebecause a truthiness check treated the numeric id 0 as absent, althoughTypeInfoallows user type ids in[0, 0xfffffffe]. A peer runtime registering a type under id 0 could not interoperate with JavaScript.What this PR fixes
The three factories now check
typeId === undefinedinstead of truthiness, so id 0 registers normally. A regression test covers all three factories and a full serialize/deserialize round trip under id 0.