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

generated output only does relative imports #5

Closed
a-morales opened this issue Sep 18, 2019 · 2 comments
Closed

generated output only does relative imports #5

a-morales opened this issue Sep 18, 2019 · 2 comments

Comments

@a-morales
Copy link

If there's a .proto file that is not on a root path and it imports another .proto file then the resulting typescript file will have the import as a relative import causing typescript to throw errors. For example given the following file structure

- foo/
  - bar.proto
  - baz.proto

with bar.proto being

syntax = "proto3";

package foo;

import "google/protobuf/wrappers.proto";
import "foo/baz.proto";
...

The generated output of ts-proto would be

- google/
  - protobuf/
    - wrappers.ts
- foo/
  - bar.ts
  - baz.ts

With bar.ts being

import * from "./google/protobuf/wrappers";
import * from "./foo/baz.ts";

...

Since a relative path is specified for imports, typescript throws errors that it can't find the modules. A proper fix is to either compute the relative paths for imports when generating the output or just have them be "top level" packages (e.g import * from 'google/protobuf/wrappers') so that typescript can be configured to include the packages for module resolution.

@a-morales
Copy link
Author

#3 is related to this.

stephenh added a commit that referenced this issue Sep 20, 2019
Fixes #4 and probably #5.

* broken_imports:
  Bump ts-poet for relative import fix.
  Update bin files.
  Broken case
@stephenh
Copy link
Owner

I'm 90% sure this is fixed in 1.4.1 / fixed while fixing #4. Going to close based on that guess, but let me know if its not.

zfy0701 added a commit to sentioxyz/ts-proto that referenced this issue Jan 5, 2023
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