moleculer
moleculer copied to clipboard
Typescript definitions don't match the actual Javascript implementation
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- [x] I am running the latest version
- [x] I checked the documentation and found no answer
- [x] I checked to make sure that this issue has not already been filed
- [x] I'm reporting the issue to the correct repository
Current Behavior
The current version of the Typescript definitions don't match the actual Javascript implementation, such as how mergeSchemas and applyMixins are no longer static classes.
Expected Behavior
To be able to import the code in Typescript and have them refer to the proper Javascript implementation.
Failure Information
Multiple methods do not align with the Javascript implementation. If you were to go by the types, your code would not run as the implementation doesn't match. Calling the proper implementation will also upset Typescript as it does not have those definitions.
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
- use a method such as mergeSchemas which is a static method according to typescript.
- run your code.
The process will fail as mergeSchemas does not exist as a static method anymore.
Reproduce code snippet
import {Service, ServiceBroker, ServiceSchema} from "moleculer";
export default class SomeService extends Service {
/*...*/
// @ts-ignore
public constructor(public broker: ServiceBroker, schema: ServiceSchema<{}> = { name: '...' }) {
super(broker);
this.parseServiceSchema(Service.mergeSchemas({ /*...*/ })
}
/*...*/
}
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
- Moleculer version: 0.14.23
- NodeJS version: 16.16.0
- Operating System: Linux
Failure Logs
[Runner] moleculer_1.Service.mergeSchemas is not a function TypeError: moleculer_1.Service.mergeSchemas is not a function
I had same issue , but I fixed this issue via removing all mergeSchemas
methods from service classes .
In case anyone wants to patch their typescript file, I've temporarily made a tag on my fork with the fixes (link over here). To use the patch, replace your dependency version in the package.json with https://github.com/skarajic/moleculer#0.14.23-patched
. I'll be deleting the tag and fork again once my merge request is merged into the repository and a new release has been made 😃