Skip to content

--allowJs and generated protocol buffers #9509

Closed
@tamird

Description

@tamird

Currently, Google's protocol buffer compiler at https://github.com/google/protobuf/tree/master/js generates code that looks something like:

/**
 * @fileoverview
 * @enhanceable
 * @public
 */
// GENERATED CODE -- DO NOT EDIT!

var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();

goog.exportSymbol('proto.cockroach.util.hlc.Timestamp', null, global);


/**
 * Generated by JsPbCodeGenerator.
 * @param {Array=} opt_data Optional initial data array, typically from a
 * server response, or constructed directly in Javascript. The array is used
 * in place and becomes part of the constructed object. It is not cloned.
 * If no data is provided, the constructed object will be empty, but still
 * valid.
 * @extends {jspb.Message}
 * @constructor
 */
proto.cockroach.util.hlc.Timestamp = function(opt_data) {
  jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.cockroach.util.hlc.Timestamp, jspb.Message);
if (goog.DEBUG && !COMPILED) {
  proto.cockroach.util.hlc.Timestamp.displayName = 'proto.cockroach.util.hlc.Timestamp';
}

...
...
...

goog.object.extend(exports, proto.cockroach.util.hlc);

See also actual generated code.

I'm not really sure what the underlying cause is, but I can't seem to get any use out of the (presumed) types inferred from the JsDoc comments in this file.

By the way, is it possible to examine the result of --allowJs to see what the typescript compiler was able to infer?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions