piotr-oles/as-proto

Example with import from google/protobuf types

dsyer opened this issue · 2 comments

dsyer commented

E.g. if you want to use timestamps, it makes sense to

import "google/protobuf/timestamp.proto";

When as-proto processes this definition it produces AssemblyScript like this:

import { google } from "./google/protobuf/timestamp";

but there is no such source file to import from, at least that I have been able to find. The fact that the import is processed to something that looks sensible makes me think it is intentional, so I need an example to see how it is supposed to be used.

dsyer commented

UPDATE: you have to include the Google proto sources on the command line when you run protoc, e.g:

protoc --plugin=protoc-gen-as=./node_modules/.bin/as-proto-gen --as_out=./protoc simple.proto google/protobuf/timestamp.proto

then you get a "google" directory generated with AssemblyScript in it. An example would still be useful.

To be honest, I didn't know about that. Thanks for all reported issues - this is really helpful! This library is still pretty new and it doesn't cover all cases.

Would you like to create a PR to add this to the README.md?