diff --git a/types/cfn-response/cfn-response-tests.ts b/types/cfn-response/cfn-response-tests.ts new file mode 100644 index 0000000000..b9633c17aa --- /dev/null +++ b/types/cfn-response/cfn-response-tests.ts @@ -0,0 +1,12 @@ +import * as cfn from "cfn-response"; +import { CloudFormationCustomResourceEvent, Context } from "aws-lambda"; + +declare const event: CloudFormationCustomResourceEvent; +declare const context: Context; + +// $ExpectType void +cfn.send(event, context, cfn.SUCCESS, { sample: 123 }, "abc"); +// $ExpectType void +cfn.send(event, context, "SUCCESS"); +// $ExpectError +cfn.send(event, context, "", {}); diff --git a/types/cfn-response/index.d.ts b/types/cfn-response/index.d.ts new file mode 100644 index 0000000000..54cb63dfef --- /dev/null +++ b/types/cfn-response/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for cfn-response 1.0 +// Project: https://github.com/LukeMizuhashi/cfn-response +// Definitions by: Ivo Murrell +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { CloudFormationCustomResourceEvent, Context } from "aws-lambda"; + +export type ResponseStatus = "SUCCESS" | "FAILED"; +export const SUCCESS: ResponseStatus; +export const FAILED: ResponseStatus; + +export function send( + event: CloudFormationCustomResourceEvent, + context: Context, + responseStatus: ResponseStatus, + responseData?: object, + physicalResourceId?: string +): void; diff --git a/types/cfn-response/tsconfig.json b/types/cfn-response/tsconfig.json new file mode 100644 index 0000000000..0aff9f9071 --- /dev/null +++ b/types/cfn-response/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cfn-response-tests.ts" + ] +} diff --git a/types/cfn-response/tslint.json b/types/cfn-response/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cfn-response/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }