From f1f3a403f14d13272d9b250e20ad9987ffc10f7f Mon Sep 17 00:00:00 2001 From: William LeGate Date: Thu, 13 Sep 2018 18:32:05 -0700 Subject: [PATCH 01/11] Adds type definitions for 'franc' --- types/franc/franc-tests.ts | 14 ++++++++++++++ types/franc/index.d.ts | 30 ++++++++++++++++++++++++++++++ types/franc/tsconfig.json | 22 ++++++++++++++++++++++ types/franc/tslint.json | 1 + 4 files changed, 67 insertions(+) create mode 100644 types/franc/franc-tests.ts create mode 100644 types/franc/index.d.ts create mode 100644 types/franc/tsconfig.json create mode 100644 types/franc/tslint.json diff --git a/types/franc/franc-tests.ts b/types/franc/franc-tests.ts new file mode 100644 index 0000000000..475f636506 --- /dev/null +++ b/types/franc/franc-tests.ts @@ -0,0 +1,14 @@ +import franc = require('franc'); + +const testText = 'This is an example sentence'; +const testOptions = { + minLength: 3, + whitelist: ['eng'], + blacklist: [], +}; + +franc(testText); +franc(testText, testOptions); + +franc.all(testText); +franc.all(testText, testOptions)[0]; diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts new file mode 100644 index 0000000000..3dc640f8d3 --- /dev/null +++ b/types/franc/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for franc 4.0.0 +// Project: https://github.com/wooorm/franc/ +// Definitions by: William LeGate +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.0.3 + +declare module 'franc' { + // ISO 639-3 code (see: https://iso639-3.sil.org/code_tables/639/data) + type ISO6393 = string; + + // Range [0, 1] + type Confidence = number; + + interface Options { + minLength?: number; + whitelist?: Array; + blacklist?: Array; + } + + function detect(text: string, options?: Options): ISO6393; + + namespace detect { + export function all( + text: string, + options?: Options + ): Array<[ISO6393, number]>; + } + + export = detect; +} diff --git a/types/franc/tsconfig.json b/types/franc/tsconfig.json new file mode 100644 index 0000000000..826b4b56e1 --- /dev/null +++ b/types/franc/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", + "franc-tests.ts" + ] +} diff --git a/types/franc/tslint.json b/types/franc/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/franc/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 67e5641370610d2ef58b9a58db830ae0be90ac92 Mon Sep 17 00:00:00 2001 From: William LeGate Date: Thu, 13 Sep 2018 18:34:37 -0700 Subject: [PATCH 02/11] Updates tab size to 4 spaces --- types/franc/index.d.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts index 3dc640f8d3..eb1a942517 100644 --- a/types/franc/index.d.ts +++ b/types/franc/index.d.ts @@ -5,26 +5,26 @@ // TypeScript Version: 3.0.3 declare module 'franc' { - // ISO 639-3 code (see: https://iso639-3.sil.org/code_tables/639/data) - type ISO6393 = string; + // ISO 639-3 code (see: https://iso639-3.sil.org/code_tables/639/data) + type ISO6393 = string; - // Range [0, 1] - type Confidence = number; + // Range [0, 1] + type Confidence = number; - interface Options { - minLength?: number; - whitelist?: Array; - blacklist?: Array; - } + interface Options { + minLength?: number; + whitelist?: Array; + blacklist?: Array; + } - function detect(text: string, options?: Options): ISO6393; + function detect(text: string, options?: Options): ISO6393; - namespace detect { - export function all( - text: string, - options?: Options - ): Array<[ISO6393, number]>; - } + namespace detect { + export function all( + text: string, + options?: Options + ): Array<[ISO6393, number]>; + } - export = detect; + export = detect; } From 72466d36fc1a9599ade8a208078f812428671734 Mon Sep 17 00:00:00 2001 From: William LeGate Date: Sat, 15 Sep 2018 18:36:28 -0700 Subject: [PATCH 03/11] Removes comment that ca was causing a CI build failure --- types/franc/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts index eb1a942517..4760d0e97a 100644 --- a/types/franc/index.d.ts +++ b/types/franc/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/wooorm/franc/ // Definitions by: William LeGate // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.0.3 declare module 'franc' { // ISO 639-3 code (see: https://iso639-3.sil.org/code_tables/639/data) From 8ed0d10d1664403cd519854dfb7f1797518ed77d Mon Sep 17 00:00:00 2001 From: William LeGate Date: Sat, 15 Sep 2018 18:41:23 -0700 Subject: [PATCH 04/11] Adds 'strictFunctionTypes' to tsconfig --- types/franc/tsconfig.json | 14 ++++---------- types/freedom/tsconfig.json | 16 ++++------------ 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/types/franc/tsconfig.json b/types/franc/tsconfig.json index 826b4b56e1..2fe0151ec5 100644 --- a/types/franc/tsconfig.json +++ b/types/franc/tsconfig.json @@ -1,22 +1,16 @@ { "compilerOptions": { "module": "commonjs", - "lib": [ - "es6" - ], + "lib": ["es6"], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, - "files": [ - "index.d.ts", - "franc-tests.ts" - ] + "files": ["index.d.ts", "franc-tests.ts"] } diff --git a/types/freedom/tsconfig.json b/types/freedom/tsconfig.json index dd0bd2e13c..adada163d4 100644 --- a/types/freedom/tsconfig.json +++ b/types/freedom/tsconfig.json @@ -1,24 +1,16 @@ { - "files": [ - "index.d.ts", - "freedom-tests.ts" - ], + "files": ["index.d.ts", "freedom-tests.ts"], "compilerOptions": { "module": "commonjs", - "lib": [ - "es6", - "dom" - ], + "lib": ["es6", "dom"], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, "strictFunctionTypes": true, "baseUrl": "../", - "typeRoots": [ - "../" - ], + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true } -} \ No newline at end of file +} From 0a937e813357f6397a034bbec5c04b98c6da66b4 Mon Sep 17 00:00:00 2001 From: William LeGate Date: Sat, 15 Sep 2018 18:49:16 -0700 Subject: [PATCH 05/11] Removes franc patch version --- types/franc/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts index 4760d0e97a..2e0dbdcd82 100644 --- a/types/franc/index.d.ts +++ b/types/franc/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for franc 4.0.0 +// Type definitions for franc 4.0 // Project: https://github.com/wooorm/franc/ // Definitions by: William LeGate // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 7ce22877a19965067e48c5e54164936fa23b2312 Mon Sep 17 00:00:00 2001 From: William LeGate Date: Sat, 15 Sep 2018 18:54:25 -0700 Subject: [PATCH 06/11] Updates array type declaration to comply with CI testing --- types/franc/index.d.ts | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts index 2e0dbdcd82..ac2dc1e90d 100644 --- a/types/franc/index.d.ts +++ b/types/franc/index.d.ts @@ -3,27 +3,20 @@ // Definitions by: William LeGate // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module 'franc' { - // ISO 639-3 code (see: https://iso639-3.sil.org/code_tables/639/data) - type ISO6393 = string; +// ISO 639-3 code (see: https://iso639-3.sil.org/code_tables/639/data) +export type ISO6393 = string; - // Range [0, 1] - type Confidence = number; +// Range [0, 1] +export type Confidence = number; - interface Options { - minLength?: number; - whitelist?: Array; - blacklist?: Array; - } +export interface Options { + minLength?: number; + whitelist?: [ISO6393]; + blacklist?: [ISO6393]; +} - function detect(text: string, options?: Options): ISO6393; +export function detect(text: string, options?: Options): ISO6393; - namespace detect { - export function all( - text: string, - options?: Options - ): Array<[ISO6393, number]>; - } - - export = detect; +export namespace detect { + function all(text: string, options?: Options): [ISO6393, number]; } From 2105750855ffcba99d4ffd4e7873f6084d82cc82 Mon Sep 17 00:00:00 2001 From: William LeGate Date: Sat, 15 Sep 2018 19:17:04 -0700 Subject: [PATCH 07/11] Updates tests --- types/franc/franc-tests.ts | 10 +++++----- types/franc/index.d.ts | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/types/franc/franc-tests.ts b/types/franc/franc-tests.ts index 475f636506..cad5c24817 100644 --- a/types/franc/franc-tests.ts +++ b/types/franc/franc-tests.ts @@ -1,4 +1,4 @@ -import franc = require('franc'); +import { detect } from 'franc'; const testText = 'This is an example sentence'; const testOptions = { @@ -7,8 +7,8 @@ const testOptions = { blacklist: [], }; -franc(testText); -franc(testText, testOptions); +detect(testText); +detect(testText, testOptions); -franc.all(testText); -franc.all(testText, testOptions)[0]; +detect.all(testText); +detect.all(testText, testOptions)[0]; diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts index ac2dc1e90d..f99f237ead 100644 --- a/types/franc/index.d.ts +++ b/types/franc/index.d.ts @@ -11,8 +11,8 @@ export type Confidence = number; export interface Options { minLength?: number; - whitelist?: [ISO6393]; - blacklist?: [ISO6393]; + whitelist?: ISO6393[]; + blacklist?: ISO6393[]; } export function detect(text: string, options?: Options): ISO6393; @@ -20,3 +20,5 @@ export function detect(text: string, options?: Options): ISO6393; export namespace detect { function all(text: string, options?: Options): [ISO6393, number]; } + +export default detect; From bab4ac88e2a45637119d76317c1ae7f01ef3f5ba Mon Sep 17 00:00:00 2001 From: William LeGate Date: Mon, 17 Sep 2018 14:56:23 -0700 Subject: [PATCH 08/11] Removes default export from types declaration file --- types/franc/index.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts index f99f237ead..c6b8ca5f8b 100644 --- a/types/franc/index.d.ts +++ b/types/franc/index.d.ts @@ -19,6 +19,4 @@ export function detect(text: string, options?: Options): ISO6393; export namespace detect { function all(text: string, options?: Options): [ISO6393, number]; -} - -export default detect; +} \ No newline at end of file From 91945dbd9a53b6bd035577fd982d10d88bc7f6b0 Mon Sep 17 00:00:00 2001 From: William LeGate Date: Mon, 17 Sep 2018 15:16:44 -0700 Subject: [PATCH 09/11] Adds newline to end of file --- types/franc/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts index c6b8ca5f8b..3447f25cc8 100644 --- a/types/franc/index.d.ts +++ b/types/franc/index.d.ts @@ -19,4 +19,4 @@ export function detect(text: string, options?: Options): ISO6393; export namespace detect { function all(text: string, options?: Options): [ISO6393, number]; -} \ No newline at end of file +} From 0be5866832dfbe3c91f2d83ea0bfd94db72ce801 Mon Sep 17 00:00:00 2001 From: William LeGate Date: Mon, 17 Sep 2018 16:24:52 -0700 Subject: [PATCH 10/11] Updates exports to only export 'detect' --- types/franc/franc-tests.ts | 2 +- types/franc/index.d.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/types/franc/franc-tests.ts b/types/franc/franc-tests.ts index cad5c24817..99cd097844 100644 --- a/types/franc/franc-tests.ts +++ b/types/franc/franc-tests.ts @@ -1,4 +1,4 @@ -import { detect } from 'franc'; +import * as detect from 'franc'; const testText = 'This is an example sentence'; const testOptions = { diff --git a/types/franc/index.d.ts b/types/franc/index.d.ts index 3447f25cc8..613c46946f 100644 --- a/types/franc/index.d.ts +++ b/types/franc/index.d.ts @@ -4,19 +4,21 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // ISO 639-3 code (see: https://iso639-3.sil.org/code_tables/639/data) -export type ISO6393 = string; +type ISO6393 = string; // Range [0, 1] -export type Confidence = number; +type Confidence = number; -export interface Options { +interface Options { minLength?: number; whitelist?: ISO6393[]; blacklist?: ISO6393[]; } -export function detect(text: string, options?: Options): ISO6393; +declare function detect(text: string, options?: Options): ISO6393; -export namespace detect { +declare namespace detect { function all(text: string, options?: Options): [ISO6393, number]; } + +export = detect; From b93e2adb39a8505ea83198faa077b3c225e5a41f Mon Sep 17 00:00:00 2001 From: William LeGate Date: Mon, 17 Sep 2018 17:53:59 -0700 Subject: [PATCH 11/11] Implements changes sug suggested by @plantain-00 (see: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/28919#pullrequestreview-156171248) --- types/franc/franc-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/franc/franc-tests.ts b/types/franc/franc-tests.ts index 99cd097844..cb687e1001 100644 --- a/types/franc/franc-tests.ts +++ b/types/franc/franc-tests.ts @@ -1,4 +1,4 @@ -import * as detect from 'franc'; +import detect = require('franc'); const testText = 'This is an example sentence'; const testOptions = {