Skip to content

Commit a3ca89f

Browse files
committedAug 23, 2023
fix: typo
1 parent 9966606 commit a3ca89f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎docs/operator.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ const greenComponent = palette.green.substring(1, 6); // 报错
665665

666666
如果要避免报错,要么精确给出变量`palette`每个属性的类型,要么对`palette.green`的值进行类型缩小。两种做法都比较麻烦,也不是很有必要。
667667

668-
这时就可以使用`statisfies`运算符,对`palette`进行类型检测,但是不改变 TypeScript 对`palette`的类型推断。
668+
这时就可以使用`satisfies`运算符,对`palette`进行类型检测,但是不改变 TypeScript 对`palette`的类型推断。
669669

670670
```typescript
671671
type Colors = "red" | "green" | "blue";
@@ -682,7 +682,7 @@ const greenComponent = palette.green.substring(1); // 不报错
682682

683683
上面示例中,变量`palette`的值后面增加了`satisfies Record<Colors, string|RGB>`,表示该值必须满足`Record<Colors, string|RGB>`这个条件,所以能够检测出属性名`bleu`的拼写错误。同时,它不会改变`palette`的类型推断,所以,TypeScript 知道`palette.green`是一个字符串,对其调用`substring()`方法就不会报错。
684684

685-
`statisfies`也可以检测属性值。
685+
`satisfies`也可以检测属性值。
686686

687687
```typescript
688688
const palette = {

0 commit comments

Comments
 (0)
Please sign in to comment.