From 1c275841aa34c5c12187acc9fa4a113316e9c283 Mon Sep 17 00:00:00 2001 From: Claas Ahlrichs Date: Mon, 18 Jun 2018 06:43:16 +0200 Subject: [PATCH 1/6] generated files for "starwars-names" package --- types/starwars-names/index.d.ts | 39 ++++++++++++++++++++ types/starwars-names/starwars-names-tests.ts | 0 types/starwars-names/tsconfig.json | 22 +++++++++++ types/starwars-names/tslint.json | 1 + 4 files changed, 62 insertions(+) create mode 100644 types/starwars-names/index.d.ts create mode 100644 types/starwars-names/starwars-names-tests.ts create mode 100644 types/starwars-names/tsconfig.json create mode 100644 types/starwars-names/tslint.json diff --git a/types/starwars-names/index.d.ts b/types/starwars-names/index.d.ts new file mode 100644 index 0000000000..0d2a23d66f --- /dev/null +++ b/types/starwars-names/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for starwars-names 1.6 +// Project: https://github.com/kentcdodds/starwars-names#readme +// 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/starwars-names/starwars-names-tests.ts b/types/starwars-names/starwars-names-tests.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/types/starwars-names/tsconfig.json b/types/starwars-names/tsconfig.json new file mode 100644 index 0000000000..90bf11ab77 --- /dev/null +++ b/types/starwars-names/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", + "starwars-names-tests.ts" + ] +} diff --git a/types/starwars-names/tslint.json b/types/starwars-names/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/starwars-names/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 755fdae13f7c32d17ce9042e5507c5de5837425f Mon Sep 17 00:00:00 2001 From: Claas Ahlrichs Date: Tue, 19 Jun 2018 06:43:25 +0200 Subject: [PATCH 2/6] added exports for "starwars-names" --- types/starwars-names/index.d.ts | 39 ++++----------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/types/starwars-names/index.d.ts b/types/starwars-names/index.d.ts index 0d2a23d66f..a03a7b5fac 100644 --- a/types/starwars-names/index.d.ts +++ b/types/starwars-names/index.d.ts @@ -1,39 +1,8 @@ // Type definitions for starwars-names 1.6 // Project: https://github.com/kentcdodds/starwars-names#readme -// Definitions by: My Self +// Definitions by: Claas Ahlrichs // 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 +export as namespace starwarsNames; +export const all: string[]; +export function random(number: number): number; From d8dabe48c508139fdb6d20d92bbabf3ea0ca0d23 Mon Sep 17 00:00:00 2001 From: Claas Ahlrichs Date: Wed, 20 Jun 2018 06:43:33 +0200 Subject: [PATCH 3/6] added "strictFunctionTypes" to tsconfig.json --- types/starwars-names/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/starwars-names/tsconfig.json b/types/starwars-names/tsconfig.json index 90bf11ab77..009a9d6ef3 100644 --- a/types/starwars-names/tsconfig.json +++ b/types/starwars-names/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 716d2435c782d275b29b6d69aaff8bceffdf6351 Mon Sep 17 00:00:00 2001 From: Claas Ahlrichs Date: Wed, 20 Jun 2018 06:43:38 +0200 Subject: [PATCH 4/6] added tests to "starwars-names" --- types/starwars-names/starwars-names-tests.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/starwars-names/starwars-names-tests.ts b/types/starwars-names/starwars-names-tests.ts index e69de29bb2..bb2f4dc232 100644 --- a/types/starwars-names/starwars-names-tests.ts +++ b/types/starwars-names/starwars-names-tests.ts @@ -0,0 +1,5 @@ +import * as names from "starwars-names"; + +const allNames = names.all; +const randomName = names.random(); +const threeRandomNames = names.random(3); From b132594ecea598b9cc0eab699d15a7ac96b41af0 Mon Sep 17 00:00:00 2001 From: Claas Ahlrichs Date: Wed, 20 Jun 2018 06:43:43 +0200 Subject: [PATCH 5/6] marked number of random starwars names as optional --- types/starwars-names/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/starwars-names/index.d.ts b/types/starwars-names/index.d.ts index a03a7b5fac..2fa218d315 100644 --- a/types/starwars-names/index.d.ts +++ b/types/starwars-names/index.d.ts @@ -5,4 +5,4 @@ export as namespace starwarsNames; export const all: string[]; -export function random(number: number): number; +export function random(number?: number): number; From 2a60a12d0a0f7285e9fd4eab4e3d295322ce52a9 Mon Sep 17 00:00:00 2001 From: Claas Ahlrichs Date: Wed, 20 Jun 2018 06:43:48 +0200 Subject: [PATCH 6/6] added dedicated export for getting a single starwars name --- types/starwars-names/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/starwars-names/index.d.ts b/types/starwars-names/index.d.ts index 2fa218d315..54f4e17c3b 100644 --- a/types/starwars-names/index.d.ts +++ b/types/starwars-names/index.d.ts @@ -5,4 +5,5 @@ export as namespace starwarsNames; export const all: string[]; -export function random(number?: number): number; +export function random(): string; +export function random(number: number): string[];