getCtor returns undefined when class property refers to another class that is defined after it
See original GitHub issueThis doesn’t work,
@entity
export class Cat {
id = 0
toys: Toy[] = []
}
@entity
export class Toy {
id = 0
}
const type = getType<Toy>()
await type.getCtor() // undefined
This works,
@entity
export class Toy {
id = 0
}
@entity
export class Cat {
id = 0
toys: Toy[] = []
}
const type = getType<Toy>()
await type.getCtor() // [class Toy]
It’s the toys: Toy[] = []
line causing the issue, it works when I comment it out. It looks like it only happens for array types, Toy[]
. just a direct reference works fine.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Javascript class property return undefined when called with a ...
When I call the inter method (who call countdown every 1s) this.work return undefined and I don't know why. If I call the...
Read more >ReferenceError: reference to undefined property "x" - JavaScript
The JavaScript warning "reference to undefined property" occurs when a script attempted to access an object property which doesn't exist.
Read more >Initialize Property Values - MATLAB & Simulink - MathWorks
Set Property Values in the Constructor. To assign a value to a property from within the class constructor, refer to the object that...
Read more >How to use Javascript classes | Geek.I.Am
Javascript classes have always been quite different from classes that ... if (o === undefined ) return "Undefined"; return Object.prototype.
Read more >Properties are undefined when accessed via super from ...
No, the child constructor can not access the instance until the parent constructor is complete. In this case, since both class fields define...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What I did is more like this. The link is not running but I think you can check the generated code.
Fixed in v1. Not in the current version.