diff --git a/types/mithril/index.d.ts b/types/mithril/index.d.ts index 254dc35991..8a7a6a6349 100644 --- a/types/mithril/index.d.ts +++ b/types/mithril/index.d.ts @@ -21,9 +21,9 @@ declare function request (options: Mithril.RequestOptions & { url: string declare function request (url: string, options?: Mithril.RequestOptions): Promise; /** Makes a JSON-P request and returns a promise. */ -declare function jsonp(options: Mithril.JsonpOptions & { url: string }): Promise; +declare function jsonp(options: Mithril.JsonpOptions & { url: string }): Promise; // tslint:disable-line:no-unnecessary-generics /** Makes a JSON-P request and returns a promise. */ -declare function jsonp(url: string, options?: Mithril.JsonpOptions): Promise; +declare function jsonp(url: string, options?: Mithril.JsonpOptions): Promise; // tslint:disable-line:no-unnecessary-generics /** Creates an event handler which takes the value of the specified DOM element property and calls a function with it as the argument. */ declare function withAttr(name: string, callback: (value: any) => any): (e: { currentTarget: any, [p: string]: any }) => void; @@ -116,7 +116,7 @@ declare namespace Mithril { /** Whether to send cookies to 3rd party domains. */ withCredentials?: boolean; /** Exposes the underlying XMLHttpRequest object for low-level configuration. */ - config?(xhr: XMLHttpRequest): XMLHttpRequest | void; + config?(xhr: XMLHttpRequest, options: this): XMLHttpRequest | void; /** Headers to append to the request before sending it. */ headers?: { [key: string]: string }; /** A constructor to be applied to each object in the response. */ diff --git a/types/mithril/test/test-api.ts b/types/mithril/test/test-api.ts index a27a674068..69f86c5ee4 100644 --- a/types/mithril/test/test-api.ts +++ b/types/mithril/test/test-api.ts @@ -20,7 +20,7 @@ const FRAME_BUDGET = 100; { const vnode = m.fragment({key: 123}, [m("div")]); console.assert((vnode.children as Array>).length === 1); - console.assert(vnode.children![0].tag === 'div'); + console.assert((vnode.children as Array>)[0].tag === 'div'); } { diff --git a/types/mithril/test/test-component.ts b/types/mithril/test/test-component.ts index a1f8107b0c..a8fecaa28f 100644 --- a/types/mithril/test/test-component.ts +++ b/types/mithril/test/test-component.ts @@ -50,7 +50,7 @@ const comp2: Component = { m(comp2, {title: '', description: ''}); // Correct use with lifecycle method -m(comp2, {title: '', description: '', oncreate: (v) => v.attrs.title + '\n' + v.attrs.description}); +m(comp2, {title: '', description: '', oncreate: (v) => `${v.attrs.title}\n${v.attrs.description}`}); // Properties missing // $ExpectError diff --git a/types/mithril/test/test-request.ts b/types/mithril/test/test-request.ts index 0a0c15c663..dbe4d6b941 100644 --- a/types/mithril/test/test-request.ts +++ b/types/mithril/test/test-request.ts @@ -44,8 +44,9 @@ request('/id', { }); request('/item', { - config: xhr => { + config: (xhr, opts) => { xhr.setRequestHeader('accept', '*'); + console.log(opts.background); return xhr; }, headers: {"Content-Type": "application/json"}, diff --git a/types/mithril/test/test-stream.ts b/types/mithril/test/test-stream.ts index 7fcb6a0372..559f339634 100644 --- a/types/mithril/test/test-stream.ts +++ b/types/mithril/test/test-stream.ts @@ -134,17 +134,6 @@ import { Stream } from 'mithril/stream'; console.assert(b()() === undefined); } -{ - let count = 0; - const a = stream(1); - const b = stream.combine(a => stream.HALT, [a]) - ["fantasy-land/map"](() => { - count++; - return 1; - }); - console.assert(b() === undefined); -} - { const all = stream.merge([ stream(10), @@ -215,112 +204,6 @@ import { Stream } from 'mithril/stream'; console.assert(doubled() === 4); } -{ - const s = stream(); - const doubled = s["fantasy-land/map"]((n: number) => n * 2); - s(3); - console.assert(doubled() === 6); -} - -{ - const s = stream(3); - const doubled = s["fantasy-land/map"]((n: number) => n * 2); - console.assert(doubled() === 6); -} - -{ - const s = stream(); - const mapped = s["fantasy-land/map"](String); - s(undefined); - console.assert(mapped() === "undefined"); -} - -{ - const s = stream(undefined); - const mapped = s["fantasy-land/map"](String); - console.assert(mapped() === "undefined"); -} - -{ - const s = stream(undefined); - const mapped = s["fantasy-land/map"]((_value: undefined) => stream()); - console.assert(mapped()() === undefined); -} - -{ - const s = stream(undefined); - console.assert(s["fantasy-land/map"] === s.map); -} - -{ - const apply = stream((n: number) => n * 2); - const s = stream(3); - const applied = s["fantasy-land/ap"](apply); - console.assert(applied() === 6); - apply(n => n / 3); - console.assert(applied() === 1); - s(9); - console.assert(applied() === 3); -} - -{ - const apply = stream<(value: undefined) => string>(String); - const s = stream(undefined); - const applied = s["fantasy-land/ap"](apply); - console.assert(applied() === "undefined"); - apply(value => String(value) + "a"); - console.assert(applied() === "undefineda"); -} - -{ - const s = stream(3); - const mapped = s["fantasy-land/map"]((v: number) => v); - console.assert(s() === mapped()); -} - -{ - const f = (x: number) => x * 2; - const g = (x: number) => x * x; - const s = stream(3); - const mapped = s["fantasy-land/map"]((value: any) => f(g(value))); - const composed = s["fantasy-land/map"](g)["fantasy-land/map"](f); - console.assert(mapped() === 18); - console.assert(mapped() === composed()); -} - -{ - const a = stream((n: number) => n * 2); - const u = stream((n: number) => n * 3); - const v = stream(5); - const mapped = v["fantasy-land/ap"](u["fantasy-land/ap"](a["fantasy-land/map"]((f: any) => (g: any) => (x: any) => f(g(x))))); - const composed = v["fantasy-land/ap"](u)["fantasy-land/ap"](a); - console.assert(mapped() === 30); - console.assert(mapped() === composed()); -} - -{ - const a = stream()["fantasy-land/of"]((value: number) => value); - const v = stream(5); - console.assert(v["fantasy-land/ap"](a)() === 5); - console.assert(v["fantasy-land/ap"](a)() === v()); -} - -{ - const a = stream(0); - const f = (n: number) => n * 2; - const x = 3; - console.assert(a["fantasy-land/of"](x)["fantasy-land/ap"](a["fantasy-land/of"](f))() === 6); - console.assert(a["fantasy-land/of"](x)["fantasy-land/ap"](a["fantasy-land/of"](f))() === a["fantasy-land/of"](f(x))()); -} - -{ - const u = stream((n: number) => n * 2); - const a = stream(); - const y = 3; - console.assert(a["fantasy-land/of"](y)["fantasy-land/ap"](u)() === 6); - console.assert(a["fantasy-land/of"](y)["fantasy-land/ap"](u)() === u["fantasy-land/ap"](a["fantasy-land/of"]((f: any) => f(y)))()); -} - // scan { diff --git a/types/mithril/tsconfig.json b/types/mithril/tsconfig.json index 8189032c62..e25806a323 100644 --- a/types/mithril/tsconfig.json +++ b/types/mithril/tsconfig.json @@ -5,9 +5,8 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "suppressImplicitAnyIndexErrors": true, - "noEmit": true, "forceConsistentCasingInFileNames": true, + "noEmit": true, "baseUrl": "../", "typeRoots": ["../"], "types": [] diff --git a/types/mithril/tslint.json b/types/mithril/tslint.json index 9067ff24e6..47e22e1551 100644 --- a/types/mithril/tslint.json +++ b/types/mithril/tslint.json @@ -3,7 +3,6 @@ "rules": { // TODOs "no-duplicate-imports": false, - "object-literal-key-quotes": false, "no-empty-interface": false } }