-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #891 from FelipeBit/felipebit-ptbr-translation
[PT-BR] noImplicityAny.md, noImplicityReturns.md, noImplicityThis.md and noImplicityUseStrict.md
- Loading branch information
Showing
5 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
packages/tsconfig-reference/copy/pt/options/noImplicitAny.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
display: "Sem 'Any' Implícito" | ||
oneline: "Evita introduzir 'anys' dentro de sua base de código quando um tipo puder ser especificado" | ||
--- | ||
|
||
Em alguns casos, onde nenhuma anotação de tipo está presente, o TypeScript retornará o tipo `any` para uma variável, quando não puder inferir o tipo. | ||
|
||
Isto pode fazer com que alguns erros sejam omitidos, por exemplo: | ||
|
||
```ts twoslash | ||
// @noImplicitAny: false | ||
function fn(s) { | ||
// Nenhum erro? | ||
console.log(s.subtr(3)); | ||
} | ||
fn(42); | ||
``` | ||
|
||
Ativando `noImplicitAny` no entanto, o TypeScript irá emitir um erro sempre que inferir `any`: | ||
|
||
```ts twoslash | ||
// @errors: 7006 | ||
function fn(s) { | ||
console.log(s.subtr(3)); | ||
} | ||
``` |
17 changes: 17 additions & 0 deletions
17
packages/tsconfig-reference/copy/pt/options/noImplicitReturns.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
display: "Sem Retornos Implícitos" | ||
oneline: "Garante que todos os caminhos de código de uma função tenham retorno" | ||
--- | ||
|
||
Quando habilitado, o TypeScript verificará todos os caminhos de código em uma função para garantir que eles retornem um valor. | ||
|
||
```ts twoslash | ||
// @errors: 2366 2322 | ||
function procurarFabricanteDeFonesDeOuvido(cor: "azul" | "preto"): string { | ||
if (cor === "azul") { | ||
return "beats"; | ||
} else { | ||
"bose"; | ||
} | ||
} | ||
``` |
27 changes: 27 additions & 0 deletions
27
packages/tsconfig-reference/copy/pt/options/noImplicitThis.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
display: "Sem 'This' Implícito" | ||
oneline: "Emite erro nas expressões 'this' com tipo 'any' implícito" | ||
--- | ||
|
||
Emite erro nas expressões 'this' com tipo 'any' implícito. | ||
|
||
Por exemplo, a classe abaixo retorna uma função que tenta acessar `this.largura` e `this.area` – mas o contexto para `this` dentro da função dentro de `funcaoObterArea` não é a instância de `Retangulo`. | ||
|
||
```ts twoslash | ||
// @errors: 2683 | ||
class Retangulo { | ||
largura: number; | ||
altura: number; | ||
|
||
constructor(largura: number, altura: number) { | ||
this.largura = largura; | ||
this.altura = altura; | ||
} | ||
|
||
funcaoObterArea() { | ||
return function () { | ||
return this.largura * this.altura; | ||
}; | ||
} | ||
} | ||
``` |
23 changes: 23 additions & 0 deletions
23
packages/tsconfig-reference/copy/pt/options/noImplicitUseStrict.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
display: "Sem 'Use Strict' Implícito" | ||
oneline: "Desabilita 'use strict' na emissão JS" | ||
--- | ||
|
||
Você não deveria precisar disso. Por padrão, ao emitir um arquivo de módulo para um destino não ES6, o TypeScript emite um prólogo `"use strict";` no topo do arquivo. | ||
Esta configuração desabilita o prólogo. | ||
|
||
```ts twoslash | ||
// @showEmit | ||
// @target: ES3 | ||
// @module: AMD | ||
// @noImplicitUseStrict | ||
// @alwaysStrict: false | ||
export function fn() {} | ||
``` | ||
|
||
```ts twoslash | ||
// @showEmit | ||
// @target: ES3 | ||
// @module: AMD | ||
export function fn() {} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters