Keep protobuf value types distinct from object refs
This commit is contained in:
@@ -58,12 +58,12 @@ const tsTypeForTypeRef = (
|
||||
type: TypeRef,
|
||||
root?: protobuf.Root,
|
||||
): string => {
|
||||
if (type.symbol) {
|
||||
return `ObjectRef<${stringLiteral(symbolId(type.symbol))}>`;
|
||||
}
|
||||
if (type.enumValues && type.enumValues.length > 0) {
|
||||
return type.enumValues.map(stringLiteral).join(" | ");
|
||||
}
|
||||
if (type.symbol) {
|
||||
return `ObjectRef<${stringLiteral(symbolId(type.symbol))}>`;
|
||||
}
|
||||
const protoType = normalizedProtoType(type.protoType);
|
||||
switch (protoType) {
|
||||
case "string":
|
||||
|
||||
@@ -366,9 +366,8 @@ const protoSymbolFromReflection = (
|
||||
|
||||
const typeRefForField = (
|
||||
field: protobuf.Field,
|
||||
schemaVersion: string,
|
||||
_schemaVersion: string,
|
||||
): TypeRef => {
|
||||
const symbol = protoSymbolFromReflection(field.resolvedType, schemaVersion);
|
||||
const enumValues =
|
||||
field.resolvedType instanceof protobuf.Enum
|
||||
? Object.entries(field.resolvedType.values)
|
||||
@@ -377,7 +376,6 @@ const typeRefForField = (
|
||||
: undefined;
|
||||
return {
|
||||
protoType: field.type,
|
||||
...(symbol ? { symbol } : {}),
|
||||
...(enumValues ? { enumValues } : {}),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user