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

Type definitions for serverless are not upto-date and causing typescript project fail (need type definitions for msk) #8288

Closed
gurbaj5124871 opened this issue Sep 25, 2020 · 3 comments
Assignees
Labels

Comments

@gurbaj5124871
Copy link

When serverless project is created by sls create --template aws-nodejs-typescript, the type definitions from @types/serverless are incompatible with the serverless version 2.3.0.

serverless.yml
const serverlessConfiguration: Serverless = {
  service: {
    name: 'test-serverless',
    // app and org for use with dashboard.serverless.com
    // app: your-app-name,
    // org: your-org-name,
  },
  frameworkVersion: '2',
  custom: {
    webpack: {
      webpackConfig: './webpack.config.js',
      includeModules: true
    }
  },
  // Add the serverless-webpack plugin
  plugins: ['serverless-webpack'],
  provider: {
    name: 'aws',
    runtime: 'nodejs12.x',
    apiGateway: {
      minimumCompressionSize: 1024,
    },
    environment: {
      AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
    },
  },
  functions: {
    hello: {
      handler: 'handler.hello',
      events: [
        {
          http: {
            method: 'get',
            path: 'hello',
          }
        }
      ]
    }
  }
}
sls create --template aws-nodejs-typescript output
Serverless: Generating boilerplate...
 _______                             __
|   _   .-----.----.--.--.-----.----|  .-----.-----.-----.
|   |___|  -__|   _|  |  |  -__|   _|  |  -__|__ --|__ --|
|____   |_____|__|  \___/|_____|__| |__|_____|_____|_____|
|   |   |             The Serverless Application Framework
|       |                           serverless.com, v2.3.0
 -------'

Serverless: Successfully generated boilerplate for template: "aws-nodejs-typescript"
Serverless: NOTE: Please update the "service" property in serverless.yml with your service name

Installed version

Framework Core: 2.3.0
Plugin: 4.0.4
SDK: 2.3.2
Components: 3.1.5

Screenshot 2020-09-25 at 4 37 32 PM

Screenshot 2020-09-25 at 4 37 15 PM

@medikoo
Copy link
Contributor

medikoo commented Sep 25, 2020

@gurbaj5124871 thanks for report. Still in context of this project we do not maintain any TypeScript definitions (afaik it's done in https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/serverless/index.d.ts purely as external community effort).

Note that config schema is validated internally with help of JSON schemas, and schema for msk event is defined here:

this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'msk', {
type: 'object',
properties: {
arn: {
oneOf: [
{ $ref: '#/definitions/awsArnString' },
{ $ref: '#/definitions/awsCfImport' },
{ $ref: '#/definitions/awsCfRef' },
],
},
batchSize: {
type: 'number',
minimum: 1,
maximum: 10000,
},
enabled: {
type: 'boolean',
},
startingPosition: {
type: 'string',
enum: ['LATEST', 'TRIM_HORIZON'],
},
topic: {
type: 'string',
},
},
additionalProperties: false,
required: ['arn', 'topic'],
});
}

@gurbaj5124871
Copy link
Author

@medikoo Thanks for clarifying the issue. I can open the issue there and might get pr opened for the support of msk. This definition schema helps.

@medikoo
Copy link
Contributor

medikoo commented Sep 28, 2020

Thanks @gurbaj5124871! I'm going to close this issue here then

@medikoo medikoo closed this as completed Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants