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

Enum properties are capitalized in JS files #527

Closed
dasois opened this issue Apr 8, 2019 · 2 comments
Closed

Enum properties are capitalized in JS files #527

dasois opened this issue Apr 8, 2019 · 2 comments

Comments

@dasois
Copy link

dasois commented Apr 8, 2019

The proto file

syntax = "proto3";
package testEnum;

enum Test{
	Prop1 = 0;
	PROP2 = 1;
}

compiles to the d.ts file

import * as jspb from "google-protobuf"

export enum Test { 
  Prop1 = 0,
  PROP2 = 1,
}

together with the js file

/**
 * @fileoverview
 * @enhanceable
 * @suppress {messageConventions} JS Compiler reports an error if a variable or
 *     field starts with 'MSG_' and isn't a translatable message.
 * @public
 */
// GENERATED CODE -- DO NOT EDIT!

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

goog.exportSymbol('proto.testEnum.Test', null, global);
/**
 * @enum {number}
 */
proto.testEnum.Test = {
  PROP1: 0,
  PROP2: 1
};

goog.object.extend(exports, proto.testEnum);

Trying to access Prop1 therefore leads to run-time errors.

@ktm-labs
Copy link

You can avoid the problem by following the all caps style for enums, as outlined in the style guide for Protocol Buffers, but the system should behave differently when the style is not followed instead of just silently breaking.

@stanley-cheung
Copy link
Collaborator

Should be fixed now.

loyalpartner pushed a commit to loyalpartner/grpc-web that referenced this issue Sep 4, 2020
…c#527)

This reverts commit cf7d15a.
This introduced a recursive call to `Flush` in the proxy, which
will crash the application.
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

3 participants