@@ -70,7 +70,7 @@ import { expectTypeOf } from 'vitest'
7070expectTypeOf ({ a: 1 , b: 2 }).toMatchObjectType <{ a: number }>() // preferred
7171expectTypeOf ({ a: 1 , b: 2 }).toExtend <{ a: number }>() // works but less strict
7272
73- // Supports nested object checking
73+ // 支持嵌套对象检查
7474const user = {
7575 name: ' John' ,
7676 address: { city: ' New York' , zip: ' 10001' }
@@ -102,11 +102,11 @@ function getResponsiveProp<T>(_props: T): ResponsiveProp<T> {
102102const cssProperties: CSSProperties = { margin: ' 1px' , padding: ' 2px' }
103103
104104expectTypeOf (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
108108expectTypeOf (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
136136expectTypeOf (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