__metadata should register function that returns type instead of literal type
See original GitHub issueImagine case with circular dependencies
class Car {
@Field owner: Person // !!! Error: Person is not defined.
}
class Person {
@Field car: Car;
}
// car has owner, owner has car
Typescript metadata would be emitted here like
eg.
__metadata('design:type', Person)
.
As Person
is injected for the first time before Person
class is initialized, it will result with ReferenceError
saying Person is not defined
.
If it’d emit metadata like:
__metadata('design:type', () => Person)
it’d be fine.
Later on, when using Reflect.metadata, it would also need to call meta function instead of just returning the type.
If you think it’s good idea, do you have any suggestions about starting point for PR that would implement this change?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:7 (3 by maintainers)
Top Results From Across the Web
typing — Support for type hints — Python 3.11.1 documentation
At runtime, the statement Derived = NewType('Derived', Base) will make Derived a callable that immediately returns whatever parameter you pass it. That means ......
Read more >Obtaining the return type of a function - Stack Overflow
const fnReturnType = (false as true) && fn(); It works by casting false to the literal value of true , so that the...
Read more >PhpStorm advanced metadata - JetBrains
The map directive lets you set an arbitrary mapping between the argument's value and the function's return type. By using this directive, you ......
Read more >Handbook - Literal Types - TypeScript
When you declare a variable via var or let , you are telling the compiler that there is the chance that this variable...
Read more >LLVM Language Reference Manual
The check function has no return value, but it will trigger an OS-level error if the address ... Only literal types are uniqued...
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
Hi, is there any update on the ETA of this? I can imagine some simple changes that would make things work. For example, emit all the decorators at end of file. Or after last class defined in the file.
Any developments? I’m stuck with the same issue…