question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

__metadata should register function that returns type instead of literal type

See original GitHub issue

Imagine 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:open
  • Created 6 years ago
  • Reactions:7
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
bolucommented, Aug 1, 2018

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.

2reactions
BeSpunkycommented, Mar 27, 2020

Any developments? I’m stuck with the same issue…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found