From c73d53d246d45d0d3976e09a2b9a926c49079394 Mon Sep 17 00:00:00 2001 From: Mael LE GUEN Date: Tue, 3 Dec 2019 09:56:33 +0100 Subject: [PATCH 1/2] fix: unable to import module from typescript --- README.md | 14 ++++++++++++++ index.d.ts | 9 +++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f9dcc79..329b5ec 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,20 @@ console.log(timestamp.utc()); //=> 2018-10-26 ``` +or in typescript: + +```ts +import * as timestamp from 'time-stamp'; +// or if "esModuleInterop": true in tsconfig.json: +// import timestamp from 'time-stamp' + +console.log(timestamp()); +//=> 2018-10-26 + +console.log(timestamp.utc()); +//=> 2018-10-26 +``` + ## Customizing the timestamp You may also pass a string to format the generated timestamp. diff --git a/index.d.ts b/index.d.ts index 7748ab9..97870e7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,5 +1,6 @@ -declare function timestamp(pattern?: string | Date, date?: Date): string -declare function timestampUTC(pattern?: string | Date, date?: Date): string +declare function timestamp(pattern?: string | Date, date?: Date): string; -export default timestamp -export { timestampUTC as utc }; +declare namespace timestamp { + function utc(pattern?: string | Date, date?: Date): string; +} +export = timestamp; From 8e2c7518858b4e46d97bfc6bf359eab4d10557c9 Mon Sep 17 00:00:00 2001 From: Mael LE GUEN Date: Tue, 10 Dec 2019 09:52:18 +0100 Subject: [PATCH 2/2] fix: use recommended typescript import syntax for a cjs module --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 329b5ec..3363a99 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,7 @@ console.log(timestamp.utc()); or in typescript: ```ts -import * as timestamp from 'time-stamp'; -// or if "esModuleInterop": true in tsconfig.json: -// import timestamp from 'time-stamp' +import timestamp = require('time-stamp'); console.log(timestamp()); //=> 2018-10-26