-
Notifications
You must be signed in to change notification settings - Fork 0
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
support for generating es6 imports and .d.ts files #1
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you temporarily add the output of running this on test.proto so I can see the output?
example/test.d.ts
Outdated
@@ -0,0 +1,1013 @@ | |||
declare namespace proto.jspb.test { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want namespaces in the es6 output. I think we can just remove this and unindent the contents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. For nested messages and enums, I still use export namespace Foo { class Bar ... }
to represent Foo.Bar
, which as I understand it should merge with the sibling export class Foo { }
.
example/test.d.ts
Outdated
@@ -0,0 +1,1013 @@ | |||
declare namespace proto.jspb.test { | |||
export class Empty extends jspb.Message { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to import dependencies.
example/test.d.ts
Outdated
declare namespace proto.jspb.test { | ||
export class Empty extends jspb.Message { | ||
constructor(data?: any[] | null); | ||
toObject(includeInstance?: boolean): GlobalObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GlobalObject is a clutz specific hack for aliasing that we shouldn't need with es6.
Although I wonder if we need to do anything special if we're importing a message named Object. I guess if we use import *
that won't be an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with { [key: string]: unknown }
in return values. Currently also that for arguments, though as I type this I'm realizing in arguments it probably needs to be any
for the values.
// @ts-nocheck | ||
|
||
import * as jspb from 'google-protobuf'; | ||
var goog = jspb; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably wiill need to be something like import { goog } from 'closure-library/goog.js
.
But that may be fine to figure out later.
Builds on protocolbuffers#150, adding:
library
option with ES6generate_dts
flag) and compatible (library
option set andimport_style
set toes6
)Tested compilation of Derivita's omaha/base/ast.proto and inspecting the generated
omaha/base/ast_proto.js
andomaha/base/ast_proto.d.ts
files.