types: improve types

This commit is contained in:
Evan You 2019-10-21 23:37:03 -04:00
parent bc0ec27739
commit a25b1371ab
2 changed files with 8 additions and 8 deletions

View File

@ -368,7 +368,7 @@ export function applyOptions(
function callSyncHook(
name: 'beforeCreate' | 'created',
options: ComponentOptions,
ctx: any,
ctx: ComponentPublicInstance,
globalMixins: ComponentOptions[]
) {
callHookFromMixins(name, globalMixins, ctx)
@ -389,7 +389,7 @@ function callSyncHook(
function callHookFromMixins(
name: 'beforeCreate' | 'created',
mixins: ComponentOptions[],
ctx: any
ctx: ComponentPublicInstance
) {
for (let i = 0; i < mixins.length; i++) {
const fn = mixins[i][name]

View File

@ -33,14 +33,14 @@ export const hasOwn = (
): key is keyof typeof val => hasOwnProperty.call(val, key)
export const isArray = Array.isArray
export const isFunction = (val: any): val is Function =>
export const isFunction = (val: unknown): val is Function =>
typeof val === 'function'
export const isString = (val: any): val is string => typeof val === 'string'
export const isSymbol = (val: any): val is symbol => typeof val === 'symbol'
export const isObject = (val: any): val is Record<any, any> =>
export const isString = (val: unknown): val is string => typeof val === 'string'
export const isSymbol = (val: unknown): val is symbol => typeof val === 'symbol'
export const isObject = (val: unknown): val is Record<any, any> =>
val !== null && typeof val === 'object'
export function isPromise<T = any>(val: any): val is Promise<T> {
export function isPromise<T = any>(val: unknown): val is Promise<T> {
return isObject(val) && isFunction(val.then) && isFunction(val.catch)
}
@ -48,7 +48,7 @@ export const objectToString = Object.prototype.toString
export const toTypeString = (value: unknown): string =>
objectToString.call(value)
export const isPlainObject = (val: any): val is object =>
export const isPlainObject = (val: unknown): val is object =>
toTypeString(val) === '[object Object]'
export const isReservedProp = (key: string): boolean =>