Skip to content

Commit

Permalink
delete unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
Yo-mah-Ya committed Oct 7, 2023
1 parent 487c9e1 commit c5cc261
Showing 1 changed file with 0 additions and 70 deletions.
70 changes: 0 additions & 70 deletions src/descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,76 +618,6 @@ function createMessageSignature(
return ts.factory.createTypeLiteralNode(fieldSignatures);
}

function createPrimitiveMessageSignature(
rootDescriptor: descriptor.FileDescriptorProto,
messageDescriptor: descriptor.DescriptorProto,
) {
const fieldSignatures = [];

const wrapMessageType = (
fieldType: ts.TypeReferenceNode,
): ts.TypeReferenceNode => {
const type = ts.factory.createTypeQueryNode(
ts.factory.createQualifiedName(
ts.factory.createQualifiedName(fieldType.typeName, "prototype"),
"toObject",
),
);
return ts.factory.createTypeReferenceNode("ReturnType", [type]);
};

for (const fieldDescriptor of messageDescriptor.field) {
let fieldType: ts.TypeNode = field.getType(fieldDescriptor, rootDescriptor);

if (field.isMap(fieldDescriptor)) {
const [keyDescriptor, valueDescriptor] = type.getMapDescriptor(
fieldDescriptor.type_name,
)!.field;

let valueType = field.getType(valueDescriptor, rootDescriptor);

if (field.isMessage(valueDescriptor)) {
valueType = wrapMessageType(valueType);
}

fieldType = ts.factory.createTypeLiteralNode([
ts.factory.createIndexSignature(
undefined,
[
ts.factory.createParameterDeclaration(
undefined,
undefined,
"key",
undefined,
field.getType(keyDescriptor, rootDescriptor),
),
],
valueType as ts.TypeNode,
),
]);
} else if (field.isMessage(fieldDescriptor)) {
fieldType = wrapMessageType(fieldType as ts.TypeReferenceNode);
}

fieldSignatures.push(
ts.factory.createPropertySignature(
undefined,
getFieldName(fieldDescriptor),
(
field.isOptional(rootDescriptor, fieldDescriptor) ||
field.isMessage(fieldDescriptor) ||
field.isRequiredWithoutExplicitDefault(rootDescriptor, fieldDescriptor)
)
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
: undefined,
field.wrapRepeatedType(fieldType as ts.TypeNode, fieldDescriptor),
),
);
}

return ts.factory.createTypeLiteralNode(fieldSignatures);
}

function getPivot(descriptor: descriptor.DescriptorProto) {
const kDefaultPivot = 500;
let max_field_number = 0;
Expand Down

0 comments on commit c5cc261

Please sign in to comment.