Skip to content
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

bug: Decorators not working correctly #134

Closed
raimannma opened this issue Dec 16, 2020 · 1 comment
Closed

bug: Decorators not working correctly #134

raimannma opened this issue Dec 16, 2020 · 1 comment

Comments

@raimannma
Copy link

raimannma commented Dec 16, 2020

Description

If I am adding a decorator for the parameter of a function, I am getting an error.

Minimal code-snippet showcasing the problem
It even won't work with you simple example.

@OnConnect()
public connection(@ConnectedSocket() socket: any) {
    console.log(socket)
}

Expected behavior

Should just output me the socket id, but throwing a TypeError.

Actual behavior

> ts-node src/server.ts


C:\Users\raima\Documents\Hexe\server\node_modules\reflect-metadata\Reflect.js:553
                var decorated = decorator(target, propertyKey, descriptor);
                                ^
TypeError: Cannot read property '0' of undefined
    at C:\Users\raima\Documents\Hexe\server\src\decorators.ts:145:91
    at C:\Users\raima\Documents\Hexe\server\src\event_handler\main.ts:9:37
    at DecorateProperty (C:\Users\raima\Documents\Hexe\server\node_modules\reflect-metadata\Reflect.js:553:33)
    at Object.decorate (C:\Users\raima\Documents\Hexe\server\node_modules\reflect-metadata\Reflect.js:123:24)
    at __decorate (C:\Users\raima\Documents\Hexe\server\src\event_handler\main.ts:4:92)
    at C:\Users\raima\Documents\Hexe\server\src\event_handler\main.ts:13:2
    at Object.<anonymous> (C:\Users\raima\Documents\Hexe\server\src\event_handler\main.ts:8:1)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module.m._compile (C:\Users\raima\Documents\Hexe\server\node_modules\ts-node\src\index.ts:1056:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] serve: `ts-node src/server.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\raima\AppData\Roaming\npm-cache\_logs\2020-12-16T15_31_09_768Z-debug.log

Process finished with exit code 1
@raimannma raimannma changed the title fix: Decorators not working correctly bug: Decorators not working correctly Dec 16, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant