-
Notifications
You must be signed in to change notification settings - Fork 27
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
Generate alias/intermediary type for function definition #60
Comments
This is such a painful thing indeed to have |
@colthreepv thanks for the link, you saved me. What I was missing was the NonNullable<> part, the error message from tsc for |
I think I am in the same boat with the
The |
You saved my life... I've spent 2 hours on this... t would be great to export this automatically from '@serverless/typescript' export type ServerlessFunction = NonNullable<AWS['functions']>[string] |
That convo was really helpful to extend for a different plugin. |
I think this deserves a mention in the readme.
if someone else needs this: import { AWS } from '@serverless/typescript';
export type Functions = AWS['functions'];
export type Function = NonNullable<Functions>[string];
export type Events = Function['events'];
export type Event = NonNullable<Events>[number];
export type HttpEvent = Exclude<Extract<Event, { http: unknown }>['http'], string>; |
@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:
The type definition for functions uses a string indexer, and the type of that indexer is inlined.
I want to do something like this:
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.The text was updated successfully, but these errors were encountered: