Git Product home page Git Product logo

Comments (7)

thesayyn avatar thesayyn commented on May 24, 2024 1

Hey. Thank you for reporting this.

I will try to take a look this week.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024 1

Also seen as: protocolbuffers/protobuf-javascript#55 in js version. This is something that we definitely have to solve here.

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

Update;

Upon closer look, I realized that public import directive transitively re-exports the symbols from dependencies. When you have two public imports with same package name they will conflict and lead to compiler errors.

TLDR: It is not so easy to solve this problem of re-exporting transitive dependencies.

// old.proto
syntax = "proto3";

import public "public.proto";
import public "public2.proto";

message OldMarker {
    importdirective.PublicMessage pubMessageField = 4;
    importdirective.PublicMessage2 pubMessageField2 = 5;
}
// public.proto
syntax = "proto3";

package importdirective;


message PublicMessage {
    bool pb = 1;
}
// public2.proto
syntax = "proto3";

package importdirective;

message PublicMessage2 {
    bool pb = 1;
}

this will lead to export conflicts. in order to work around this, we need to explicitly import symbols from transitive dependencies and re-export the symbols from them within a namespace whose name is identical to conflicting packages.

this is what the protoc compiler wants us to do. merge everything under a namespace if the protos has the same package directive hence it is safe to do because protoc guarantees that there can not be identically named symbols under the same name

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

But still, there are more cursed cases;

syntax = "proto3";

package importdirective;

import public "test/import/public.proto";
import public "test/import/public2.proto";

message OldMarker {
    importdirective.PublicMessage pubMessageField = 4;
    importdirective.PublicMessage2 pubMessageField2 = 5;
}

where we need to re-export everything that conflicts as well as the symbols in the proto within the same package.

from protoc-gen-ts.

petermetz avatar petermetz commented on May 24, 2024

@thesayyn Quite the can of worms indeed. :-) Thank you again for the investigation/fix efforts!

from protoc-gen-ts.

thesayyn avatar thesayyn commented on May 24, 2024

I am going to close this as not planned.

from protoc-gen-ts.

petermetz avatar petermetz commented on May 24, 2024

@thesayyn Cool, thanks for the update! Hopefully the upstream repo adds support to it at some point.

from protoc-gen-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.