From cebee43d80e672d95bcbd8fed69eb7819fedb276 Mon Sep 17 00:00:00 2001 From: DovidM Date: Thu, 14 Dec 2017 10:12:11 -0500 Subject: [PATCH 1/7] Generated files --- types/word-list-json/index.d.ts | 39 ++++++++++++++++++++ types/word-list-json/tsconfig.json | 22 +++++++++++ types/word-list-json/tslint.json | 1 + types/word-list-json/word-list-json-tests.ts | 0 4 files changed, 62 insertions(+) create mode 100644 types/word-list-json/index.d.ts create mode 100644 types/word-list-json/tsconfig.json create mode 100644 types/word-list-json/tslint.json create mode 100644 types/word-list-json/word-list-json-tests.ts diff --git a/types/word-list-json/index.d.ts b/types/word-list-json/index.d.ts new file mode 100644 index 0000000000..0dec6547e2 --- /dev/null +++ b/types/word-list-json/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for word-list-json 0.2 +// Project: https://github.com/sindresorhus/word-list +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/*~ If this module is a UMD module that exposes a global variable 'myLib' when + *~ loaded outside a module loader environment, declare that global here. + *~ Otherwise, delete this declaration. + */ +export as namespace myLib; + +/*~ If this module has methods, declare them as functions like so. + */ +export function myMethod(a: string): string; +export function myOtherMethod(a: number): number; + +/*~ You can declare types that are available via importing the module */ +export interface someType { + name: string; + length: number; + extras?: string[]; +} + +/*~ You can declare properties of the module using const, let, or var */ +export const myField: number; + +/*~ If there are types, properties, or methods inside dotted names + *~ of the module, declare them inside a 'namespace'. + */ +export namespace subProp { + /*~ For example, given this definition, someone could write: + *~ import { subProp } from 'yourModule'; + *~ subProp.foo(); + *~ or + *~ import * as yourMod from 'yourModule'; + *~ yourMod.subProp.foo(); + */ + export function foo(): void; +} \ No newline at end of file diff --git a/types/word-list-json/tsconfig.json b/types/word-list-json/tsconfig.json new file mode 100644 index 0000000000..af12c82665 --- /dev/null +++ b/types/word-list-json/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", + "word-list-json-tests.ts" + ] +} diff --git a/types/word-list-json/tslint.json b/types/word-list-json/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/word-list-json/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/word-list-json/word-list-json-tests.ts b/types/word-list-json/word-list-json-tests.ts new file mode 100644 index 0000000000..e69de29bb2 From c693da26678828accdb6e02bbef2ee511dc35c9a Mon Sep 17 00:00:00 2001 From: DovidM Date: Thu, 14 Dec 2017 15:49:23 -0500 Subject: [PATCH 2/7] Added typing --- types/word-list-json/index.d.ts | 40 +++++++-------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/types/word-list-json/index.d.ts b/types/word-list-json/index.d.ts index 0dec6547e2..4c9ffb751f 100644 --- a/types/word-list-json/index.d.ts +++ b/types/word-list-json/index.d.ts @@ -1,39 +1,15 @@ // Type definitions for word-list-json 0.2 // Project: https://github.com/sindresorhus/word-list -// Definitions by: My Self +// Definitions by: Dovid Meiseles // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/*~ If this module is a UMD module that exposes a global variable 'myLib' when - *~ loaded outside a module loader environment, declare that global here. - *~ Otherwise, delete this declaration. - */ -export as namespace myLib; - -/*~ If this module has methods, declare them as functions like so. - */ -export function myMethod(a: string): string; -export function myOtherMethod(a: number): number; - /*~ You can declare types that are available via importing the module */ -export interface someType { - name: string; - length: number; - extras?: string[]; +interface Lengths { + [key: string]: number; } +export const words: string[]; +export const lengths: Lengths; -/*~ You can declare properties of the module using const, let, or var */ -export const myField: number; - -/*~ If there are types, properties, or methods inside dotted names - *~ of the module, declare them inside a 'namespace'. - */ -export namespace subProp { - /*~ For example, given this definition, someone could write: - *~ import { subProp } from 'yourModule'; - *~ subProp.foo(); - *~ or - *~ import * as yourMod from 'yourModule'; - *~ yourMod.subProp.foo(); - */ - export function foo(): void; -} \ No newline at end of file +export default interface Words { + words: typeof words & typeof lengths; +} From 1490613596547e46114d5a268f6b63fd123807c7 Mon Sep 17 00:00:00 2001 From: DovidM Date: Thu, 14 Dec 2017 16:12:45 -0500 Subject: [PATCH 3/7] Made types clearer, added example --- types/word-list-json/index.d.ts | 11 ++++++----- types/word-list-json/word-list-json-tests.ts | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/word-list-json/index.d.ts b/types/word-list-json/index.d.ts index 4c9ffb751f..a9435519ce 100644 --- a/types/word-list-json/index.d.ts +++ b/types/word-list-json/index.d.ts @@ -4,12 +4,13 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /*~ You can declare types that are available via importing the module */ + interface Lengths { [key: string]: number; } -export const words: string[]; -export const lengths: Lengths; -export default interface Words { - words: typeof words & typeof lengths; -} +type words = string[]; + +export default interface Words extends words { + lengths: Lengths; +} \ No newline at end of file diff --git a/types/word-list-json/word-list-json-tests.ts b/types/word-list-json/word-list-json-tests.ts index e69de29bb2..2198e4396e 100644 --- a/types/word-list-json/word-list-json-tests.ts +++ b/types/word-list-json/word-list-json-tests.ts @@ -0,0 +1,3 @@ +import wordListJson from 'word-list-json'; + +const words: wordListJson['lengths'] = { '123': 123 }; From ac8197d94979c00e707d9f58e0c283312201013b Mon Sep 17 00:00:00 2001 From: DovidM Date: Thu, 14 Dec 2017 16:36:54 -0500 Subject: [PATCH 4/7] Nothing to test --- types/word-list-json/word-list-json-tests.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/types/word-list-json/word-list-json-tests.ts b/types/word-list-json/word-list-json-tests.ts index 2198e4396e..e69de29bb2 100644 --- a/types/word-list-json/word-list-json-tests.ts +++ b/types/word-list-json/word-list-json-tests.ts @@ -1,3 +0,0 @@ -import wordListJson from 'word-list-json'; - -const words: wordListJson['lengths'] = { '123': 123 }; From 18c1fba49771618ece93cf9b7b3c934b8cef95b4 Mon Sep 17 00:00:00 2001 From: DovidM Date: Fri, 15 Dec 2017 07:29:01 -0500 Subject: [PATCH 5/7] Made a regular (non default) export --- types/word-list-json/index.d.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/types/word-list-json/index.d.ts b/types/word-list-json/index.d.ts index a9435519ce..e221d3795f 100644 --- a/types/word-list-json/index.d.ts +++ b/types/word-list-json/index.d.ts @@ -2,15 +2,19 @@ // Project: https://github.com/sindresorhus/word-list // Definitions by: Dovid Meiseles // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/*~ You can declare types that are available via importing the module */ +// TypeScript Version: 2.4 interface Lengths { [key: string]: number; } -type words = string[]; +export const lengths: Lengths; -export default interface Words extends words { +type wordsArray = string[]; +interface Words extends wordsArray { lengths: Lengths; -} \ No newline at end of file +} + +declare const words: Words; + +export default words; From 11e3c1ac94d20eb36f03b410806989b410fe794f Mon Sep 17 00:00:00 2001 From: DovidM Date: Fri, 15 Dec 2017 07:29:09 -0500 Subject: [PATCH 6/7] Added tests --- types/word-list-json/word-list-json-tests.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/word-list-json/word-list-json-tests.ts b/types/word-list-json/word-list-json-tests.ts index e69de29bb2..d12edf731d 100644 --- a/types/word-list-json/word-list-json-tests.ts +++ b/types/word-list-json/word-list-json-tests.ts @@ -0,0 +1,5 @@ +import wordListJson from 'word-list-json'; + +wordListJson.lengths; // $ExpectType Lengths + +wordListJson; // $ExpectType Words From 1d54ed0bcde80e6e45e7bab87a98b027b4205e04 Mon Sep 17 00:00:00 2001 From: DovidM Date: Fri, 15 Dec 2017 07:29:28 -0500 Subject: [PATCH 7/7] Fixed tslint error --- types/word-list-json/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/word-list-json/tsconfig.json b/types/word-list-json/tsconfig.json index af12c82665..8f34d90409 100644 --- a/types/word-list-json/tsconfig.json +++ b/types/word-list-json/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../"