diff --git a/flow/component.js b/flow/component.js index c2aa3944..4c9cb094 100644 --- a/flow/component.js +++ b/flow/component.js @@ -69,16 +69,34 @@ declare interface Component { _provided: ?Object; // private methods + // lifecycle _init: Function; _mount: (el?: Element | void, hydrating?: boolean) => Component; _update: (vnode: VNode, hydrating?: boolean) => void; + // rendering _render: () => VNode; - __patch__: (a: Element | VNode | void, b: VNode) => any; + + __patch__: ( + a: Element | VNode | void, + b: VNode, + hydrating?: boolean, + removeOnly?: boolean, + parentElm?: any, + refElm?: any + ) => any; + // createElement + // _c is internal that accepts `normalizationType` optimization hint - _c: (vnode?: VNode, data?: VNodeData, children?: VNodeChildren, normalizationType?: number) => VNode | void; + _c: ( + vnode?: VNode, + data?: VNodeData, + children?: VNodeChildren, + normalizationType?: number + ) => VNode | void; + // renderStatic _m: (index: number, isInFor?: boolean) => VNode | VNodeChildren; // markOnce diff --git a/flow/modules.js b/flow/modules.js index 49a0a098..a660e9c9 100644 --- a/flow/modules.js +++ b/flow/modules.js @@ -10,6 +10,7 @@ declare module 'source-map' { toString(): string; } declare class SourceMapConsumer { + constructor (map: Object): void; originalPositionFor(position: { line: number; column: number; }): { source: ?string; line: ?number; diff --git a/src/core/instance/render-helpers/render-list.js b/src/core/instance/render-helpers/render-list.js index 09ec4cdd..abe99db4 100644 --- a/src/core/instance/render-helpers/render-list.js +++ b/src/core/instance/render-helpers/render-list.js @@ -7,7 +7,11 @@ import { isObject, isDef } from 'core/util/index' */ export function renderList ( val: any, - render: () => VNode + render: ( + val: any, + keyOrIndex: string | number, + index?: number + ) => VNode ): ?Array { let ret: ?Array, i, l, keys, key if (Array.isArray(val) || typeof val === 'string') { diff --git a/src/core/observer/index.js b/src/core/observer/index.js index 4d503203..a71334f8 100644 --- a/src/core/observer/index.js +++ b/src/core/observer/index.js @@ -80,7 +80,7 @@ export class Observer { * Augment an target Object or Array by intercepting * the prototype chain using __proto__ */ -function protoAugment (target, src: Object) { +function protoAugment (target, src: Object, keys: any) { /* eslint-disable no-proto */ target.__proto__ = src /* eslint-enable no-proto */ diff --git a/src/server/bundle-renderer/create-bundle-renderer.js b/src/server/bundle-renderer/create-bundle-renderer.js index 64f1b6cf..3b6e2376 100644 --- a/src/server/bundle-renderer/create-bundle-renderer.js +++ b/src/server/bundle-renderer/create-bundle-renderer.js @@ -27,7 +27,9 @@ type RenderBundle = { modules?: { [filename: string]: Array }; }; -export function createBundleRendererCreator (createRenderer: () => Renderer) { +export function createBundleRendererCreator ( + createRenderer: (options?: RenderOptions) => Renderer +) { return function createBundleRenderer ( bundle: string | RenderBundle, rendererOptions?: RenderOptions = {} diff --git a/src/server/create-renderer.js b/src/server/create-renderer.js index 4997aa61..5e030098 100644 --- a/src/server/create-renderer.js +++ b/src/server/create-renderer.js @@ -18,7 +18,7 @@ type RenderCache = { }; export type RenderOptions = { - modules?: Array<(vnode: VNode) => string>; + modules?: Array<(vnode: VNode) => ?string>; directives?: Object; isUnaryTag?: Function; cache?: RenderCache; diff --git a/src/server/optimizing-compiler/codegen.js b/src/server/optimizing-compiler/codegen.js index 397e0c8e..4e0c6511 100644 --- a/src/server/optimizing-compiler/codegen.js +++ b/src/server/optimizing-compiler/codegen.js @@ -97,7 +97,7 @@ function genSSRChildren (el, state, checkSkip) { function genSSRNode (el, state) { return el.type === 1 ? genSSRElement(el, state) - : genText(el, state) + : genText(el) } function genChildrenAsStringNode (el, state) { diff --git a/src/server/optimizing-compiler/runtime-helpers.js b/src/server/optimizing-compiler/runtime-helpers.js index bbcb86e6..48f0828f 100644 --- a/src/server/optimizing-compiler/runtime-helpers.js +++ b/src/server/optimizing-compiler/runtime-helpers.js @@ -71,7 +71,14 @@ function renderStringNode ( return new StringNode(open, close, children, normalizationType) } -function renderStringList (val: any, render: () => string): string { +function renderStringList ( + val: any, + render: ( + val: any, + keyOrIndex: string | number, + index?: number + ) => string +): string { let ret = '' let i, l, keys, key if (Array.isArray(val) || typeof val === 'string') { diff --git a/src/server/render-context.js b/src/server/render-context.js index 4396f9c1..d75fdc8c 100644 --- a/src/server/render-context.js +++ b/src/server/render-context.js @@ -28,7 +28,7 @@ export class RenderContext { next: () => void; done: () => void; - modules: Array<() => ?string>; + modules: Array<(node: VNode) => ?string>; directives: Object; isUnaryTag: (tag: string) => boolean; diff --git a/src/server/render.js b/src/server/render.js index e3e192fa..872ae941 100644 --- a/src/server/render.js +++ b/src/server/render.js @@ -343,7 +343,7 @@ function renderStartingTag (node: VNode, context) { } export function createRenderFunction ( - modules: Array, + modules: Array<(node: VNode) => ?string>, directives: Object, isUnaryTag: Function, cache: any diff --git a/src/shared/util.js b/src/shared/util.js index bc9bf466..922bcd2b 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -202,13 +202,15 @@ export function toObject (arr: Array): Object { /** * Perform no operation. + * Stubbing args to make Flow happy without leaving useless transpiled code + * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) */ -export function noop () {} +export function noop (a?: any, b?: any, c?: any) {} /** * Always return false. */ -export const no = () => false +export const no = (a?: any, b?: any, c?: any) => false /** * Return same value