Skip to content

Commit 2e22f20

Browse files
committed
Fix english at guide/typescript-support
1 parent 2607e3f commit 2e22f20

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/guide/typescript-support.md

+18-18
Original file line numberDiff line numberDiff line change
@@ -153,30 +153,30 @@ const Component = defineComponent({
153153
})
154154
```
155155

156-
### Augmenting Types for `globalProperties`
156+
### Ampliando Tipos para `globalProperties`
157157

158-
Vue 3 provides a [`globalProperties` object](../api/application-config.html#globalproperties) that can be used to add a global property that can be accessed in any component instance. For example, a [plugin](./plugins.html#writing-a-plugin) might want to inject a shared global object or function.
158+
O Vue 3 fornece um [objeto `globalProperties`](../api/application-config.html#globalproperties) que pode ser usado para adicionar uma propriedade global que pode ser acessada em qualquer instância do componente. Por exemplo, um [plugin](./plugins.html#escrevendo-um-plugin) pode querer injetar um objeto ou função global compartilhado.
159159

160160
```ts
161-
// User Definition
161+
// Definição do Usuário
162162
import axios from 'axios'
163163

164164
const app = Vue.createApp({})
165165
app.config.globalProperties.$http = axios
166166

167-
// Plugin for validating some data
167+
// Plugin para validar alguns dados
168168
export default {
169169
install(app, options) {
170170
app.config.globalProperties.$validate = (data: object, rule: object) => {
171-
// check whether the object meets certain rules
171+
// verifica se o objeto atende a certas regras
172172
}
173173
}
174174
}
175175
```
176176

177-
In order to tell TypeScript about these new properties, we can use [module augmentation](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation).
177+
Para informar o TypeScript sobre essas novas propriedades, podemos usar [aumento de módulos](https://www.typescriptlang.org/pt/docs/handbook/declaration-merging.html#aumento-de-m%C3%B3dulos).
178178

179-
In the above example, we could add the following type declaration:
179+
No exemplo acima, poderíamos adicionar a seguinte declaração de tipo:
180180

181181
```ts
182182
import axios from 'axios'
@@ -189,15 +189,15 @@ declare module '@vue/runtime-core' {
189189
}
190190
```
191191

192-
We can put this type declaration in the same file, or in a project-wide `*.d.ts` file (for example, in the `src/typings` folder that is automatically loaded by TypeScript). For library/plugin authors, this file should be specified in the `types` property in `package.json`.
192+
Podemos colocar esta declaração de tipo no mesmo arquivo, ou em um arquivo `*.d.ts` acessível por todo o projeto (por exemplo, na pasta `src/typings` que é carregada automaticamente pelo TypeScript). Para autores de biblioteca/plugin, este arquivo deve ser especificado na propriedade `types` em `package.json`.
193193

194-
::: warning Make sure the declaration file is a TypeScript module
195-
In order to take advantage of module augmentation, you will need to ensure there is at least one top-level `import` or `export` in your file, even if it is just `export {}`.
194+
::: warning Verifique se o arquivo de declaração é um módulo TypeScript
195+
Para aproveitar o aumento do módulo, você precisará garantir que haja pelo menos um `import` ou `export` de nível superior em seu arquivo, mesmo que seja apenas `export {}`.
196196

197-
[In TypeScript](https://www.typescriptlang.org/docs/handbook/modules.html), any file containing a top-level `import` or `export` is considered a 'module'. If type declaration is made outside of a module, it will overwrite the original types rather than augmenting them.
197+
[No TypeScript](https://www.typescriptlang.org/pt/docs/handbook/modules.html), qualquer arquivo que contenha um `import` ou `export` de nível superior é considerado um 'módulo'. Se a declaração de tipo for feita fora de um módulo, ela substituirá os tipos originais em vez de aumentá-los.
198198
:::
199199

200-
For more information about the `ComponentCustomProperties` type, see its [definition in `@vue/runtime-core`](https://github.com/vuejs/vue-next/blob/2587f36fe311359e2e34f40e8e47d2eebfab7f42/packages/runtime-core/src/componentOptions.ts#L64-L80) and [the TypeScript unit tests](https://github.com/vuejs/vue-next/blob/master/test-dts/componentTypeExtensions.test-d.tsx) to learn more.
200+
Para obter mais informações sobre o tipo `ComponentCustomProperties`, consulte sua [definição em `@vue/runtime-core`](https://github.com/vuejs/vue-next/blob/2587f36fe311359e2e34f40e8e47d2eebfab7f42/packages/runtime-core/src/componentOptions.ts#L64-L80) e [os testes de unidade do TypeScript](https://github.com/vuejs/vue-next/blob/master/test-dts/componentTypeExtensions.test-d.tsx) para saber mais .
201201

202202
### Anotando Tipos de Retorno
203203

@@ -376,9 +376,9 @@ year.value = 2020 // ok!
376376
Se o tipo do genérico é desconhecido, é recomendado converter `ref` para `Ref<T>`.
377377
:::
378378

379-
### Typing Template Refs
379+
### Tipando Refs de _Template_
380380

381-
Sometimes you might need to annotate a template ref for a child component in order to call its public method. For example, we have a `MyModal` child component with a method that opens the modal:
381+
Às vezes você pode precisar anotar um ref de _template_ para um componente filho para poder chamar seu método público. Por exemplo, temos um componente filho `MyModal` com um método que abre o modal:
382382

383383
```ts
384384
import { defineComponent, ref } from 'vue'
@@ -396,7 +396,7 @@ const MyModal = defineComponent({
396396
})
397397
```
398398

399-
We want to call this method via a template ref from the parent component:
399+
Queremos chamar esse método por meio de um ref de _template_ do componente pai:
400400

401401
```ts
402402
import { defineComponent, ref } from 'vue'
@@ -418,7 +418,7 @@ const app = defineComponent({
418418
MyModal
419419
},
420420
template: `
421-
<button @click="openModal">Open from parent</button>
421+
<button @click="openModal">Abrir pelo pai</button>
422422
<my-modal ref="modal" />
423423
`,
424424
setup() {
@@ -432,7 +432,7 @@ const app = defineComponent({
432432
})
433433
```
434434

435-
While this will work, there is no type information about `MyModal` and its available methods. To fix this, you should use `InstanceType` when creating a ref:
435+
Embora isso funcione, não há informações de tipo sobre `MyModal` e seus métodos disponíveis. Para corrigir isso, você deve usar `InstanceType` ao criar uma ref:
436436

437437
```ts
438438
setup() {
@@ -445,7 +445,7 @@ setup() {
445445
}
446446
```
447447

448-
Please note that you would also need to use [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) or any other way to check that `modal.value` is not undefined.
448+
Observe que você também precisaria usar [encadeamento opcional](https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Operators/Optional_chaining) ou qualquer outra maneira de verificar que `modal.value` não é `undefined`.
449449

450450
### Tipando `reactive`
451451

0 commit comments

Comments
 (0)