javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Could not find a declaration file for module

Open rochapablo opened this issue 7 years ago • 11 comments

Describe the bug

Could not find a declaration file for module '@brazilian-utils/is-valid-cpf'. 'node_modules/@brazilian-utils/is-valid-cpf/dist/index.js' implicitly has an 'any' type.
  Try `npm install @types/brazilian-utils__is-valid-cpf` if it exists or add a new declaration (.d.ts) file containing `declare module '@brazilian-utils/is-valid-cpf';`ts(7016)

Same with

import isValidCnpj from '@brazilian-utils/is-valid-cnpj';
or
import { isValidCpf, isValidCnpj } from '@brazilian-utils/validators';

To Reproduce Steps to reproduce the behavior:

  1. npm install @brazilian-utils/is-valid-cpf --save
  2. import isValidCpf from '@brazilian-utils/is-valid-cpf';
  3. See error

Expected behavior It should import with no problem

rochapablo avatar Mar 28 '19 22:03 rochapablo

It seems there hasn't been a deploy since #38. I thought there would have been a types field in package.json pointing to a file that didn't exist, but the field itself is missing (https://unpkg.com/@brazilian-utils/is-valid-cnpj/package.json). Any idea of what happened? @hyanmandian @andreoav

vhfmag avatar Mar 29 '19 09:03 vhfmag

I really don't know what happened :( but @andreoav started to rewrite the architecture ( #36) and this problem probably will solve with that rewrite.

hyanmandian avatar Apr 03 '19 16:04 hyanmandian

try delete your node_modules folder and reinstall. to me worked normally. strange :/

pedroSoaresll avatar May 07 '19 23:05 pedroSoaresll

hmm if you are using with typescript, i don't know if this library have a @types, configure your tsconfig.json to allow pass libraries without @types defined

noImplicitAny

pedroSoaresll avatar May 07 '19 23:05 pedroSoaresll

we started working in refactoring of the entire project to solve issues like that, maybe in the next weeks we'll finish

hyanmandian avatar May 13 '19 12:05 hyanmandian

Hey @hyanmandian, how do you think to solve this problem?

pedroSoaresll avatar May 13 '19 12:05 pedroSoaresll

Just adding types property on package.json. Probably before I starting the refactoring of the entire project, I will publish a new version of each package with types

hyanmandian avatar May 14 '19 16:05 hyanmandian

Please make a common form to import, today is like this:

import { isValidCnpj } from '@brazilian-utils/is-valid-cnpj';
import { isValidCpf } from '@brazilian-utils/is-valid-cpf';
import isValidCep from '@brazilian-utils/is-valid-cep';
import isValidPhone from '@brazilian-utils/is-valid-phone';

ricardovf avatar Aug 27 '19 17:08 ricardovf

Thanks, @ricardovf. If you have free time and know how to fix, contributions are welcome. Right now we are trying to refactor the entire project but things are going slow :(

hyanmandian avatar Aug 27 '19 18:08 hyanmandian

Hey, we publish our first RC of the next version of our package today :D. Can you check if our typings are exported correctly?

https://www.npmjs.com/package/@brazilian-utils/brazilian-utils

hyanmandian avatar Jan 13 '20 17:01 hyanmandian

I did this example to show typings working in v1 version (current) https://codesandbox.io/s/brazilian-utils-typescript-example-6fhmt

hyanmandian avatar Jan 15 '20 12:01 hyanmandian