(aws-lambda-nodejs): ICommandHooks requires all hooks to be implementated
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Reproduction Steps
```
new lambda.NodejsFunction(this, "LambdaFunction", {
bundling: {
commandHooks: {
afterBundling(inputDir: string, outputDir: string): string[] {
return [`echo "hello world"`];
},
},
},
});
```
### What did you expect to happen?
For this to be valid, and the equivalent of defining no commands for `beforeBundling` and `beforeInstall`.
### What actually happened?
`Type '{ afterBundling(inputDir: string, outputDir: string): string[]; }' is missing the following properties from type 'ICommandHooks': beforeBundling, beforeInstall`
### Environment
- **CDK CLI Version :** 1.91.0
- **Framework Version:** 1.91.0
- **Node.js Version:** v14.15.1
- **OS :** macOS Catalina
- **Language (Version):** Typescript (4.2.3)
### Other
Happy to provide a pull-request for this, looks very easy to fix. Unless I'm missing something we can just declare the functions as optional and then default them to the equivalent of `() => []`.
---
This is :bug: Bug Report
Contributor guide
Research direction
Start from the ICommandHooks definition used by NodejsFunction bundling and reproduce the TypeScript error with the afterBundling-only example in the issue. Check the bundling command-hook handling for omitted hooks; done means the example type-checks and missing hooks behave like empty command lists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100