Skip to content

Commit 41a8d67

Browse files
committed
Merge branch 'master' of github.com:vuejs/vue-function-api
2 parents 98e100a + 6e9abc4 commit 41a8d67

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

src/apis/watch.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ function createWatcher(
180180
flushMode
181181
);
182182

183-
// `shiftCallback` is used to handle firty sync effect.
184-
// The subsequent callbcks will redirect to `callback`.
183+
// `shiftCallback` is used to handle dirty sync effect.
184+
// The subsequent callbacks will redirect to `callback`.
185185
let shiftCallback = (n: any, o: any) => {
186186
shiftCallback = callback;
187187
applyCb(n, o);
@@ -214,14 +214,14 @@ export function watch(
214214
cb?: Partial<WatcherOption> | WatcherCallBack<any>,
215215
options?: Partial<WatcherOption>
216216
): StopHandle {
217-
let callbck: WatcherCallBack<unknown> | null = null;
217+
let callback: WatcherCallBack<unknown> | null = null;
218218
if (typeof cb === 'function') {
219219
// source watch
220-
callbck = cb as WatcherCallBack<unknown>;
220+
callback = cb as WatcherCallBack<unknown>;
221221
} else {
222222
// effect watch
223223
options = cb as Partial<WatcherOption>;
224-
callbck = null;
224+
callback = null;
225225
}
226226

227227
const opts: WatcherOption = {
@@ -242,5 +242,5 @@ export function watch(
242242
installWatchEnv(vm);
243243
}
244244

245-
return createWatcher(vm, source, callbck, opts);
245+
return createWatcher(vm, source, callback, opts);
246246
}

src/component/componentProps.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ export type PropType<T> = PropConstructor<T> | PropConstructor<T>[];
1717

1818
type PropConstructor<T> = { new (...args: any[]): T & object } | { (): T };
1919

20-
type RequiredKeys<T, MakeDefautRequired> = {
20+
type RequiredKeys<T, MakeDefaultRequired> = {
2121
[K in keyof T]: T[K] extends
2222
| { required: true }
23-
| (MakeDefautRequired extends true ? { default: any } : never)
23+
| (MakeDefaultRequired extends true ? { default: any } : never)
2424
? K
2525
: never;
2626
}[keyof T];
2727

28-
type OptionalKeys<T, MakeDefautRequired> = Exclude<keyof T, RequiredKeys<T, MakeDefautRequired>>;
28+
type OptionalKeys<T, MakeDefaultRequired> = Exclude<keyof T, RequiredKeys<T, MakeDefaultRequired>>;
2929

3030
// prettier-ignore
3131
type InferPropType<T> = T extends null
3232
? any // null & true would fail to infer
3333
: T extends { type: null }
34-
? any // somehow `ObjectContructor` when inferred from { (): T } becomes `any`
34+
? any // somehow `ObjectConstructor` when inferred from { (): T } becomes `any`
3535
: T extends ObjectConstructor | { type: ObjectConstructor }
3636
? { [key: string]: any }
3737
: T extends Prop<infer V>
3838
? V
3939
: T;
4040

4141
// prettier-ignore
42-
export type ExtractPropTypes<O, MakeDefautRequired extends boolean = true> = {
43-
readonly [K in RequiredKeys<O, MakeDefautRequired>]: InferPropType<O[K]>;
42+
export type ExtractPropTypes<O, MakeDefaultRequired extends boolean = true> = {
43+
readonly [K in RequiredKeys<O, MakeDefaultRequired>]: InferPropType<O[K]>;
4444
} & {
45-
readonly [K in OptionalKeys<O, MakeDefautRequired>]?: InferPropType<O[K]>;
45+
readonly [K in OptionalKeys<O, MakeDefaultRequired>]?: InferPropType<O[K]>;
4646
};

src/reactivity/reactive.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getCurrentVue } from '../runtimeContext';
33
import { isPlainObject, def, hasOwn, warn } from '../utils';
44
import { isComponentInstance, createComponentInstance } from '../helper';
55
import {
6-
AccessControIdentifierlKey,
6+
AccessControlIdentifierKey,
77
ReactiveIdentifierKey,
88
NonReactiveIdentifierKey,
99
RefKey,
@@ -40,14 +40,14 @@ function setupAccessControl(target: AnyObject): void {
4040
}
4141

4242
if (
43-
hasOwn(target, AccessControIdentifierlKey) &&
44-
target[AccessControIdentifierlKey] === AccessControlIdentifier
43+
hasOwn(target, AccessControlIdentifierKey) &&
44+
target[AccessControlIdentifierKey] === AccessControlIdentifier
4545
) {
4646
return;
4747
}
4848

4949
if (Object.isExtensible(target)) {
50-
def(target, AccessControIdentifierlKey, AccessControlIdentifier);
50+
def(target, AccessControlIdentifierKey, AccessControlIdentifier);
5151
}
5252
const keys = Object.keys(target);
5353
for (let i = 0; i < keys.length; i++) {
@@ -56,7 +56,7 @@ function setupAccessControl(target: AnyObject): void {
5656
}
5757

5858
/**
59-
* Auto unwrapping when acccess property
59+
* Auto unwrapping when access property
6060
*/
6161
export function defineAccessControl(target: AnyObject, key: any, val?: any) {
6262
if (key === '__ob__') return;
@@ -81,7 +81,7 @@ export function defineAccessControl(target: AnyObject, key: any, val?: any) {
8181
configurable: true,
8282
get: function getterHandler() {
8383
const value = getter ? getter.call(target) : val;
84-
// if the key is euqal to RefKey, skip the unwrap logic
84+
// if the key is equal to RefKey, skip the unwrap logic
8585
if (key !== RefKey && isRef(value)) {
8686
return value.value;
8787
} else {
@@ -92,7 +92,7 @@ export function defineAccessControl(target: AnyObject, key: any, val?: any) {
9292
if (getter && !setter) return;
9393

9494
const value = getter ? getter.call(target) : val;
95-
// If the key is euqal to RefKey, skip the unwrap logic
95+
// If the key is equal to RefKey, skip the unwrap logic
9696
// If and only if "value" is ref and "newVal" is not a ref,
9797
// the assignment should be proxied to "value" ref.
9898
if (key !== RefKey && isRef(value) && !isRef(newVal)) {
@@ -151,7 +151,7 @@ export function nonReactive<T = any>(obj: T): T {
151151
return obj;
152152
}
153153

154-
// set the vue obserable flag at obj
154+
// set the vue observable flag at obj
155155
(obj as any).__ob__ = (observe({}) as any).__ob__;
156156
// mark as nonReactive
157157
def(obj, NonReactiveIdentifierKey, NonReactiveIdentifier);

src/reactivity/ref.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function createRef<T>(options: RefOption<T>) {
100100

101101
type RefValue<T> = T extends Ref<infer V> ? V : UnwrapRef<T>;
102102

103-
// without init value, explict typed: a = ref<{ a: number }>()
103+
// without init value, explicit typed: a = ref<{ a: number }>()
104104
// typeof a will be Ref<{ a: number } | undefined>
105105
export function ref<T = undefined>(): Ref<T | undefined>;
106106
// with init value: a = ref({ a: ref(0) })
@@ -138,16 +138,16 @@ export function toRefs<T extends Data = Data>(obj: T): Refs<T> {
138138

139139
const res: Refs<T> = {} as any;
140140
Object.keys(obj).forEach(key => {
141-
let val = obj[key];
141+
let val: any = obj[key];
142142
// use ref to proxy the property
143143
if (!isRef(val)) {
144-
val = createRef({
144+
val = createRef<any>({
145145
get: () => obj[key],
146-
set: v => (obj[key as keyof T] = v as any),
146+
set: v => (obj[key as keyof T] = v),
147147
});
148148
}
149149
// todo
150-
res[key as keyof T] = val as any;
150+
res[key as keyof T] = val;
151151
});
152152

153153
return res;

src/setup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ function updateTemplateRef(vm: ComponentInstance) {
5151
}
5252

5353
const newKeys = Object.keys(refs);
54-
const validNewKyes = [];
54+
const validNewKeys = [];
5555
for (let index = 0; index < newKeys.length; index++) {
5656
const key = newKeys[index];
5757
const setupValue = rawBindings[key];
5858
if (refs[key] && setupValue && isRef(setupValue)) {
5959
setupValue.value = refs[key];
60-
validNewKyes.push(key);
60+
validNewKeys.push(key);
6161
}
6262
}
63-
vmStateManager.set(vm, 'refs', validNewKyes);
63+
vmStateManager.set(vm, 'refs', validNewKeys);
6464
}
6565

6666
function activateCurrentInstance(
@@ -124,7 +124,7 @@ export function mixin(Vue: VueConstructor) {
124124
}
125125

126126
const { data } = $options;
127-
// wapper the data option, so we can invoke setup before data get resolved
127+
// wrapper the data option, so we can invoke setup before data get resolved
128128
$options.data = function wrappedData() {
129129
initSetup(vm, vm.$props);
130130
return typeof data === 'function' ? data.call(vm, vm) : data || {};

src/symbols.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ function createSymbol(name: string): string {
66

77
export const WatcherPreFlushQueueKey = createSymbol('vfa.key.preFlushQueue');
88
export const WatcherPostFlushQueueKey = createSymbol('vfa.key.postFlushQueue');
9-
export const AccessControIdentifierlKey = createSymbol('vfa.key.accessControIdentifier');
10-
export const ReactiveIdentifierKey = createSymbol('vfa.key.reactiveleIdentifier');
11-
export const NonReactiveIdentifierKey = createSymbol('vfa.key.nonReactiveleIdentifier');
9+
export const AccessControlIdentifierKey = createSymbol('vfa.key.accessControlIdentifier');
10+
export const ReactiveIdentifierKey = createSymbol('vfa.key.reactiveIdentifier');
11+
export const NonReactiveIdentifierKey = createSymbol('vfa.key.nonReactiveIdentifier');
1212

1313
// must be a string, symbol key is ignored in reactive
1414
export const RefKey = 'vfa.key.refKey';

test/apis/watch.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('api/watch', () => {
3434
}).then(done);
3535
});
3636

37-
it('basic usage(value warpper)', done => {
37+
it('basic usage(value wrapper)', done => {
3838
const vm = new Vue({
3939
setup() {
4040
const a = ref(1);

test/setup.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('setup', () => {
9898
.then(done);
9999
});
100100

101-
it('should reveive props as first params', () => {
101+
it('should receive props as first params', () => {
102102
let props;
103103
new Vue({
104104
props: ['a'],
@@ -112,7 +112,7 @@ describe('setup', () => {
112112
expect(props.a).toBe(1);
113113
});
114114

115-
it('should reveive SetupContext second params', () => {
115+
it('should receive SetupContext second params', () => {
116116
let context;
117117
const vm = new Vue({
118118
setup(_, ctx) {
@@ -343,7 +343,7 @@ describe('setup', () => {
343343
});
344344

345345
it('inline render function should work', done => {
346-
// let createELement;
346+
// let createElement;
347347
const vm = new Vue({
348348
props: ['msg'],
349349
template: '<div>1</div>',

0 commit comments

Comments
 (0)