types: massive refactor

This commit is contained in:
Evan You
2019-10-22 11:26:48 -04:00
parent 522beaa766
commit b5886189ba
21 changed files with 308 additions and 258 deletions

View File

@@ -15,7 +15,7 @@ import {
NOOP
} from '@vue/shared'
import { computed } from './apiReactivity'
import { watch, WatchOptions, CleanupRegistrator } from './apiWatch'
import { watch, WatchOptions, WatchHandler } from './apiWatch'
import { provide, inject } from './apiInject'
import {
onBeforeMount,
@@ -40,7 +40,7 @@ import { Directive } from './directives'
import { ComponentPublicInstance } from './componentProxy'
import { warn } from './warning'
interface ComponentOptionsBase<
export interface ComponentOptionsBase<
Props,
RawBindings,
D,
@@ -119,12 +119,6 @@ export type ExtractComputedReturns<T extends any> = {
: ReturnType<T[key]>
}
export type WatchHandler<T = any> = (
val: T,
oldVal: T,
onCleanup: CleanupRegistrator
) => any
type ComponentWatchOptions = Record<
string,
string | WatchHandler | { handler: WatchHandler } & WatchOptions
@@ -134,7 +128,7 @@ type ComponentInjectOptions =
| string[]
| Record<
string | symbol,
string | symbol | { from: string | symbol; default?: any }
string | symbol | { from: string | symbol; default?: unknown }
>
// TODO type inference for these options
@@ -294,12 +288,12 @@ export function applyOptions(
set: isFunction(set)
? set.bind(ctx)
: __DEV__
? () => {
warn(
`Computed property "${key}" was assigned to but it has no setter.`
)
}
: NOOP
? () => {
warn(
`Computed property "${key}" was assigned to but it has no setter.`
)
}
: NOOP
})
} else if (__DEV__) {
warn(`Computed property "${key}" has no getter.`)