chore: fix typos (#103)

This commit is contained in:
Vladimir 2019-10-05 21:48:54 +07:00 committed by Evan You
parent ec8f7c6375
commit f48a2ffc76
10 changed files with 26 additions and 26 deletions

View File

@ -267,7 +267,7 @@ describe('compiler: transform', () => {
} }
} }
test('no chidlren', () => { test('no children', () => {
const ast = transformWithCodegen(``) const ast = transformWithCodegen(``)
expect(ast.codegenNode).toBeUndefined() expect(ast.codegenNode).toBeUndefined()
}) })

View File

@ -50,7 +50,7 @@ function parseWithElementTransform(
} }
describe('compiler: element transform', () => { describe('compiler: element transform', () => {
test('import + resovle component', () => { test('import + resolve component', () => {
const { root } = parseWithElementTransform(`<Foo/>`) const { root } = parseWithElementTransform(`<Foo/>`)
expect(root.imports).toContain(RESOLVE_COMPONENT) expect(root.imports).toContain(RESOLVE_COMPONENT)
expect(root.statements[0]).toMatch(`${RESOLVE_COMPONENT}("Foo")`) expect(root.statements[0]).toMatch(`${RESOLVE_COMPONENT}("Foo")`)
@ -575,7 +575,7 @@ describe('compiler: element transform', () => {
expect(node2.arguments.length).toBe(4) expect(node2.arguments.length).toBe(4)
expect(node2.arguments[3]).toBe(`${PatchFlags.TEXT} /* TEXT */`) expect(node2.arguments[3]).toBe(`${PatchFlags.TEXT} /* TEXT */`)
// multiple nodes, merged with optimze text // multiple nodes, merged with optimize text
const { node: node3 } = parseWithBind(`<div>foo {{ bar }} baz</div>`) const { node: node3 } = parseWithBind(`<div>foo {{ bar }} baz</div>`)
expect(node3.arguments.length).toBe(4) expect(node3.arguments.length).toBe(4)
expect(node3.arguments[3]).toBe(`${PatchFlags.TEXT} /* TEXT */`) expect(node3.arguments[3]).toBe(`${PatchFlags.TEXT} /* TEXT */`)

View File

@ -264,7 +264,7 @@ describe('reactivity/readonly', () => {
}) })
if (Collection === Map) { if (Collection === Map) {
test('should retrive readonly values on iteration', () => { test('should retrieve readonly values on iteration', () => {
const key1 = {} const key1 = {}
const key2 = {} const key2 = {}
const original = new Collection([[key1, {}], [key2, {}]]) const original = new Collection([[key1, {}], [key2, {}]])
@ -334,7 +334,7 @@ describe('reactivity/readonly', () => {
}) })
if (Collection === Set) { if (Collection === Set) {
test('should retrive readonly values on iteration', () => { test('should retrieve readonly values on iteration', () => {
const original = new Collection([{}, {}]) const original = new Collection([{}, {}])
const observed: any = readonly(original) const observed: any = readonly(original)
for (const value of observed) { for (const value of observed) {

View File

@ -13,7 +13,7 @@ import {
describe('error handling', () => { describe('error handling', () => {
mockWarn() mockWarn()
test('propagtaion', () => { test('propagation', () => {
const err = new Error('foo') const err = new Error('foo')
const fn = jest.fn() const fn = jest.fn()
@ -365,8 +365,8 @@ describe('error handling', () => {
const onError = jest.spyOn(console, 'error') const onError = jest.spyOn(console, 'error')
onError.mockImplementation(() => {}) onError.mockImplementation(() => {})
const groupCollpased = jest.spyOn(console, 'groupCollapsed') const groupCollapsed = jest.spyOn(console, 'groupCollapsed')
groupCollpased.mockImplementation(() => {}) groupCollapsed.mockImplementation(() => {})
const log = jest.spyOn(console, 'log') const log = jest.spyOn(console, 'log')
log.mockImplementation(() => {}) log.mockImplementation(() => {})
@ -397,7 +397,7 @@ describe('error handling', () => {
expect(onError).toHaveBeenCalledWith(err) expect(onError).toHaveBeenCalledWith(err)
onError.mockRestore() onError.mockRestore()
groupCollpased.mockRestore() groupCollapsed.mockRestore()
log.mockRestore() log.mockRestore()
process.env.NODE_ENV = 'test' process.env.NODE_ENV = 'test'
}) })

View File

@ -285,7 +285,7 @@ describe('renderer: suspense', () => {
expect(serializeInner(root)).toBe(`<div>fallback</div>`) expect(serializeInner(root)).toBe(`<div>fallback</div>`)
expect(calls).toEqual([]) expect(calls).toEqual([])
// remvoe the async dep before it's resolved // remove the async dep before it's resolved
toggle.value = false toggle.value = false
await nextTick() await nextTick()
// should cause the suspense to resolve immediately // should cause the suspense to resolve immediately

View File

@ -168,7 +168,7 @@ export interface LegacyOptions<
beforeUpdate?(): void beforeUpdate?(): void
updated?(): void updated?(): void
activated?(): void activated?(): void
decativated?(): void deactivated?(): void
beforeUnmount?(): void beforeUnmount?(): void
unmounted?(): void unmounted?(): void
renderTracked?(e: DebuggerEvent): void renderTracked?(e: DebuggerEvent): void
@ -206,7 +206,7 @@ export function applyOptions(
beforeUpdate, beforeUpdate,
updated, updated,
// TODO activated // TODO activated
// TODO decativated // TODO deactivated
beforeUnmount, beforeUnmount,
unmounted, unmounted,
renderTracked, renderTracked,

View File

@ -33,36 +33,36 @@ export type PropType<T> = PropConstructor<T> | PropConstructor<T>[]
type PropConstructor<T> = { new (...args: any[]): T & object } | { (): T } type PropConstructor<T> = { new (...args: any[]): T & object } | { (): T }
type RequiredKeys<T, MakeDefautRequired> = { type RequiredKeys<T, MakeDefaultRequired> = {
[K in keyof T]: T[K] extends [K in keyof T]: T[K] extends
| { required: true } | { required: true }
| (MakeDefautRequired extends true ? { default: any } : never) | (MakeDefaultRequired extends true ? { default: any } : never)
? K ? K
: never : never
}[keyof T] }[keyof T]
type OptionalKeys<T, MakeDefautRequired> = Exclude< type OptionalKeys<T, MakeDefaultRequired> = Exclude<
keyof T, keyof T,
RequiredKeys<T, MakeDefautRequired> RequiredKeys<T, MakeDefaultRequired>
> >
type InferPropType<T> = T extends null type InferPropType<T> = T extends null
? any // null & true would fail to infer ? any // null & true would fail to infer
: T extends { type: null | true } : T extends { type: null | true }
? any // somehow `ObjectContructor` when inferred from { (): T } becomes `any` ? any // somehow `ObjectConstructor` when inferred from { (): T } becomes `any`
: T extends ObjectConstructor | { type: ObjectConstructor } : T extends ObjectConstructor | { type: ObjectConstructor }
? { [key: string]: any } ? { [key: string]: any }
: T extends Prop<infer V> ? V : T : T extends Prop<infer V> ? V : T
export type ExtractPropTypes< export type ExtractPropTypes<
O, O,
MakeDefautRequired extends boolean = true MakeDefaultRequired extends boolean = true
> = O extends object > = O extends object
? { ? {
readonly [K in RequiredKeys<O, MakeDefautRequired>]: InferPropType<O[K]> readonly [K in RequiredKeys<O, MakeDefaultRequired>]: InferPropType<O[K]>
} & } &
{ {
readonly [K in OptionalKeys<O, MakeDefautRequired>]?: InferPropType< readonly [K in OptionalKeys<O, MakeDefaultRequired>]?: InferPropType<
O[K] O[K]
> >
} }

View File

@ -13,7 +13,7 @@ export function renderSlot(
name: string, name: string,
props: any = {}, props: any = {},
// this is not a user-facing function, so the fallback is always generated by // this is not a user-facing function, so the fallback is always generated by
// the compiler and gurunteed to be an array // the compiler and guaranteed to be an array
fallback?: VNodeChildren fallback?: VNodeChildren
): VNode { ): VNode {
const slot = slots[name] const slot = slots[name]

View File

@ -1,6 +1,6 @@
import { isArray, isPlainObject, objectToString } from '@vue/shared' import { isArray, isPlainObject, objectToString } from '@vue/shared'
// for conversting {{ interpolation }} values to displayed strings. // for converting {{ interpolation }} values to displayed strings.
export function toString(val: any): string { export function toString(val: any): string {
return val == null return val == null
? '' ? ''

View File

@ -65,14 +65,14 @@ function getComponentTrace(): ComponentTraceStack {
// we can't just use the stack because it will be incomplete during updates // we can't just use the stack because it will be incomplete during updates
// that did not start from the root. Re-construct the parent chain using // that did not start from the root. Re-construct the parent chain using
// instance parent pointers. // instance parent pointers.
const normalizeStack: ComponentTraceStack = [] const normalizedStack: ComponentTraceStack = []
while (currentVNode) { while (currentVNode) {
const last = normalizeStack[0] const last = normalizedStack[0]
if (last && last.vnode === currentVNode) { if (last && last.vnode === currentVNode) {
last.recurseCount++ last.recurseCount++
} else { } else {
normalizeStack.push({ normalizedStack.push({
vnode: currentVNode, vnode: currentVNode,
recurseCount: 0 recurseCount: 0
}) })
@ -82,7 +82,7 @@ function getComponentTrace(): ComponentTraceStack {
currentVNode = parentInstance && parentInstance.vnode currentVNode = parentInstance && parentInstance.vnode
} }
return normalizeStack return normalizedStack
} }
function formatTrace(trace: ComponentTraceStack): string[] { function formatTrace(trace: ComponentTraceStack): string[] {