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.

reflect-metadata specific version needed?

See original GitHub issue

I’m submitting a request

Current behavior

NestJs currently seems to depend on a specific version of reflect-metadata (0.1.10) and will complain in NPM unless you resolve this SPECIFIC version, I tried higher versions and it complained it needed that specific one.

Expected behavior

It should ideally not need any specific polyfill for Reflect.getMetadata etc it should just expect the consumer to provide one (until nodejs etc) doesn’t need it polyfilled.

Currently to my knowledge there are 2 available polyfills:

  • core-js
  • reflect-metadata

Problem here is if you were to have both of them in a project your metadata gets wiped as each polyfill is replacing each others polyfill (this may be fixed now but was an issue a few months back).

Minimal reproduction of the problem with instructions

  • Make a new project
  • Add restjs dependencies
  • See error for missing reflect-metadata 0.1.10
  • install 0.1.12 version of reflect-metadata
  • See error for missing reflect-metadata 0.1.10

What is the motivation / use case for changing the behavior?

It just seemed odd that it should force you to use a specific version of a polyfill, and in some cases people may want to use core-js which would probably cause decorators that use metadata to blow up.

Recommended solution?

I would remove the dependency on reflect-metadata entirely, and just include a devDependency for @types/reflect-metadata, that will allow you to write TS code that uses metadata, then you require the consumer to provide a relevant polyfill (as listed above).

This is done on one of my other libs:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kamilmysliwieccommented, Apr 21, 2018

Hey @grofit, Thanks for reporting! This issue is fixed in v5.0.0 (currently v5.0.0-beta.2).

0reactions
lock[bot]commented, Sep 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reflect-metadata - npm
Latest version: 0.1.13, last published: 4 years ago. Start using reflect-metadata in your project by running `npm i reflect-metadata`.
Read more >
Introduction to “reflect-metadata” package and its ECMAScript ...
The require('reflect-metadata') import statement is special. This imports the reflect-metadata package which adds the proposed methods such as ...
Read more >
Why reflect-metadata suc*s - DEV Community ‍ ‍
The reflect-metadata library enables us to write decorators that will read metadata from the static type and this metadata may affect your ...
Read more >
reflect metadata in typescript - YouTube
Reflect metadata in typescript build further on the video of last week. I explain in this video how to use metadata on top...
Read more >
What is reflect-metadata in typescript - Stack Overflow
reflect -metadata Allows you to do runtime reflection on types. The native (non reflect-metadata) version of type inference is much poorer ...
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