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

Value/ListValue do not include the required dependencies when using nestJs=true #985

Open
dbettini opened this issue Jan 7, 2024 · 0 comments

Comments

@dbettini
Copy link

dbettini commented Jan 7, 2024

For content-delivery.proto file:

syntax = "proto3";

package content_delivery;

import "google/protobuf/struct.proto";

...

message Test {
  // optional google.protobuf.Value data = 5;  // If this replaces the next line, it does not work
  optional google.protobuf.Struct data = 5;
}

Using Struct correctly requires the dependencies in the built content-delivery.ts, but does not if Value or ListValue is used.

The missing lines are as follows, the files otherwise being identical:

- import { wrappers } from "protobufjs";
import { Observable } from "rxjs";
import { ContentElement_MetaProps, Course, CourseMetaProps, Page } from "./content.pb";
- import { Struct } from "./google/protobuf/struct.pb";
 ...
+  data?:
+    | any
+    | undefined;
-   data?: { [key: string]: any } | undefined;
...
- wrappers[".google.protobuf.Struct"] = { fromObject: Struct.wrap, toObject: Struct.unwrap } as any;

As you can see, the types seem to be correct, but the import is not there.
This only happens with the Nestjs option - without it, the generated files are working, i.e. they only have expected differences (using Value. vs Struct).

EDIT: Also, it seems Struct is there only if it's part of at least one root message, but not if all messages containing it are nested:

message TestFirst {
  message TestSecond {
    google.protobuf.Struct dataSecond = 1;
  }

  TestSecond dataFirst = 1;
}

In this case, even Struct will not be correctly imported (again, only in the case of Nest plugin).
Should I open another issue for that, since it looks like a different problem?

Version: Initially tried on 1.156.6, then tried bumping to latest 1.166.2

@dbettini dbettini changed the title Value/ListValue do not include the required dependencies during build compared to Struct Value/ListValue do not include the required dependencies for Nestjs Jan 9, 2024
@dbettini dbettini changed the title Value/ListValue do not include the required dependencies for Nestjs Value/ListValue do not include the required dependencies when using nestJs=true Jan 9, 2024
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

1 participant