style: @typescript-eslint/consistent-type-assertions

Fixes #564.
Fixes #565.
pull/569/head
Shahar Or (mightyiam) 5 years ago committed by Shahar Dawn Or
parent f38f49e985
commit ffc166cdb4

@ -8,7 +8,6 @@ module.exports = {
'import/newline-after-import': 'error',
'max-statements-per-line': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',

@ -6,8 +6,8 @@ export interface DOMAPI {
insertBefore: (parentNode: Node, newNode: Node, referenceNode: Node | null) => void
removeChild: (node: Node, child: Node) => void
appendChild: (node: Node, child: Node) => void
parentNode: (node: Node) => Node
nextSibling: (node: Node) => Node
parentNode: (node: Node) => Node | null
nextSibling: (node: Node) => Node | null
tagName: (elm: Element) => string
setTextContent: (node: Node, text: string | null) => void
getTextContent: (node: Node) => string | null
@ -76,7 +76,7 @@ function isComment (node: Node): node is Comment {
return node.nodeType === 8;
}
export const htmlDomApi = {
export const htmlDomApi: DOMAPI = {
createElement,
createElementNS,
createTextNode,
@ -92,6 +92,6 @@ export const htmlDomApi = {
isElement,
isText,
isComment,
} as DOMAPI;
};
export default htmlDomApi;

@ -61,5 +61,5 @@ function updateAttrs (oldVnode: VNode, vnode: VNode): void {
}
}
export const attributesModule = { create: updateAttrs, update: updateAttrs } as Module;
export const attributesModule: Module = { create: updateAttrs, update: updateAttrs };
export default attributesModule;

@ -28,5 +28,5 @@ function updateClass (oldVnode: VNode, vnode: VNode): void {
}
}
export const classModule = { create: updateClass, update: updateClass } as Module;
export const classModule: Module = { create: updateClass, update: updateClass };
export default classModule;

@ -39,5 +39,5 @@ function updateDataset (oldVnode: VNode, vnode: VNode): void {
}
}
export const datasetModule = { create: updateDataset, update: updateDataset } as Module;
export const datasetModule: Module = { create: updateDataset, update: updateDataset };
export default datasetModule;

@ -103,9 +103,9 @@ function updateEventListeners (oldVnode: VNode, vnode?: VNode): void {
}
}
export const eventListenersModule = {
export const eventListenersModule: Module = {
create: updateEventListeners,
update: updateEventListeners,
destroy: updateEventListeners
} as Module;
};
export default eventListenersModule;

@ -179,5 +179,5 @@ function post () {
removed = created = undefined;
}
export const heroModule = { pre, create, destroy, post } as Module;
export const heroModule: Module = { pre, create, destroy, post };
export default heroModule;

@ -1,10 +1,10 @@
import { PreHook, CreateHook, UpdateHook, DestroyHook, RemoveHook, PostHook } from '../hooks';
export interface Module {
export type Module = Partial<{
pre: PreHook
create: CreateHook
update: UpdateHook
destroy: DestroyHook
remove: RemoveHook
post: PostHook
}
}>;

@ -30,5 +30,5 @@ function updateProps (oldVnode: VNode, vnode: VNode): void {
}
}
export const propsModule = { create: updateProps, update: updateProps } as Module;
export const propsModule: Module = { create: updateProps, update: updateProps };
export default propsModule;

@ -30,8 +30,8 @@ function updateStyle (oldVnode: VNode, vnode: VNode): void {
if (!oldStyle && !style) return;
if (oldStyle === style) return;
oldStyle = oldStyle || {} as VNodeStyle;
style = style || {} as VNodeStyle;
oldStyle = oldStyle || {};
style = style || {};
var oldHasDel = 'delayed' in oldStyle;
for (name in oldStyle) {
@ -110,11 +110,11 @@ function forceReflow () {
reflowForced = false;
}
export const styleModule = {
export const styleModule: Module = {
pre: forceReflow,
create: updateStyle,
update: updateStyle,
destroy: applyDestroyStyle,
remove: applyRemoveStyle
} as Module;
};
export default styleModule;

@ -30,7 +30,7 @@ type ArraysOf<T> = {
[K in keyof T]: Array<T[K]>;
};
type ModuleHooks = ArraysOf<Module>;
type ModuleHooks = ArraysOf<Required<Module>>;
function createKeyToOldIdx (children: VNode[], beginIdx: number, endIdx: number): KeyToIndexMap {
const map: KeyToIndexMap = {};
@ -51,7 +51,14 @@ export { thunk } from './thunk';
export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
let i: number;
let j: number;
const cbs = ({} as ModuleHooks);
const cbs: ModuleHooks = {
create: [],
update: [],
remove: [],
destroy: [],
pre: [],
post: []
};
const api: DOMAPI = domApi !== undefined ? domApi : htmlDomApi;
@ -74,7 +81,7 @@ export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
function createRmCb (childElm: Node, listeners: number) {
return function rmCb () {
if (--listeners === 0) {
const parent = api.parentNode(childElm);
const parent = api.parentNode(childElm) as Node;
api.removeChild(parent, childElm);
}
};
@ -310,7 +317,7 @@ export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
patchVnode(oldVnode, vnode, insertedVnodeQueue);
} else {
elm = oldVnode.elm!;
parent = api.parentNode(elm);
parent = api.parentNode(elm) as Node;
createElm(vnode, insertedVnodeQueue);

Loading…
Cancel
Save