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

Reflection & Hoisting #74

Open
rightisleft opened this issue Oct 20, 2017 · 3 comments
Open

Reflection & Hoisting #74

rightisleft opened this issue Oct 20, 2017 · 3 comments

Comments

@rightisleft
Copy link

rightisleft commented Oct 20, 2017

I'm debugging the following error.

TypeError: decorator is not a function
at DecorateProperty (/Users/jmurphy/projects/ubq/api/node_modules/reflect-metadata/Reflect.js:530:29)
at Object.decorate (/Users/jmurphy/projects/ubq/api/node_modules/reflect-metadata/Reflect.js:100:20)
at __decorate (/Users/jmurphy/projects/ubq/api/dist/src/ubq/dtos/lens.dto.js:4:92)
at Object. (/Users/jmurphy/projects/ubq/api/dist/src/ubq/dtos/lens.dto.js:73:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)

It occurs when using autoSerializeAs(Foo)

Is there support for getting the class type by function as outlined here?

rbuckton/reflect-metadata#29

The core issue comes from trying to implement this library:
typeorm/typeorm#1060

@rightisleft
Copy link
Author

I setup a simple test with 2 entities that use both Address and Owner. This is designed specifically to test fat arrow type assignment.

1: Using an expression to

export class Address {
    @autoserialize name: string;
    @autoserialize unit: number;
    @autoserializeAs(() => Owner) owner: Owner
}

// Address { name: 'carl', unit: 2, owner: [Function: Owner] }

Using:

export class Address {
    @autoserialize name: string;
    @autoserialize unit: number;
    @autoserialize owner: Owner
}

// Address { name: 'carl', unit: 2, owner: { type: 'owner', name: 'bank' } }

@rightisleft
Copy link
Author

From the other author:
typeorm/typeorm#1060

@weichx
Copy link
Owner

weichx commented Feb 6, 2018

This should be solved in version 2 https://github.com/weichx/cerialize/tree/mw/v2 using @serializeUsing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants