Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta generated for messages with oneOf properties is incorret for other properties #1021

Open
jkristia opened this issue Mar 26, 2024 · 1 comment

Comments

@jkristia
Copy link

I see an issue in the generated meta when a class contains a oneof type.
this class

message UsingOneOf {
  type1.Type1Basic some_type = 1;
  oneof one_of_type {
    type1.Type1Basic one_of_type1 = 3;
    type2.Type2Basic one_of_type2 = 4;
  }
}

generates oneOfIndex: 0 for all 3 properties, not just the 2 properties in the oneof field.
This is with version

    "ts-proto": "^1.170.0",
    "ts-proto-descriptors": "^1.15.0",

The generated meta. Notice field some_type also has oneOfIndex: 0

   {
      "name": "UsingOneOf",
      "field": [{
        "name": "some_type",
        "number": 1,
        "label": 1,
        "type": 11,
        "typeName": ".type1.Type1Basic",
        "extendee": "",
        "defaultValue": "",
        "oneofIndex": 0,   <----
        "jsonName": "someType",
        "options": undefined,
        "proto3Optional": false,
      }, {
        "name": "one_of_type1",
        "number": 3,
        "label": 1,
        "type": 11,
        "typeName": ".type1.Type1Basic",
        "extendee": "",
        "defaultValue": "",
        "oneofIndex": 0,
        "jsonName": "oneOfType1",
        "options": undefined,
        "proto3Optional": false,
      }, {
        "name": "one_of_type2",
        "number": 4,
        "label": 1,
        "type": 11,
        "typeName": ".type2.Type2Basic",
        "extendee": "",
        "defaultValue": "",
        "oneofIndex": 0,
        "jsonName": "oneOfType2",
        "options": undefined,
        "proto3Optional": false,
      }],
      "extension": [],
      "nestedType": [],
      "enumType": [],
      "extensionRange": [],
      "oneofDecl": [{ "name": "one_of_type", "options": undefined }],
      "options": undefined,
      "reservedRange": [],
      "reservedName": [],
    }
@stephenh
Copy link
Owner

@lukealvoeiro I haven't looked into this very much, but oneofIndex is a proto2 field; could this be from a ts-proto-descriptor thing / your recent PR?

You'd mentioned bumping ts-proto-descriptors, but I don't think that ended up happening, but I kinda thought it shouldn't really matter since it'd still be using the generated-by-older-ts-proto versions of the decode code... 🤔

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

No branches or pull requests

2 participants