import { $NAME, MetaContext } from '../../MetaContext'; export const $INTERPOLATE = '$interpolate'; export type Interpolate = (from: T, to: T, progress: number) => T; export type $Interpolate = { [$INTERPOLATE]: Interpolate }; export type InterpolateNumber = { interpolateNumber(from: number, to: number, progress: number): number }; export const withInterpolate = MetaContext>(MetaContextBase: TMetaContextBase) => class extends MetaContextBase { [$INTERPOLATE](from: T, to: T, progress: number) { const $from = this.resolveValue(from); const $to = this.resolveValue(to); if ($from !== $to) throw new TypeError(`MetaContext.${$INTERPOLATE}(): type missmatch '${$from[$NAME]}' !== '${$to[$NAME]}'`); return $from[$INTERPOLATE](from, to, progress, this) as T; } };