diff --git a/types/cnpj/cnpj-tests.ts b/types/cnpj/cnpj-tests.ts new file mode 100644 index 0000000000..f43834cc3d --- /dev/null +++ b/types/cnpj/cnpj-tests.ts @@ -0,0 +1,5 @@ +import * as cnpj from 'cnpj'; + +const valid: boolean = cnpj.validate('38.981.218/0001-47'); +const formatted: string = cnpj.format(88415345000157); +const generated: string = cnpj.generate(); diff --git a/types/cnpj/index.d.ts b/types/cnpj/index.d.ts new file mode 100644 index 0000000000..de38629631 --- /dev/null +++ b/types/cnpj/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for cnpj 3.0 +// Project: https://github.com/gabrielizaias/cnpj +// Definitions by: Miguel A. Almeida +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Verifica validade do cnpj + * @param cnpj o CNPJ a ser validado. + * @returns Verdadeiro ou falso indicando a validade. + */ +export function validate(cnpj: string): boolean; + +/** + * Formata o cnpj com pontos e barra + * @param cnpj o CNPJ a ser formatado. + * @returns A string formatado. + */ +export function format(cnpj: number): string; + +/** + * Gera um cnpj aleatorio e valido + * @returns CNPJ gerado + */ +export function generate(): string; diff --git a/types/cnpj/tsconfig.json b/types/cnpj/tsconfig.json new file mode 100644 index 0000000000..0fadf50d00 --- /dev/null +++ b/types/cnpj/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cnpj-tests.ts" + ] +} \ No newline at end of file diff --git a/types/cnpj/tslint.json b/types/cnpj/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cnpj/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }