mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-10 09:40:21 +08:00
Fix new --strictNullChecks errors from updated lib.dom (#27786)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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'))
|
||||
})
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
let $container: JQueryNotifyWidget = $("<div style='display:none' class='noprint'><div></div></div>").appendTo(document.body).notify();
|
||||
let $container: JQueryNotifyWidget = $("<div style='display:none' class='noprint'><div></div></div>").appendTo(document.body!).notify();
|
||||
|
||||
let notification: JQueryNotifyInstance = $container.notify(
|
||||
"create",
|
||||
|
||||
@@ -17,7 +17,7 @@ function test_executing_scripts1() {
|
||||
</body>`);
|
||||
|
||||
// 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() {
|
||||
</body>`, { 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 = "<p>Hello, world!</p>";`);
|
||||
window.document.body.children.length === 1;
|
||||
window.document.body!.children.length === 1;
|
||||
}
|
||||
|
||||
function test_virtualConsole() {
|
||||
@@ -74,7 +74,7 @@ function test_serialize() {
|
||||
dom.serialize() === '<!DOCTYPE html><html><head></head><body>hello</body></html>';
|
||||
|
||||
// Contrast with:
|
||||
dom.window.document.documentElement.outerHTML === '<html><head></head><body>hello</body></html>';
|
||||
dom.window.document.documentElement!.outerHTML === '<html><head></head><body>hello</body></html>';
|
||||
}
|
||||
|
||||
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')!;
|
||||
|
||||
@@ -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', {
|
||||
|
||||
@@ -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!);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class Comp4 implements ClassComponent<Comp4Attrs> {
|
||||
//
|
||||
// Test that all are mountable components
|
||||
//
|
||||
m.route(document.body, '/', {
|
||||
m.route(document.body!, '/', {
|
||||
'/comp0': Comp0,
|
||||
'/comp1': Comp1,
|
||||
'/comp2': Comp2,
|
||||
|
||||
@@ -148,7 +148,7 @@ function comp5(): Component<Comp4Attrs, Comp5State> {
|
||||
//
|
||||
// Test that all are mountable components
|
||||
//
|
||||
m.route(document.body, '/', {
|
||||
m.route(document.body!, '/', {
|
||||
'/comp0': comp0,
|
||||
'/comp1': comp1,
|
||||
'/comp2': comp2,
|
||||
|
||||
@@ -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')]
|
||||
]);
|
||||
|
||||
@@ -66,7 +66,7 @@ const routeResolver: RouteResolver<Attrs, RRState> & RRState = {
|
||||
}
|
||||
};
|
||||
|
||||
route(document.body, '/', {
|
||||
route(document.body!, '/', {
|
||||
'/': component1,
|
||||
'/test1': {
|
||||
onmatch(args, path) {
|
||||
|
||||
@@ -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!'));
|
||||
|
||||
@@ -31,7 +31,7 @@ client.add(magnetURI, {}, torrent => {
|
||||
a.href = url;
|
||||
}
|
||||
a.textContent = 'Download ' + file.name;
|
||||
document.body.appendChild(a);
|
||||
document.body!.appendChild(a);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ const balloonLayout = ymaps.templateLayoutFactory.createClass(
|
||||
{
|
||||
build(this: ymaps.ILayout): void {
|
||||
(<ymaps.layout.templateBased.Base> (<any> this.constructor).superclass).build.call(this);
|
||||
this.getParentElement().children.item(0).children.item(0).appendChild((<any> this.getData()).properties.get("balloonContent"));
|
||||
this.getParentElement().children.item(0)!.children.item(0)!.appendChild((<any> this.getData()).properties.get("balloonContent"));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user