From 09e39bfd0f25b16f6a9daa95af3093e99e5e6ad4 Mon Sep 17 00:00:00 2001 From: Hagai Cohen Date: Mon, 15 Aug 2016 14:01:37 +0300 Subject: [PATCH] added definitions for phone --- phone/index.d.ts | 6 ++++++ phone/phone-tests.ts | 12 ++++++++++++ phone/tsconfig.json | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 phone/index.d.ts create mode 100644 phone/phone-tests.ts create mode 100644 phone/tsconfig.json diff --git a/phone/index.d.ts b/phone/index.d.ts new file mode 100644 index 0000000000..4814691de8 --- /dev/null +++ b/phone/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for phone 1.0.8 +// Project: https://github.com/aftership/phone +// Definitions by: Hagai Cohen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export default function phone(phoneNumber: string, countryCode?: string): Array; diff --git a/phone/phone-tests.ts b/phone/phone-tests.ts new file mode 100644 index 0000000000..bc0eb7de6f --- /dev/null +++ b/phone/phone-tests.ts @@ -0,0 +1,12 @@ +import phone from 'phone'; + +phone('+852 6569-8900'); // return ['+85265698900', 'HKG'] +phone('(817) 569-8900'); // return ['+18175698900, 'USA'] +phone('(817) 569-8900', ''); // return ['+18175698900, 'USA'] +phone('(817) 569-8900', 'USA'); // return ['+18175698900', 'USA'] +phone('(817) 569-8900', 'HKG'); // return [] +phone('+1(817) 569-8900', 'HKG'); // return [], as it is not a valid HKG mobile phone number +phone('+1(817) 569-8900', ''); // return ['+18175698900', 'USA'] +phone('(817) 569-8900', ''); // return ['+18175698900', 'USA'] +phone('6123-6123', ''); // return [], as default country is USA +phone('6123-6123', 'HKG'); // return ['+85261236123', 'HKG'] diff --git a/phone/tsconfig.json b/phone/tsconfig.json new file mode 100644 index 0000000000..c4ee98b78c --- /dev/null +++ b/phone/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "phone-tests.ts" + ] +}