Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: TypeScript Configuration / getOwnMetadata() returns undefined #56

Closed
dhemeier opened this issue May 24, 2020 · 7 comments
Closed

Comments

@dhemeier
Copy link

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

@tomgelu
Copy link

tomgelu commented May 25, 2020

I have the same issue.

@seanpmaxwell
Copy link
Owner

seanpmaxwell commented May 25, 2020

Here's my tsconfig.json. Try with this and see if it helps. I'm not able to reproduce the issue. But I did notice some differences in our tsconfigs.

{
  "compilerOptions": {
    "baseUrl": "./",
    "emitDecoratorMetadata": true,
    "declaration": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "removeComments": true,
    "strict": true,
    "target": "es6",
    "types": [
      "node"
    ],
    "paths": {
      "@overnightjs/core": ["../src/core"],
      "@overnightjs/jwt": ["../src/jwt"],
      "@overnightjs/logger": ["../src/logger"]
    }
  },
  "include": [
    "./src/**/*"
  ],
  "exclude": [
    "**/node_modules/"
  ]
}

@joeykilpatrick
Copy link
Contributor

@seanpmaxwell There is a problem with the published version 1.7.0. Old files from 1.6.x are included (like decorators.js) which should not be produced with tsc. These files are overriding the changes from 1.7.0 and are causing all controllers to not be added when addControllers is used.

@seanpmaxwell
Copy link
Owner

Hmm i made sure to tsc before publishing. I thought that would overwrite all old files. I deleted .d.ts and .js and .js.map files this time and re-ran tsc. Try again everyone.

@seanpmaxwell
Copy link
Owner

Let me know if version 1.7.2 fixes the issue.

@tomgelu
Copy link

tomgelu commented May 26, 2020

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

@seanpmaxwell
Copy link
Owner

Please upgrade to 1.7.3 to make this problem go away

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants