chore: ts type
							parent
							
								
									6e6fd3af79
								
							
						
					
					
						commit
						f875b3add1
					
				|  | @ -11,9 +11,8 @@ export default defineComponent({ | |||
|     children: PropTypes.any.isRequired, | ||||
|     didUpdate: PropTypes.func, | ||||
|   }, | ||||
|   data() { | ||||
|   beforeCreate() { | ||||
|     this._container = null; | ||||
|     return {}; | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.createContainer(); | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| const isNumeric = value => { | ||||
| const isNumeric = (value: any): boolean => { | ||||
|   return !isNaN(parseFloat(value)) && isFinite(value); | ||||
| }; | ||||
| 
 | ||||
| export default isNumeric; | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { isVNode, Fragment, Comment, Text, h, VNode, ComponentPublicInstance } from 'vue'; | ||||
| import { isVNode, Fragment, Comment, Text, h, VNode, ComponentPublicInstance, Slots } from 'vue'; | ||||
| import isPlainObject from 'lodash-es/isPlainObject'; | ||||
| import { camelize, hyphenate, isOn, resolvePropValue } from './util'; | ||||
| import isValid from './isValid'; | ||||
|  | @ -148,6 +148,16 @@ const getOptionProps = (instance: ComponentPublicInstance) => { | |||
|   } | ||||
|   return res; | ||||
| }; | ||||
| 
 | ||||
| const getComponentFromSetup = ( | ||||
|   props: Record<string, unknown>, | ||||
|   slots: Slots, | ||||
|   name: string, | ||||
|   options?: unknown, | ||||
| ) => { | ||||
|   return props[name] ? props[name] : slots[name]?.(options); | ||||
| }; | ||||
| 
 | ||||
| const getComponent = ( | ||||
|   instance: ComponentPublicInstance, | ||||
|   prop: string = 'default', | ||||
|  | @ -403,5 +413,6 @@ export { | |||
|   getAllChildren, | ||||
|   findDOMNode, | ||||
|   flattenChildren, | ||||
|   getComponentFromSetup, | ||||
| }; | ||||
| export default hasProp; | ||||
|  |  | |||
|  | @ -1,10 +1,14 @@ | |||
| import raf from 'raf'; | ||||
| 
 | ||||
| let id = 0; | ||||
| const ids = {}; | ||||
| interface RafMap { | ||||
|   [id: number]: number; | ||||
| } | ||||
| 
 | ||||
| let id: number = 0; | ||||
| const ids: RafMap = {}; | ||||
| 
 | ||||
| // Support call raf with delay specified frame
 | ||||
| export default function wrapperRaf(callback, delayFrames = 1) { | ||||
| export default function wrapperRaf(callback: () => void, delayFrames: number = 1): number { | ||||
|   const myId = id++; | ||||
|   let restFrames = delayFrames; | ||||
| 
 | ||||
|  | @ -24,9 +28,10 @@ export default function wrapperRaf(callback, delayFrames = 1) { | |||
|   return myId; | ||||
| } | ||||
| 
 | ||||
| wrapperRaf.cancel = function(pid) { | ||||
| wrapperRaf.cancel = function(pid?: number) { | ||||
|   if (pid === undefined) return; | ||||
|   raf.cancel(ids[pid]); | ||||
|   delete ids[pid]; | ||||
| }; | ||||
| 
 | ||||
| wrapperRaf.ids = ids; // export this for test usage
 | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| const isStyleSupport = styleName => { | ||||
| const isStyleSupport = (styleName: string | string[]): boolean => { | ||||
|   if (typeof window !== 'undefined' && window.document && window.document.documentElement) { | ||||
|     const styleNameList = Array.isArray(styleName) ? styleName : [styleName]; | ||||
|     const { documentElement } = window.document; | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| export default function triggerEvent(el, type) { | ||||
| export default function triggerEvent(el: HTMLElement, type: string) { | ||||
|   if ('createEvent' in document) { | ||||
|     // modern browsers, IE9+
 | ||||
|     const e = document.createEvent('HTMLEvents'); | ||||
|  |  | |||
|  | @ -7,22 +7,22 @@ export const isObject = (val: unknown): val is object => val !== null && typeof | |||
| const onRE = /^on[^a-z]/; | ||||
| const isOn = (key: string) => onRE.test(key); | ||||
| 
 | ||||
| const cacheStringFunction = fn => { | ||||
| const cacheStringFunction = (fn: (str: string) => string) => { | ||||
|   const cache = Object.create(null); | ||||
|   return str => { | ||||
|   return (str: string) => { | ||||
|     const hit = cache[str]; | ||||
|     return hit || (cache[str] = fn(str)); | ||||
|   }; | ||||
| }; | ||||
| const camelizeRE = /-(\w)/g; | ||||
| const camelize = cacheStringFunction(str => { | ||||
| const camelize = cacheStringFunction((str: string) => { | ||||
|   return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); | ||||
| }); | ||||
| 
 | ||||
| const hyphenateRE = /\B([A-Z])/g; | ||||
| const hyphenate = cacheStringFunction((str: string) => { | ||||
|   return str.replace(hyphenateRE, '-$1').toLowerCase(); | ||||
| }); | ||||
| const hyphenate = cacheStringFunction((str: string) => | ||||
|   str.replace(hyphenateRE, '-$1').toLowerCase(), | ||||
| ); | ||||
| 
 | ||||
| const capitalize = cacheStringFunction((str: string) => { | ||||
|   return str.charAt(0).toUpperCase() + str.slice(1); | ||||
|  |  | |||
|  | @ -186,11 +186,11 @@ export const validateType = (type, value, silent = false) => { | |||
|   return valid; | ||||
| }; | ||||
| 
 | ||||
| let warn = noop; | ||||
| let warn: any = noop; | ||||
| 
 | ||||
| if (process.env.NODE_ENV !== 'production') { | ||||
|   const hasConsole = typeof console !== 'undefined'; | ||||
|   warn = msg => { | ||||
|   warn = (msg: string) => { | ||||
|     if (hasConsole) { | ||||
|       console.warn(`[VueTypes warn]: ${msg}`); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Amour1688
						Amour1688