-
Notifications
You must be signed in to change notification settings - Fork 130
[PT-BR] By Example.md and Do's and Dont's.md #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PT-BR] By Example.md and Do's and Dont's.md #72
Conversation
Thanks for the PR! This section of the codebase is owned by @khaosdoctor and @danilofuchs - if they write a comment saying "LGTM" then it will be merged. |
Translation of By Example.mdtitle: Declaration Reference oneline: "How to create a d.ts file for a module"The purpose of this guide is to teach you how to write a high-quality definition file. These examples are ordered in an approximate ascending order of complexity. Objects with Propertiesdocumentation
code let resultado = minhaLib.criaCumprimento("Olá, mundo");
console.log("O cumprimento computado é:" + resultado);
let count = minhaLib.numeroDeCumprimentos; statement Use declare namespace minhaLib {
function criaCumprimento(s: string): string;
let numeroDeCumprimentos: number;
} Overloaded Functionsdocumentation The function code let x: Ferramenta = pegaFerramenta(43);
let arr: Ferramenta[] = pegaFerramenta("todas"); statement declare function pegaFerramenta(n: number): Ferramenta;
declare function pegaFerramenta(s: string): Ferramenta[]; Reusable Types (Interfaces)documentation
code cumprimenta({
cumprimento: "olá mundo",
duracao: 4000
}); statement Use a interface ConfiguracoesCumprimento {
cumprimento: string;
duracao?: number;
cor?: string;
}
declare function cumprimenta(setting: ConfiguracoesSaudacao): void; Reusable types (Aliasetype)documentation
code function pegaCumprimento() {
return "oopa";
}
class MeuCumprimentador extends Cumprimentador {}
cumprimenta("olá");
cumprimenta(pegaCumprimento);
cumprimenta(new MeuCumprimentador()); statement You can use an alias to make an abbreviation for a type: type ComoUmCumprimentador = string | (() => string) | MeuCumprimentador;
declare function cumprimenta(g: ComoUmCumprimentador): void; Organizing Typesdocumentation
code const g = new Cumprimentador("Olá");
g.log({ verbose: true });
g.alert({ modal: false, title: "Cumprimento Atual" }); statement Use namespaces to organize types. declare namespace CumprimentoLib {
interface LogOptions {
verbose?: boolean;
}
interface AlertOptions {
modal: boolean;
title?: string;
color?: string;
}
} You can also create nested namespaces in a declaration: declare namespace CumprimentoLib.Options {
// Faz referência via CumprimentoLib.Options.Log
interface Log {
verbose?: boolean;
}
interface Alert {
modal: boolean;
title?: string;
color?: string;
}
} Classesdocumentation
code const MeuCumprimentador = new Cumprimentador("Olá, mundo");
MeuCumprimentador.cumprimento = "oopa";
MeuCumprimentador.mostraCumprimento();
class CumprimentadorEspecial extends Cumprimentador {
constructor() {
super("Cumprimentador muito especial");
}
} statement Use declare class Cumprimentador {
constructor(cumprimento: string);
cumprimento: string;
mostraCumprimento(): void;
} Global Variablesdocumentation
code console.log("Metade do numero de ferramentas é " + foo / 2); statement Use /** O numero de ferramentas atual */
declare var foo: number; Global Functionsdocumentation
code cumprimenta("olá, mundo"); statement Use declare function cumprimenta(cumprimento: string): void; Translation of Do's and Don'ts.mdtitle: Do's and Don'ts oneline: "Recommendations for writing d.ts files"General Types
|
I haven't forgotten this one, I'll review it shortly, sorry. I had some health issues |
LGTM |
There was an issue merging, maybe try again khaosdoctor. |
LGTM |
There was an issue merging, maybe try again khaosdoctor. |
@orta I think something is wrong with the bot |
bad bot |
This PR translates the following documentation to Brazilian Portuguese.
📝 Notes:
I have translated Do's and Dont's to
Sempre
eNunca
. I know that it may look weird, but reads more natural in Portuguese.Some exemples:
to
Ref: #1