mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* bootstraped folder structure for "protocol-buffers-schema" * npx prettier --write .\types\protocol-buffers-schema\** * drafted types for protocol-buffers-schema * moved types into dedicated file * added "strictFunctionTypes"-flag * drafted index.d.ts * added missing files to tsconfig * npx prettier --write .\types\protocol-buffers-schema\** * added "node" to types in tsconfig * removed redundant "export" keywords * added reference to node type(s) * added test case
22 lines
426 B
TypeScript
22 lines
426 B
TypeScript
import schema from "protocol-buffers-schema";
|
|
|
|
const proto = `syntax = "proto2";
|
|
|
|
message Point {
|
|
required int32 x = 1;
|
|
required int32 y=2;
|
|
optional string label = 3;
|
|
}
|
|
|
|
message Line {
|
|
required Point start = 1;
|
|
required Point end = 2;
|
|
optional string label = 3;
|
|
}`;
|
|
|
|
// pass a buffer or string to schema.parse
|
|
const sch = schema.parse(proto);
|
|
|
|
// will print out the schema as a javascript object
|
|
console.log(sch);
|