Skip to content

Commit dbf68d9

Browse files
committed
fix: allow using unbound service methods
1 parent 2ba99d9 commit dbf68d9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/schema-to-typescript/common/operation-methods.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {
22
arrayExpression,
3+
arrowFunctionExpression,
34
assignmentPattern,
45
blockStatement,
56
callExpression,
6-
classMethod,
7-
ClassMethod,
7+
ClassProperty,
8+
classProperty,
89
Expression,
910
expressionStatement,
1011
Identifier,
@@ -166,7 +167,7 @@ export function generateOperationMethods({
166167
extendDependenciesAndGetResult(generateBinaryType(binaryTypes, operationImportPath), dependencyImports);
167168

168169
const modelRegisterValidationSchemaImports: Record<string, true> = {};
169-
const methods: ClassMethod[] = [];
170+
const methodProperties: ClassProperty[] = [];
170171
const validationStatements: Statement[] = [];
171172

172173
if (validateResponse && !validationContext) {
@@ -617,9 +618,7 @@ export function generateOperationMethods({
617618
);
618619
}
619620

620-
const operationMethod = classMethod(
621-
'method',
622-
identifier(operationName),
621+
const operationMethod = arrowFunctionExpression(
623622
argument.properties.length > 0
624623
? [
625624
isAssignableToEmptyObject(argument.typeAnnotation.typeAnnotation)
@@ -644,11 +643,12 @@ export function generateOperationMethods({
644643
)
645644
])
646645
);
646+
const operationMethodProperty = classProperty(identifier(operationName), operationMethod);
647647
operationMethod.returnType = tsTypeAnnotation(
648648
tsTypeReference(identifier('Promise'), tsTypeParameterInstantiation([operationReturn.type]))
649649
);
650650
extendDependencyImports(dependencyImports, operationReturn.dependencyImports);
651-
methods.push(attachJsDocComment(operationMethod, renderJsDoc(jsdoc, jsDocRenderConfig)));
651+
methodProperties.push(attachJsDocComment(operationMethodProperty, renderJsDoc(jsdoc, jsDocRenderConfig)));
652652
}
653653
}
654654
if (Object.keys(modelRegisterValidationSchemaImports).length > 0 && validationContext) {
@@ -671,7 +671,7 @@ export function generateOperationMethods({
671671
);
672672
}
673673

674-
methods.sort((a, b) => (a.key as Identifier).name.localeCompare((b.key as Identifier).name));
674+
methodProperties.sort((a, b) => (a.key as Identifier).name.localeCompare((b.key as Identifier).name));
675675

676-
return {methods, dependencyImports, validationStatements};
676+
return {methods: methodProperties, dependencyImports, validationStatements};
677677
}

0 commit comments

Comments
 (0)