From b5e934832bd8d108022f83d8051a1e92c1b1b1ff Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Tue, 5 Sep 2017 11:52:46 +0900 Subject: [PATCH 1/2] Add wcwidth --- types/wcwidth/index.d.ts | 10 ++++++++++ types/wcwidth/tsconfig.json | 22 ++++++++++++++++++++++ types/wcwidth/tslint.json | 3 +++ types/wcwidth/wcwidth-tests.ts | 5 +++++ 4 files changed, 40 insertions(+) create mode 100644 types/wcwidth/index.d.ts create mode 100644 types/wcwidth/tsconfig.json create mode 100644 types/wcwidth/tslint.json create mode 100644 types/wcwidth/wcwidth-tests.ts diff --git a/types/wcwidth/index.d.ts b/types/wcwidth/index.d.ts new file mode 100644 index 0000000000..99b2107ba9 --- /dev/null +++ b/types/wcwidth/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for wcwidth 1.0 +// Project: https://github.com/timoxley/wcwidth +// Definitions by: Junyoung Choi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function wcwidth(input: string): number; + +declare namespace wcwidth {} + +export = wcwidth; diff --git a/types/wcwidth/tsconfig.json b/types/wcwidth/tsconfig.json new file mode 100644 index 0000000000..55ce5efd5b --- /dev/null +++ b/types/wcwidth/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "wcwidth-tests.ts" + ] +} diff --git a/types/wcwidth/tslint.json b/types/wcwidth/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/wcwidth/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/wcwidth/wcwidth-tests.ts b/types/wcwidth/wcwidth-tests.ts new file mode 100644 index 0000000000..56e4987a7a --- /dev/null +++ b/types/wcwidth/wcwidth-tests.ts @@ -0,0 +1,5 @@ +import * as wcwidth from 'wcwidth'; + +const length1 = wcwidth('ν•œ'); // => 2 + +const length2 = wcwidth('ν•œκΈ€'); // => 4 From f56d8aacd57d0ec2e56a0ad0ccfb2d4124856759 Mon Sep 17 00:00:00 2001 From: Junyoung Choi Date: Wed, 6 Sep 2017 16:15:21 +0900 Subject: [PATCH 2/2] Remove unnecessary namespace and fix importing expression in test module This implementation is for making `import * as someModule from 'someModule'` is available. But this usage is note appropiate. --- types/wcwidth/index.d.ts | 2 -- types/wcwidth/wcwidth-tests.ts | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/types/wcwidth/index.d.ts b/types/wcwidth/index.d.ts index 99b2107ba9..da9920a611 100644 --- a/types/wcwidth/index.d.ts +++ b/types/wcwidth/index.d.ts @@ -5,6 +5,4 @@ declare function wcwidth(input: string): number; -declare namespace wcwidth {} - export = wcwidth; diff --git a/types/wcwidth/wcwidth-tests.ts b/types/wcwidth/wcwidth-tests.ts index 56e4987a7a..11f150a73c 100644 --- a/types/wcwidth/wcwidth-tests.ts +++ b/types/wcwidth/wcwidth-tests.ts @@ -1,4 +1,4 @@ -import * as wcwidth from 'wcwidth'; +import wcwidth = require('wcwidth'); const length1 = wcwidth('ν•œ'); // => 2