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.

Question: TypeScript Configuration / getOwnMetadata() returns undefined

See original GitHub issue

Hello,

I try to use this project for my next js-server application. I tried many things to got this to working but for whatever reason the metadata could not be readen.

As far as I understand the problem for me are the getRouter() implementation in the main Server.js file. Line 65 always returns undefined:

var classMetadata = Reflect.getOwnMetadata(types_1.classMetadataKey, prototype);

Maybe I messed up with the tsconfig. These are my current settings:

{
  "compilerOptions": {
    "target": "es6",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
    "declaration": true,                   /* Generates corresponding '.d.ts' file. */
    "outDir": "./dist",                       /* Redirect output structure to the directory. */
    "baseUrl": "./",
    "importHelpers": true,                    /* Import emit helpers from 'tslib'. */
    "strict": true,                           /* Enable all strict type-checking options. */
    "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
    "esModuleInterop": true,                  /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
    "experimentalDecorators": true,           /* Enables experimental support for ES7 decorators. */
    "emitDecoratorMetadata": true,            /* Enables experimental support for emitting type metadata for decorators. */
    "skipLibCheck": true,                     /* Skip type checking of declaration files. */
    "forceConsistentCasingInFileNames": true  /* Disallow inconsistently-cased references to the same file. */
  }
}

For the demo purpose I used the example UserController.ts provided by the example application.

TypeScript: 3.9.2 Node: v14.1.0 npm: 6.14.4 @overnightjs/core 1.7.0

The readme says something about the lib property but no more information are given there -_- Many thanks for your support in advance.

Dennis

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
seanpmaxwellcommented, May 26, 2020

Please upgrade to 1.7.3 to make this problem go away

0reactions
tomgelucommented, May 26, 2020

I downgraded to 1.6.2 and it solved it. 1.7.2 fixes it too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reflect.getMetadata is returning undefined - Stack Overflow
In this case I want to use decorators to look at the property, look at the typescript type, and then be able to...
Read more >
Reflect - JavaScript - MDN Web Docs
Chrome Edge Firefox Reflect Full support. Chrome49. Toggle history Full support. Edge12. Toggle history Full... apply Full support. Chrome49. Toggle history Full support. Edge12. Toggle...
Read more >
Introduction to “reflect-metadata” package and its ECMAScript ...
In this lesson, we are going to take a look at the reflect-metadata package used by TypeScript to design decorators. This package is...
Read more >
Solution - Abitrarily Idiosyncratic Randomness
For cyclic dependent classes, at least one class' annotation is undefined (ES3/5), or the script is crashed before it can run (ES6).
Read more >
reflect-metadata - npm
TypeScript icon, indicating that this package has built-in type declarations ... C is stored in C.[[Metadata]], with undefined as the key.
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