Skip to content
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

TypeScript #265

Open
feponiel opened this issue Feb 15, 2024 · 1 comment
Open

TypeScript #265

feponiel opened this issue Feb 15, 2024 · 1 comment

Comments

@feponiel
Copy link

feponiel commented Feb 15, 2024

Seria muito massa se vocês adicionassem suporte nativo ao TypeScript

@wellwelwel
Copy link
Contributor

Eaí @feponiel, 🙋🏻‍♂️

O que você diz por suporte nativo?
O cep-promise tem todas as declaração de tipos através do arquivo index.d.ts:

cep-promise/index.d.ts

Lines 1 to 78 in 43fbb00

declare module "cep-promise" {
/** Represents the result of a CEP search */
export interface CEP {
/** The retrieved CEP number */
cep: string;
/** The state associated with the CEP */
state: string;
/** The city associated with the CEP */
city: string;
/** The street associated with the CEP */
street: string;
/** The neighborhood associated with the CEP */
neighborhood: string;
/** The provider which returned the result */
service: string;
}
/**
* Available providers:
*
* | Provider | Browser | Node.js |
* | ------------ | ------- | ------- |
* | brasilapi | ✅ | ✅ |
* | viacep | ✅ | ✅ |
* | widenet | ✅ | ✅ |
* | correios | ❌ | ✅ |
* | correios-alt | ❌ | ✅ |
*/
export const AvailableProviders: {
/** Supported in both **Node.js** and **Browser** environments. */
readonly brasilapi: "brasilapi";
/** Supported in both **Node.js** and **Browser** environments. */
readonly viacep: "viacep";
/** Supported in both **Node.js** and **Browser** environments. */
readonly widenet: "widenet";
/** Supported only in **Node.js** environment. */
readonly correios: "correios";
/** Supported only in **Node.js** environment. */
readonly correiosAlt: "correios-alt";
};
/** Configuration options to customize the CEP search, by selecting specific providers and/or setting a timeout */
export interface Configurations {
/** Specifies the providers to be used for CEP searches, otherwise all available providers will be used.
*
* ---
*
* Available providers:
*
* | Provider | Browser | Node.js |
* | ------------ | ------- | ------- |
* | brasilapi | ✅ | ✅ |
* | viacep | ✅ | ✅ |
* | widenet | ✅ | ✅ |
* | correios | ❌ | ✅ |
* | correios-alt | ❌ | ✅ |
*/
providers?: (typeof AvailableProviders)[keyof typeof AvailableProviders][];
/** Timeout (in milliseconds) after which the CEP search will be cancelled. */
timeout?: number;
}
/**
* Searches for CEP directly integrated with the services of Correios, ViaCEP, and WideNet (Node.js and Browser).
*
* ---
*
* @param cep The CEP (postal code) to search for.
* @param configurations Optional configurations to customize the CEP search.
* @returns A promise that resolves with the CEP details.
*/
export function cep(
cep: string | number,
configurations?: Configurations
): Promise<CEP>;
export default cep;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants