-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing ts-mocha is throwing type errors in Inject #2764
Comments
It seems that |
Maybe there is a possibility to relax the check if the design type is |
@Navos Can you make sure #2765 skips the assertions but |
@raymondfeng I tried the separate branch and the added the |
If you have a github repo to reproduce the issue, I can take a look. |
Hey Raymond, I cant show you the code I am currently working on due to it being work related, but I reproduced the error with the log-extension example here https://github.com/Navos/ts-mocha-implementation/blob/master/package.json |
Here is the transpiled result from __decorate([
context_1.inject(keys_1.EXAMPLE_LOG_BINDINGS.LOGGER, { optional: true }),
__metadata("design:type", typeof (_a = typeof types_1.LogWriterFn !== "undefined" && types_1.LogWriterFn) === "function" ? _a : Object)
], LogActionProvider.prototype, "writeLog", void 0);
__decorate([
context_1.inject(keys_1.EXAMPLE_LOG_BINDINGS.APP_LOG_LEVEL, { optional: true }),
__metadata("design:type", typeof (_b = typeof keys_1.LOG_LEVEL !== "undefined" && keys_1.LOG_LEVEL) === "function" ? _b : Object)
], LogActionProvider.prototype, "logLevel", void 0);
LogActionProvider = __decorate([
__param(0, context_1.inject.getter(core_1.CoreBindings.CONTROLLER_CLASS)),
__param(1, context_1.inject.getter(core_1.CoreBindings.CONTROLLER_METHOD_NAME)),
__param(2, context_1.inject(keys_1.EXAMPLE_LOG_BINDINGS.TIMER)),
__metadata("design:paramtypes", [typeof (_c = typeof context_1.Getter !== "undefined" && context_1.Getter) === "function" ? _c : Object, typeof (_d = typeof context_1.Getter !== "undefined" && context_1.Getter) === "function" ? _d : Object, typeof (_e = typeof types_1.TimerFn !== "undefined" && types_1.TimerFn) === "function" ? _e : Object])
], LogActionProvider); |
And here is what __decorate([
context_1.inject(keys_1.EXAMPLE_LOG_BINDINGS.LOGGER, { optional: true }),
__metadata("design:type", Function)
], LogActionProvider.prototype, "writeLog", void 0);
__decorate([
context_1.inject(keys_1.EXAMPLE_LOG_BINDINGS.APP_LOG_LEVEL, { optional: true }),
__metadata("design:type", Number)
], LogActionProvider.prototype, "logLevel", void 0);
LogActionProvider = __decorate([
__param(0, context_1.inject.getter(core_1.CoreBindings.CONTROLLER_CLASS)),
__param(1, context_1.inject.getter(core_1.CoreBindings.CONTROLLER_METHOD_NAME)),
__param(2, context_1.inject(keys_1.EXAMPLE_LOG_BINDINGS.TIMER)),
__metadata("design:paramtypes", [Function, Function, Function])
], LogActionProvider); |
|
@raymondfeng Hey Raymond, what will happen with this issue? |
Possibly related: #3160 @Navos is this issue still relevant? Have you managed to find any solution or any workaround? I am looking into ways how to switch loopback-next from Mocha to Jest (see #3159). It seems to me that the solution for on-the-fly-compilation used by Jest is different from the solution used by Would you like to try Jest instead of |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the |
Description / Steps to reproduce / Feature proposal
I've been trying to implement ts-mocha instead of the built in lb-mocha for faster test running and while I have taken care of the main issues within my code, one problem remains related to when
inject
checks if a getter or setter is a function.The issue stems from the following lines: https://github.com/strongloop/loopback-next/blob/master/packages/context/src/inject.ts#L551 and https://github.com/strongloop/loopback-next/blob/master/packages/context/src/inject.ts#L426
When modifying the code and trying to make working adjustments,
typeof targetType === 'function'
returns true, but the check against the interfaceFunction
does not.Current Behavior
The type of AuthenticateActionProvider.constructor[1] (Object) is not Setter function
Expected Behavior
It understand the given object is a function.
The text was updated successfully, but these errors were encountered: