The const typeNameForArgument assignment will fail on the async _getDefinition(classDeclaration, body, parsedFile, ServiceClass) method:
for (const parameterDeclaration of constructorParams) {
const typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
const argumentId = await this._getIdentifierFromImports(typeNameForArgument, body, parsedFile);
if (!argumentId) {
continue;
}
definition.addArgument(new _Reference.default(argumentId), definition.abstract);
}
When resolving the StatusGetController service, it will throw an exception.
I think this happens because the typescript-eslint parser returns a different data structure when resolving constructors which dont use private properties.
The parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name will throw an error, because typescript-eslint resolves this structure to:
And the parameter.typeAnnotation property does not exist when using this declaration.
So, I would suggest to change the documentation to reflect that autowiring only works with private constructor properties.
@abadb Thanks! I'll update the documentation in order to reflect your suggestion.
As well I will create a task in order to make it working with protected and public attributes on constructor
Let's assume the following case:
Then, If I have:
A client which uses this QueryBus interface:
If using autowiring (loading a YAML file):
The const typeNameForArgument assignment will fail on the async _getDefinition(classDeclaration, body, parsedFile, ServiceClass) method:
When resolving the StatusGetController service, it will throw an exception.
I think this happens because the typescript-eslint parser returns a different data structure when resolving constructors which dont use private properties.
If using private constructor properties:
The parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name will be present, as resolved by the typescript-eslint parser:
However, if not using private property constructors, like:
The parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name will throw an error, because typescript-eslint resolves this structure to:
And the parameter.typeAnnotation property does not exist when using this declaration.
So, I would suggest to change the documentation to reflect that autowiring only works with private constructor properties.