Aws-nodejs-typescript — error TS2304: Cannot find name 'PropertyKey'

Hi,

I get the error error “error TS2304: Cannot find name ‘PropertyKey’” after importing a class from external packages such as inversify.

This is the simple case I could build, just a one-liner from the aws-nodejs-typescript template:

import { inject, injectable } from "inversify";

export const hello = (event, context, cb) => {
  const response = {
    statusCode: 200,
    body: JSON.stringify({
      message: 'Go Serverless Webpack (Typescript) v1.0! Your function executed successfully!',
      input: event,
    }),
  };

  cb(null, response);
}

This is the output:

Serverless: Bundling with Webpack...
ts-loader: Using typescript@2.6.2 and /Users/mbranca/code/projects/zmoog/dailybot/service2/tsconfig.json
Time: 1120ms
     Asset     Size  Chunks             Chunk Names
handler.js  2.89 kB       0  [emitted]  handler
   [0] ./handler.ts 338 bytes {0} [built]

ERROR in /Users/mbranca/code/projects/zmoog/dailybot/service2/node_modules/inversify/dts/syntax/constraint_helpers.d.ts
(3,37): error TS2304: Cannot find name 'PropertyKey'.

ERROR in /Users/mbranca/code/projects/zmoog/dailybot/service2/node_modules/inversify/dts/interfaces/interfaces.d.ts
(105,25): error TS2304: Cannot find name 'Map'.

ERROR in /Users/mbranca/code/projects/zmoog/dailybot/service2/node_modules/inversify/dts/interfaces/interfaces.d.ts
(187,19): error TS2304: Cannot find name 'Map'.

  Error --------------------------------------------------

  Webpack compilation error, see above

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Forums:        forum.serverless.com
     Chat:          gitter.im/serverless/serverless

  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           6.10.3
     Serverless Version:     1.24.1

I am not an expert JS/TS developer… maybe I’ve just committed a trivial error… :slight_smile:

Thank you!

It turns out that I was incompetent at a much bugger scale that I was aware… I’ve completely missed a proper configuration for the TS compiler.

This is a working starting point for my journey in TS and Serverless:

{
  "compilerOptions": {
    "sourceMap": true,
    "target": "es5",
    "lib": ["es6"],
    "types": ["node", "reflect-metadata"],
    "module": "commonjs",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

I’m sorry for wasting your attention. :slight_smile:

Maurizio