From 79c61037367b1f52064d84eba93ff333d4fdd807 Mon Sep 17 00:00:00 2001 From: Kiran Koirala Date: Wed, 8 Jul 2020 10:37:44 +0545 Subject: [PATCH 1/2] Add typescript type definition for TS projects support --- index.d.ts | 5 +++++ package.json | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..32c9fef --- /dev/null +++ b/index.d.ts @@ -0,0 +1,5 @@ +type anyObject = { + [key: string]: any, +}; + +export default function interpolate(str: string, params: anyObject): string; diff --git a/package.json b/package.json index d84586c..6cbf5e9 100644 --- a/package.json +++ b/package.json @@ -39,5 +39,6 @@ }, "engines": { "node": ">=8" - } + }, + "types": "./index.d.ts" } From 9f10c9f5b79aff1cc51b391160560fca7a7b1e5a Mon Sep 17 00:00:00 2001 From: Kiran Koirala Date: Wed, 8 Jul 2020 11:34:14 +0545 Subject: [PATCH 2/2] Code review changes --- index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 32c9fef..edd9109 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,5 @@ -type anyObject = { - [key: string]: any, -}; +export interface Params { + [key: string]: string | number; +} -export default function interpolate(str: string, params: anyObject): string; +export default function interpolate(str: string, params: Params): string;