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

Decorator #22

Open
Timbuktu1982 opened this issue Jul 11, 2023 · 1 comment
Open

Decorator #22

Timbuktu1982 opened this issue Jul 11, 2023 · 1 comment
Assignees
Labels
investigating Issue is currently being checked

Comments

@Timbuktu1982
Copy link
Contributor

Timbuktu1982 commented Jul 11, 2023

Hi EnterTheNameHere,

i have problems, when i export a decorator function directly:

input:

export function ServiceInjection(target: object, propertyName: string): void {
    ServiceManager.getService(propertyName).then((service) => {
        Object.defineProperty(target, propertyName, service);
    });
}

output:

3| import { ServiceManager } from '../core/service-manager';
4| 
5| export function ServiceInjection(target: object, propertyName: string): void {
6|     ServiceManager.getService(propertyName).then((service) => {
7|         Object.defineProperty(target, propertyName, service);
8|     });
9| }
10| 
11| undefined
12| undefined
13| undefined

/usr/local/lib/node_modules/@enterthenamehere/esdoc/out/ESDoc.js:394
        throw e;
        ^

TypeError: Cannot read properties of undefined (reading 'start')
    at InvalidCodeLogger.show (/usr/local/lib/node_modules/@enterthenamehere/esdoc-standard-plugin/node_modules/@enterthenamehere/esdoc-core/lib/Util/InvalidCodeLogger.js:37:43)
    at FunctionDoc._$param (/usr/local/lib/node_modules/@enterthenamehere/esdoc-standard-plugin/node_modules/@enterthenamehere/esdoc-core/lib/Doc/AbstractDoc.js:550:36)
    at FunctionDoc._apply (/usr/local/lib/node_modules/@enterthenamehere/esdoc-standard-plugin/node_modules/@enterthenamehere/esdoc-core/lib/Doc/AbstractDoc.js:115:10)
    at new AbstractDoc (/usr/local/lib/node_modules/@enterthenamehere/esdoc-standard-plugin/node_modules/@enterthenamehere/esdoc-core/lib/Doc/AbstractDoc.js:46:10)
    at new FunctionDoc (/usr/local/lib/node_modules/@enterthenamehere/esdoc-standard-plugin/node_modules/@enterthenamehere/esdoc-core/lib/Doc/FunctionDoc.js:19:1)
    at DocFactory._createDoc (/usr/local/lib/node_modules/@enterthenamehere/esdoc-standard-plugin/node_modules/@enterthenamehere/esdoc-core/lib/Factory/DocFactory.js:555:12)
    at DocFactory._traverseComments (/usr/local/lib/node_modules/@enterthenamehere/esdoc-standard-plugin/node_modules/@enterthenamehere/esdoc-core/lib/Factory/DocFactory.js:474:22)
    at DocFactory.push (/usr/local/lib/node_modules/@enterthenamehere/esdoc-standard-plugin/node_modules/@enterthenamehere/esdoc-core/lib/Factory/DocFactory.js:382:20)
    at /usr/local/lib/node_modules/@enterthenamehere/esdoc/out/ESDoc.js:391:17
    at enter (/usr/local/lib/node_modules/@enterthenamehere/esdoc-standard-plugin/node_modules/@enterthenamehere/esdoc-core/lib/Util/ASTUtil.js:39:9)
When i separate the export like the code below, i have no problems...

const ServiceInjection = function (target: object, propertyName: string): void {
    ServiceManager.getService(propertyName).then((service) => {
        Object.defineProperty(target, propertyName, service);
    });
};

export { ServiceInjection };
@Timbuktu1982
Copy link
Contributor Author

Sorry, i forgot to say:
I use node.js 19 and TypeScript.

The post above i have make prettier.

@EnterTheNameHere EnterTheNameHere self-assigned this Jul 13, 2023
@EnterTheNameHere EnterTheNameHere added the investigating Issue is currently being checked label Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating Issue is currently being checked
Projects
None yet
Development

No branches or pull requests

2 participants