From c679a8e691db619614c4acb666b768ef2f1508d2 Mon Sep 17 00:00:00 2001 From: Ivo Murrell Date: Sat, 1 Dec 2018 02:32:31 +0000 Subject: [PATCH] Add type definitions for cfn-response package. --- types/cfn-response/cfn-response-tests.ts | 12 ++++++++++++ types/cfn-response/index.d.ts | 19 +++++++++++++++++++ types/cfn-response/tsconfig.json | 23 +++++++++++++++++++++++ types/cfn-response/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 types/cfn-response/cfn-response-tests.ts create mode 100644 types/cfn-response/index.d.ts create mode 100644 types/cfn-response/tsconfig.json create mode 100644 types/cfn-response/tslint.json 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" }