From 2e1a28de3d571ba809cd03686544aec739f48bf6 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Thu, 1 Dec 2016 08:07:00 +0100 Subject: [PATCH 1/6] Added http-link-header --- http-link-header/http-link-header-tests.ts | 28 ++++++++++++++++++++++ http-link-header/index.d.ts | 19 +++++++++++++++ http-link-header/tsconfig.json | 19 +++++++++++++++ http-link-header/tslint.json | 1 + 4 files changed, 67 insertions(+) create mode 100644 http-link-header/http-link-header-tests.ts create mode 100644 http-link-header/index.d.ts create mode 100644 http-link-header/tsconfig.json create mode 100644 http-link-header/tslint.json diff --git a/http-link-header/http-link-header-tests.ts b/http-link-header/http-link-header-tests.ts new file mode 100644 index 0000000000..85145dc8eb --- /dev/null +++ b/http-link-header/http-link-header-tests.ts @@ -0,0 +1,28 @@ +import * as LinkHeader from 'http-link-header'; + +function isBool(bool: boolean): null { + return null; +} + +function isReference(ref: LinkHeader.Reference): null { + return null; +} + +function isString(str: string): null { + return null; +} + +const link = LinkHeader.parse( + '; rel="example"; title="Example Website", ' + + '; rel="alternate"; title="Alternate Example Domain"' +); +const has = link.has('rel', 'alternate'); +isBool(has); +const get = link.get('title', 'Example Website'); +isReference(get); +const rel = link.rel('alternate'); +isReference(rel); +const set = link.set({ rel: 'next', uri: 'http://example.com/next' }); +isReference(set); +const str = link.toString(); +isString(str); diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts new file mode 100644 index 0000000000..f72a1fe065 --- /dev/null +++ b/http-link-header/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for http-link-header v0.6.0 +// Project: https://github.com/jhermsmeier/node-http-link-header +// Definitions by: Christian Rackerseder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Reference { + uri: string; + rel: string; + title?: string; +} +export interface Link { + refs: Array; + has: (attribute: string, value: string) => boolean; + get: (attribute: string, value: string) => Reference; + rel: (value: string) => Reference; + set: (ref: Reference) => Reference; + toString: () => string; +} +export function parse(header: string): Link; diff --git a/http-link-header/tsconfig.json b/http-link-header/tsconfig.json new file mode 100644 index 0000000000..12f90f78bd --- /dev/null +++ b/http-link-header/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", + "http-link-header-tests.ts" + ] +} diff --git a/http-link-header/tslint.json b/http-link-header/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/http-link-header/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 142daba378bca250818450d967265661c79550b1 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Mon, 5 Dec 2016 12:03:53 +0100 Subject: [PATCH 2/6] Fixed Travis build --- http-link-header/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts index f72a1fe065..cb3205c81a 100644 --- a/http-link-header/index.d.ts +++ b/http-link-header/index.d.ts @@ -9,7 +9,7 @@ export interface Reference { title?: string; } export interface Link { - refs: Array; + refs: Reference[]; has: (attribute: string, value: string) => boolean; get: (attribute: string, value: string) => Reference; rel: (value: string) => Reference; From 0d97dfa1eeb25916bee168dffc49e35483a8dece Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 28 Dec 2016 13:55:02 +0100 Subject: [PATCH 3/6] Updated tsconfig.json --- http-link-header/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/http-link-header/tsconfig.json b/http-link-header/tsconfig.json index 12f90f78bd..9fb6d5e158 100644 --- a/http-link-header/tsconfig.json +++ b/http-link-header/tsconfig.json @@ -3,7 +3,8 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "noImplicitThis": true, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From d10885743b370f39cf198576693338c41ec07ea3 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 28 Dec 2016 13:55:14 +0100 Subject: [PATCH 4/6] Fixed version number --- http-link-header/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts index cb3205c81a..615d94f76b 100644 --- a/http-link-header/index.d.ts +++ b/http-link-header/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for http-link-header v0.6.0 +// Type definitions for http-link-header 0.6 // Project: https://github.com/jhermsmeier/node-http-link-header // Definitions by: Christian Rackerseder // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 33f91fb45c54cc13b706347f8ee5ee082653a9c1 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 28 Dec 2016 13:55:26 +0100 Subject: [PATCH 5/6] Removed toString() --- http-link-header/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts index 615d94f76b..b24b01ee4a 100644 --- a/http-link-header/index.d.ts +++ b/http-link-header/index.d.ts @@ -14,6 +14,5 @@ export interface Link { get: (attribute: string, value: string) => Reference; rel: (value: string) => Reference; set: (ref: Reference) => Reference; - toString: () => string; } export function parse(header: string): Link; From 6b165e026db59b660c3da12a6de5b5aa3ea5d702 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Fri, 6 Jan 2017 12:27:28 +0100 Subject: [PATCH 6/6] Fixed function signature --- http-link-header/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/http-link-header/index.d.ts b/http-link-header/index.d.ts index b24b01ee4a..ba208d8595 100644 --- a/http-link-header/index.d.ts +++ b/http-link-header/index.d.ts @@ -10,9 +10,9 @@ export interface Reference { } export interface Link { refs: Reference[]; - has: (attribute: string, value: string) => boolean; - get: (attribute: string, value: string) => Reference; - rel: (value: string) => Reference; - set: (ref: Reference) => Reference; + has(attribute: string, value: string): boolean; + get(attribute: string, value: string): Reference; + rel(value: string): Reference; + set(ref: Reference): Reference; } export function parse(header: string): Link;