Skip to content

Commit 462993c

Browse files
authored
Update options-api.md
同步英文文档此处关于 prop 注意事项的更新 vuejs/docs#1853
1 parent 2cbbf8f commit 462993c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/guide/typescript/options-api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default defineComponent({
6767

6868
### 注意事项 {#caveats}
6969

70-
因为一个 TypeScript [设计限制](https://github.com/microsoft/TypeScript/issues/38845),你在使用函数作为 prop 的 `validator``default` 选项值时需要格外小心——确保使用箭头函数:
70+
如果你的 TypeScript 版本低于 `4.7`,在使用函数作为 prop 的 `validator``default` 选项值时需要格外小心——确保使用箭头函数:
7171

7272
```ts
7373
import { defineComponent } from 'vue'
@@ -82,7 +82,7 @@ export default defineComponent({
8282
props: {
8383
bookA: {
8484
type: Object as PropType<Book>,
85-
// 确保使用箭头函数
85+
// 如果 TypeScript 版本低于 4.7,确保使用箭头函数
8686
default: () => ({
8787
title: 'Arrow Function Expression'
8888
}),
@@ -92,7 +92,7 @@ export default defineComponent({
9292
})
9393
```
9494

95-
这会防止 Typescript`this` 根据函数内的环境作出不符合我们期望的类型推导。
95+
这会防止 TypeScript`this` 根据函数内的环境作出不符合我们期望的类型推导。这是由于之前版本的一个 [设计限制](https://github.com/microsoft/TypeScript/issues/38845) 导致的,不过这个问题已经在 [TypeScript 4.7](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#improved-function-inference-in-objects-and-methods) 版本被解决了
9696

9797
## 为组件的 emit 标注类型 {#typing-component-emits}
9898

0 commit comments

Comments
 (0)