-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
removeEnumPrefix
option (#779)
* Remove enum prefix feature * Update readme * Fix prettier * Make a boolean parameter for removeEnumPrefix option --------- Co-authored-by: maxkiner <kirpichnikov@qtim.ru>
- Loading branch information
Showing
8 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
removeEnumPrefix=true,unrecognizedEnum=false |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
|
||
enum Foo { | ||
FOO_UNSPECIFIED = 0; | ||
FOO_BAR = 1; | ||
FOO_BAZ = 2; | ||
} | ||
|
||
enum Bar { | ||
BAR_UNSPECIFIED = 0; | ||
BAZ = 1; | ||
QUX = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* eslint-disable */ | ||
|
||
export const protobufPackage = ""; | ||
|
||
export enum Foo { | ||
UNSPECIFIED = 0, | ||
BAR = 1, | ||
BAZ = 2, | ||
} | ||
|
||
export function fooFromJSON(object: any): Foo { | ||
switch (object) { | ||
case 0: | ||
case "FOO_UNSPECIFIED": | ||
return Foo.UNSPECIFIED; | ||
case 1: | ||
case "FOO_BAR": | ||
return Foo.BAR; | ||
case 2: | ||
case "FOO_BAZ": | ||
return Foo.BAZ; | ||
default: | ||
throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum Foo"); | ||
} | ||
} | ||
|
||
export function fooToJSON(object: Foo): string { | ||
switch (object) { | ||
case Foo.UNSPECIFIED: | ||
return "FOO_UNSPECIFIED"; | ||
case Foo.BAR: | ||
return "FOO_BAR"; | ||
case Foo.BAZ: | ||
return "FOO_BAZ"; | ||
default: | ||
throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum Foo"); | ||
} | ||
} | ||
|
||
export enum Bar { | ||
UNSPECIFIED = 0, | ||
BAZ = 1, | ||
QUX = 2, | ||
} | ||
|
||
export function barFromJSON(object: any): Bar { | ||
switch (object) { | ||
case 0: | ||
case "BAR_UNSPECIFIED": | ||
return Bar.UNSPECIFIED; | ||
case 1: | ||
case "BAZ": | ||
return Bar.BAZ; | ||
case 2: | ||
case "QUX": | ||
return Bar.QUX; | ||
default: | ||
throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum Bar"); | ||
} | ||
} | ||
|
||
export function barToJSON(object: Bar): string { | ||
switch (object) { | ||
case Bar.UNSPECIFIED: | ||
return "BAR_UNSPECIFIED"; | ||
case Bar.BAZ: | ||
return "BAZ"; | ||
case Bar.QUX: | ||
return "QUX"; | ||
default: | ||
throw new tsProtoGlobalThis.Error("Unrecognized enum value " + object + " for enum Bar"); | ||
} | ||
} | ||
|
||
declare var self: any | undefined; | ||
declare var window: any | undefined; | ||
declare var global: any | undefined; | ||
var tsProtoGlobalThis: any = (() => { | ||
if (typeof globalThis !== "undefined") { | ||
return globalThis; | ||
} | ||
if (typeof self !== "undefined") { | ||
return self; | ||
} | ||
if (typeof window !== "undefined") { | ||
return window; | ||
} | ||
if (typeof global !== "undefined") { | ||
return global; | ||
} | ||
throw "Unable to locate global object"; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters