From 4598f49db1675a74a833bcf6e635e4d3a45db541 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 1 Aug 2018 16:50:36 -0700 Subject: [PATCH] Fix new --strictNullChecks errors from updated lib.dom (#27786) --- types/d3-dispatch/d3-dispatch-tests.ts | 8 ++++---- types/deku/deku-tests.ts | 8 ++++---- types/downloadjs/downloadjs-tests.ts | 2 +- .../i18next-browser-languagedetector-tests.ts | 2 +- types/jquery.notify/jquery.notify-tests.ts | 2 +- types/jsdom/jsdom-tests.ts | 10 +++++----- types/mark.js/mark.js-tests.ts | 2 +- types/marko/marko-tests.ts | 6 +++--- types/mithril/test/test-api.ts | 14 +++++++------- types/mithril/test/test-class-component.ts | 2 +- types/mithril/test/test-factory-component.ts | 2 +- types/mithril/test/test-misc.ts | 6 +++--- types/mithril/test/test-route.ts | 2 +- types/redom/redom-tests.ts | 8 ++++---- types/webtorrent/webtorrent-tests.ts | 2 +- types/yandex-maps/yandex-maps-tests.ts | 2 +- 16 files changed, 39 insertions(+), 39 deletions(-) diff --git a/types/d3-dispatch/d3-dispatch-tests.ts b/types/d3-dispatch/d3-dispatch-tests.ts index 4e8d2cfb31..b4f44ad4d2 100644 --- a/types/d3-dispatch/d3-dispatch-tests.ts +++ b/types/d3-dispatch/d3-dispatch-tests.ts @@ -47,12 +47,12 @@ undef = dispatch.on('unknown') as undefined; dispatch.on('bar', dispatch.on('bar')!); dispatch.call('foo'); -dispatch.call('foo', document.body); -dispatch.call('foo', document.body, { a: 3, b: 'test' }, 1); +dispatch.call('foo', document.body!); +dispatch.call('foo', document.body!, { a: 3, b: 'test' }, 1); dispatch.apply('bar'); -dispatch.apply('bar', document.body); -dispatch.apply('bar', document.body, [{ a: 3, b: 'test' }, 1]); +dispatch.apply('bar', document.body!); +dispatch.apply('bar', document.body!, [{ a: 3, b: 'test' }, 1]); dispatch.on('bar', null); diff --git a/types/deku/deku-tests.ts b/types/deku/deku-tests.ts index d123c7b8f7..d0467adead 100644 --- a/types/deku/deku-tests.ts +++ b/types/deku/deku-tests.ts @@ -24,7 +24,7 @@ }) } - let render = createApp(document.body) + let render = createApp(document.body!) function main(state: any){ let vnode = view(state, (action: any) => main({ count: 0 })) @@ -43,7 +43,7 @@ return element('div', { class: `size-${ props.size }` }) } - const render = createApp(document.body) + const render = createApp(document.body!) render(element(App, { size: 'small' })) @@ -82,11 +82,11 @@ (function (){ const { createApp, element } = deku - let render: Function = createApp(document.body) + let render: Function = createApp(document.body!) render(element('div')) - render = createApp(document.body, (action: any) => { + render = createApp(document.body!, (action: any) => { render(element('div')) }) diff --git a/types/downloadjs/downloadjs-tests.ts b/types/downloadjs/downloadjs-tests.ts index 00bb5395ef..da110af46d 100644 --- a/types/downloadjs/downloadjs-tests.ts +++ b/types/downloadjs/downloadjs-tests.ts @@ -7,6 +7,6 @@ download(new Blob(['hello world']), 'dlTextBlob.txt', 'text/plain'); download('/robots.txt'); -download(document.documentElement.outerHTML, 'dlHTML.html', 'text/html'); +download(document.documentElement!.outerHTML, 'dlHTML.html', 'text/html'); download(new Blob(['hello world'.bold()]), 'dlHtmlBlob.html', 'text/html'); download('/diff6.png'); diff --git a/types/i18next-browser-languagedetector/i18next-browser-languagedetector-tests.ts b/types/i18next-browser-languagedetector/i18next-browser-languagedetector-tests.ts index eadfcea369..174a871b9f 100644 --- a/types/i18next-browser-languagedetector/i18next-browser-languagedetector-tests.ts +++ b/types/i18next-browser-languagedetector/i18next-browser-languagedetector-tests.ts @@ -19,7 +19,7 @@ const options: LngDetector.DetectorOptions = { cookieDomain: "myDomain", // optional htmlTag with lang attribute, the default is: - htmlTag: document.documentElement + htmlTag: document.documentElement! }; i18next.use(LngDetector).init({ diff --git a/types/jquery.notify/jquery.notify-tests.ts b/types/jquery.notify/jquery.notify-tests.ts index 1af31996a1..1d872e92fa 100644 --- a/types/jquery.notify/jquery.notify-tests.ts +++ b/types/jquery.notify/jquery.notify-tests.ts @@ -1,4 +1,4 @@ -let $container: JQueryNotifyWidget = $("").appendTo(document.body).notify(); +let $container: JQueryNotifyWidget = $("").appendTo(document.body!).notify(); let notification: JQueryNotifyInstance = $container.notify( "create", diff --git a/types/jsdom/jsdom-tests.ts b/types/jsdom/jsdom-tests.ts index c672580a63..24b136e5ad 100644 --- a/types/jsdom/jsdom-tests.ts +++ b/types/jsdom/jsdom-tests.ts @@ -17,7 +17,7 @@ function test_executing_scripts1() { `); // The script will not be executed, by default: - dom.window.document.body.children.length === 1; + dom.window.document.body!.children.length === 1; } function test_executing_scripts2() { @@ -26,14 +26,14 @@ function test_executing_scripts2() { `, { runScripts: 'dangerously' }); // The script will be executed and modify the DOM: - dom.window.document.body.children.length === 2; + dom.window.document.body!.children.length === 2; } function test_executing_scripts3() { const window = (new JSDOM(``, { runScripts: 'outside-only' })).window; window.eval(`document.body.innerHTML = "

Hello, world!

";`); - window.document.body.children.length === 1; + window.document.body!.children.length === 1; } function test_virtualConsole() { @@ -74,7 +74,7 @@ function test_serialize() { dom.serialize() === 'hello'; // Contrast with: - dom.window.document.documentElement.outerHTML === 'hello'; + dom.window.document.documentElement!.outerHTML === 'hello'; } function test_nodeLocation() { @@ -86,7 +86,7 @@ function test_nodeLocation() { ); const document = dom.window.document; - const bodyEl = document.body; // implicitly created + const bodyEl = document.body!; // implicitly created const pEl = document.querySelector('p')!; const textNode = pEl.firstChild!; const imgEl = document.querySelector('img')!; diff --git a/types/mark.js/mark.js-tests.ts b/types/mark.js/mark.js-tests.ts index a979990521..2f4bb62d9a 100644 --- a/types/mark.js/mark.js-tests.ts +++ b/types/mark.js/mark.js-tests.ts @@ -3,7 +3,7 @@ import * as Mark from 'mark.js'; /* test instance */ const mark = new Mark(document.querySelectorAll('div')); const markBySelector = new Mark('div'); -const markByElement = new Mark(document.body); +const markByElement = new Mark(document.body!); mark.mark('keyword'); mark.mark('keyword', { diff --git a/types/marko/marko-tests.ts b/types/marko/marko-tests.ts index 623ad12e5f..e43f61d8b5 100644 --- a/types/marko/marko-tests.ts +++ b/types/marko/marko-tests.ts @@ -18,7 +18,7 @@ const template: Template = require('template.marko'); // $ExpectType RenderResult template .renderSync({ name: 'Marko' }) - .appendTo(document.body); + .appendTo(document.body!); createServer((req, res) => { res.setHeader('content-type', 'text/html'); @@ -30,12 +30,12 @@ const template: Template = require('template.marko'); .render({ $global: { flags: ['mobile'] } }) .then((result) => { // $ExpectType RenderResult - result.appendTo(document.body); + result.appendTo(document.body!); }); template.render({}, (err: Error | null, result: RenderResult) => { // $ExpectType RenderResult - result.appendTo(document.body); + result.appendTo(document.body!); }); }; diff --git a/types/mithril/test/test-api.ts b/types/mithril/test/test-api.ts index 73e03edeae..66c026f47d 100644 --- a/types/mithril/test/test-api.ts +++ b/types/mithril/test/test-api.ts @@ -142,7 +142,7 @@ const FRAME_BUDGET = 100; }); }; - m.render(document.body, userInputs(users)); + m.render(document.body!, userInputs(users)); } //////////////////////////////////////////////////////////////////////////////// @@ -246,7 +246,7 @@ const FRAME_BUDGET = 100; }; // example 1 - m.route(document.body, "/", { + m.route(document.body!, "/", { "/": { view() { return m(Layout, m(Home)); @@ -260,7 +260,7 @@ const FRAME_BUDGET = 100; }); // example 2 - m.route(document.body, "/", { + m.route(document.body!, "/", { "/": { render() { return m(Layout, m(Home)); @@ -285,7 +285,7 @@ const FRAME_BUDGET = 100; }, }; - m.route(document.body, "/", { + m.route(document.body!, "/", { "/": { render() { return m(Anon1); @@ -313,7 +313,7 @@ const FRAME_BUDGET = 100; } }; - m.route(document.body, "/user/list", { + m.route(document.body!, "/user/list", { "/user/list": { onmatch: state.loadUsers, render() { @@ -330,7 +330,7 @@ const FRAME_BUDGET = 100; { let progress = 0; - m.mount(document.body, { + m.mount(document.body!, { view() { return [ m("input[type=file]", { onchange: upload }), @@ -396,7 +396,7 @@ const FRAME_BUDGET = 100; deserialize: value => value }) .then(svg => { - m.render(document.body, m.trust(svg)); + m.render(document.body!, m.trust(svg)); }); } diff --git a/types/mithril/test/test-class-component.ts b/types/mithril/test/test-class-component.ts index 0b70773c9e..44c81a8b56 100644 --- a/types/mithril/test/test-class-component.ts +++ b/types/mithril/test/test-class-component.ts @@ -112,7 +112,7 @@ class Comp4 implements ClassComponent { // // Test that all are mountable components // -m.route(document.body, '/', { +m.route(document.body!, '/', { '/comp0': Comp0, '/comp1': Comp1, '/comp2': Comp2, diff --git a/types/mithril/test/test-factory-component.ts b/types/mithril/test/test-factory-component.ts index 6d0102fe38..b53619fbf1 100644 --- a/types/mithril/test/test-factory-component.ts +++ b/types/mithril/test/test-factory-component.ts @@ -148,7 +148,7 @@ function comp5(): Component { // // Test that all are mountable components // -m.route(document.body, '/', { +m.route(document.body!, '/', { '/comp0': comp0, '/comp1': comp1, '/comp2': comp2, diff --git a/types/mithril/test/test-misc.ts b/types/mithril/test/test-misc.ts index 3f377fec60..548811247d 100644 --- a/types/mithril/test/test-misc.ts +++ b/types/mithril/test/test-misc.ts @@ -10,9 +10,9 @@ const params = parseQueryString('?id=123'); const qstr = buildQueryString({id: 123}); -render(document.body, 'Hello'); -render(document.body, h('h1', 'Test')); -render(document.body, [ +render(document.body!, 'Hello'); +render(document.body!, h('h1', 'Test')); +render(document.body!, [ h('h1', 'Test'), "abc", null, 123, false, h('p', 'Vnode array'), ['a', 123, undefined, h('div', 'Nested')] ]); diff --git a/types/mithril/test/test-route.ts b/types/mithril/test/test-route.ts index 7f82c9fa40..63f10e510e 100644 --- a/types/mithril/test/test-route.ts +++ b/types/mithril/test/test-route.ts @@ -66,7 +66,7 @@ const routeResolver: RouteResolver & RRState = { } }; -route(document.body, '/', { +route(document.body!, '/', { '/': component1, '/test1': { onmatch(args, path) { diff --git a/types/redom/redom-tests.ts b/types/redom/redom-tests.ts index 0ec18f6a59..83eb899c65 100644 --- a/types/redom/redom-tests.ts +++ b/types/redom/redom-tests.ts @@ -4,13 +4,13 @@ const el1: HTMLElement = redom.el(''); const el2: HTMLElement = redom.el('p', 'Hello, World!', (el: HTMLElement) => { el.setAttribute('ok', '!'); }); const el3: HTMLElement = redom.html('p', 2, { color: 'red' }); -redom.mount(document.body, el1); -redom.mount(document.body, el2, el1); -redom.unmount(document.body, el1); +redom.mount(document.body!, el1); +redom.mount(document.body!, el2, el1); +redom.unmount(document.body!, el1); redom.setAttr(el3, 'ok', '!'); redom.setAttr(el3, { ok: '!' }); redom.setStyle(el3, { color: 'blue' }); redom.setChildren(el1, [el2, el3]); -redom.mount(document.body, redom.text('Hello, World!')); +redom.mount(document.body!, redom.text('Hello, World!')); diff --git a/types/webtorrent/webtorrent-tests.ts b/types/webtorrent/webtorrent-tests.ts index 63a9647902..d8ffba389d 100644 --- a/types/webtorrent/webtorrent-tests.ts +++ b/types/webtorrent/webtorrent-tests.ts @@ -31,7 +31,7 @@ client.add(magnetURI, {}, torrent => { a.href = url; } a.textContent = 'Download ' + file.name; - document.body.appendChild(a); + document.body!.appendChild(a); }); }); diff --git a/types/yandex-maps/yandex-maps-tests.ts b/types/yandex-maps/yandex-maps-tests.ts index 5c52936813..2406ef6cd6 100644 --- a/types/yandex-maps/yandex-maps-tests.ts +++ b/types/yandex-maps/yandex-maps-tests.ts @@ -23,7 +23,7 @@ const balloonLayout = ymaps.templateLayoutFactory.createClass( { build(this: ymaps.ILayout): void { ( ( this.constructor).superclass).build.call(this); - this.getParentElement().children.item(0).children.item(0).appendChild(( this.getData()).properties.get("balloonContent")); + this.getParentElement().children.item(0)!.children.item(0)!.appendChild(( this.getData()).properties.get("balloonContent")); } } );