Skip to content

Commit 3a081d9

Browse files
committed
docs: api/expect-typeof
1 parent 9988450 commit 3a081d9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

api/expect-typeof.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import { expectTypeOf } from 'vitest'
7070
expectTypeOf({ a: 1, b: 2 }).toMatchObjectType<{ a: number }>() // preferred
7171
expectTypeOf({ a: 1, b: 2 }).toExtend<{ a: number }>() // works but less strict
7272

73-
// Supports nested object checking
73+
// 支持嵌套对象检查
7474
const user = {
7575
name: 'John',
7676
address: { city: 'New York', zip: '10001' }
@@ -102,11 +102,11 @@ function getResponsiveProp<T>(_props: T): ResponsiveProp<T> {
102102
const cssProperties: CSSProperties = { margin: '1px', padding: '2px' }
103103

104104
expectTypeOf(getResponsiveProp(cssProperties))
105-
.extract<{ xs?: any }>() // extracts the last type from a union
105+
.extract<{ xs?: any }>() // 从联合类型中提取最后一个类型
106106
.toEqualTypeOf<{ xs?: CSSProperties, sm?: CSSProperties, md?: CSSProperties }>()
107107

108108
expectTypeOf(getResponsiveProp(cssProperties))
109-
.extract<unknown[]>() // extracts an array from a union
109+
.extract<unknown[]>() // 从联合类型中提取数组
110110
.toEqualTypeOf<CSSProperties[]>()
111111
```
112112

@@ -135,7 +135,7 @@ const cssProperties: CSSProperties = { margin: '1px', padding: '2px' }
135135

136136
expectTypeOf(getResponsiveProp(cssProperties))
137137
.exclude<unknown[]>()
138-
.exclude<{ xs?: unknown }>() // or just .exclude<unknown[] | { xs?: unknown }>()
138+
.exclude<{ xs?: unknown }>() // 或直接使用 .exclude<unknown[] | { xs?: unknown }>()
139139
.toEqualTypeOf<CSSProperties>()
140140
```
141141

0 commit comments

Comments
 (0)