Skip to content

Generate alias/intermediary type for function definitionΒ #60

@coyoteecd

Description

@coyoteecd

@fredericbarthelet

Is it possible to generate an intermediary type/alias for the indexer type of AWS functions? Some plugins expect additional configuration properties in the function definition, and this gives compile errors when using a serverless.ts file.

A good example is https://github.com/go-dima/serverless-plugin-conditional-functions.

My serverless.ts file:

const serverlessConfig: AWS = {
  plugins: [
     'serverless-plugin-conditional-functions',
  ],
 // lots of code
 functions: {
   'func1': {
     handler: 'src/func1.ts',
     events: [/*...eventconfig...*/],
     enabled: 'false'
   }
 }
}

The type definition for functions uses a string indexer, and the type of that indexer is inlined.
I want to do something like this:

type ConditionalFunctionsConfig = {
  functions: {
    [key: string]: { enabled?: boolean | string } & ActualFunctionTypeFromAWSType
  }
};

const serverlessConfig: AWS & ConditionalFunctionsConfig = {
  // ...
}

I couldn't figure out a way to get the type starting from the AWS type def, so I'm hoping that if the @serverless/typescript package would provide an alias, then I could use the alias to extend it with additional props as outlined above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions