Edits to pass new linting rules

This commit is contained in:
spacejack
2019-01-01 17:51:48 -05:00
parent bf4288fc9c
commit 570db36e68
3 changed files with 11 additions and 11 deletions
+6 -6
View File
@@ -173,7 +173,7 @@ declare namespace Mithril {
type ChildArrayOrPrimitive = ChildArray | string | number | boolean;
/** Virtual DOM nodes, or vnodes, are Javascript objects that represent an element (or parts of the DOM). */
interface Vnode<Attrs = {}, State extends Lifecycle<Attrs, State> = Lifecycle<Attrs, State>> {
interface Vnode<Attrs = {}, State extends Lifecycle<Attrs, State> = {}> {
/** The nodeName of a DOM element. It may also be the string [ if a vnode is a fragment, # if it's a text vnode, or < if it's a trusted HTML vnode. Additionally, it may be a component. */
tag: string | ComponentTypes<Attrs, State>;
/** A hashmap of DOM attributes, events, properties and lifecycle methods. */
@@ -194,7 +194,7 @@ declare namespace Mithril {
// In some lifecycle methods, Vnode will have a dom property
// and possibly a domSize property.
interface VnodeDOM<Attrs = {}, State extends Lifecycle<Attrs, State> = Lifecycle<Attrs, State>> extends Vnode<Attrs, State> {
interface VnodeDOM<Attrs = {}, State extends Lifecycle<Attrs, State> = {}> extends Vnode<Attrs, State> {
/** Points to the element that corresponds to the vnode. */
dom: Element;
/** This defines the number of DOM elements that the vnode represents (starting from the element referenced by the dom property). */
@@ -210,7 +210,7 @@ declare namespace Mithril {
* Any Javascript object that has a view method can be used as a Mithril component.
* Components can be consumed via the m() utility.
*/
interface Component<Attrs = {}, State extends Lifecycle<Attrs, State> = Lifecycle<Attrs, State>> extends Lifecycle<Attrs, State> {
interface Component<Attrs = {}, State extends Lifecycle<Attrs, State> = {}> extends Lifecycle<Attrs, State> {
/** Creates a view out of virtual elements. */
view(this: State, vnode: Vnode<Attrs, State>): Children | null | void;
}
@@ -242,16 +242,16 @@ declare namespace Mithril {
* Any function that returns an object with a view method can be used as a Mithril component.
* Components can be consumed via the m() utility.
*/
type FactoryComponent<A = {}> = (vnode: Vnode<A, {}>) => Component<A, {}>;
type FactoryComponent<A = {}> = (vnode: Vnode<A>) => Component<A>;
/**
* Components are a mechanism to encapsulate parts of a view to make code easier to organize and/or reuse.
* Any Javascript object that has a view method is a Mithril component. Components can be consumed via the m() utility.
*/
type Comp<Attrs = {}, State extends Lifecycle<Attrs, State> = Lifecycle<Attrs, State>> = Component<Attrs, State> & State;
type Comp<Attrs = {}, State extends Lifecycle<Attrs, State> = {}> = Component<Attrs, State> & State;
/** Components are a mechanism to encapsulate parts of a view to make code easier to organize and/or reuse. Components can be consumed via the m() utility. */
type ComponentTypes<A = {}, S extends Lifecycle<A, S> = Lifecycle<A, S>> = Component<A, S> | { new (vnode: CVnode<A>): ClassComponent<A> } | FactoryComponent<A>;
type ComponentTypes<A = {}, S extends Lifecycle<A, S> = {}> = Component<A, S> | { new (vnode: CVnode<A>): ClassComponent<A> } | FactoryComponent<A>;
/** This represents the attributes available for configuring virtual elements, beyond the applicable DOM attributes. */
interface Attributes extends Lifecycle<any, any> {
+4 -4
View File
@@ -116,7 +116,7 @@ const FRAME_BUDGET = 100;
{
// define a component
const Greeter: m.Comp<{ style: string }, {}> = {
const Greeter: m.Comp<{ style: string }> = {
view(vnode) {
return m("div", vnode.attrs, ["Hello ", vnode.children]);
}
@@ -191,7 +191,7 @@ const FRAME_BUDGET = 100;
////////////////////////////////////////////////////////////////////////////////
{
const Fader: m.Comp<{}, {}> = {
const Fader: m.Comp = {
onbeforeremove(vnode) {
vnode.dom.classList.add("fade-out");
return new Promise(resolve => {
@@ -227,7 +227,7 @@ const FRAME_BUDGET = 100;
}
};
const Form: m.Comp<{term: string}, {}> = {
const Form: m.Comp<{term: string}> = {
oninit(vnode) {
state.term = vnode.attrs.term || ""; // populated from the `history.state` property if the user presses the back button
},
@@ -239,7 +239,7 @@ const FRAME_BUDGET = 100;
}
};
const Layout: m.Comp<{}, {}> = {
const Layout: m.Comp = {
view(vnode) {
return m(".layout", vnode.children);
}
+1 -1
View File
@@ -89,7 +89,7 @@ route(document.body, '/', {
test4: {
onmatch(args, path) {
// Must provide a Promise type if we want type checking
return new Promise<Component<{title: string}, {}>>((resolve, reject) => {
return new Promise<Component<{title: string}>>((resolve, reject) => {
resolve(component2);
});
}