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

tsc error: Could not find a declaration file for module 'nsql-cache' #223

Open
reedom opened this issue Mar 12, 2020 · 3 comments
Open

tsc error: Could not find a declaration file for module 'nsql-cache' #223

reedom opened this issue Mar 12, 2020 · 3 comments
Labels

Comments

@reedom
Copy link

reedom commented Mar 12, 2020

When I invoke tsc upon my project, I got the following error in node_modules/gstore-node/lib/index, due to lack of nsql-cache module's type definition.
How other people overcome this?

 error TS7016: Could not find a declaration file for module 'nsql-cache'. '/path/to/myproj/node_modules/nsql-cache/index.js' implicitly has an 'any' type.
  Try `npm install @types/nsql-cache` if it exists or add a new declaration (.d.ts) file containing `declare module 'nsql-cache';`

1 import NsqlCache, { NsqlCacheConfig } from 'nsql-cache';
                                             ~~~~~~~~~~~~

As workarounds, I could take the ways below, but I feel like none of them are best.
a. turn off strict flag in tsconfig.json
b. include sql-cache's type definition in gstore-node repository somehow

@sebelga
Copy link
Owner

sebelga commented May 9, 2020

Hi @reedom, sorry for the late answer!

Have you tried copying the declaration in your project from the repo: https://github.com/sebelga/gstore-node/blob/master/typings/nsql-cache/index.d.ts

Cheers! 👍

@reedom
Copy link
Author

reedom commented May 10, 2020

Yes, I had tried and then posted this issue, while wondering it was whether the expected solution or just a workaround, or even it was only me who face this kind of type-not-found error.

And my question hasn't changed ever since.

@sebelga
Copy link
Owner

sebelga commented May 19, 2020

Hello,

So indeed you need to copy the nsql-cache typing from this repo into yours.

I added a "typings" folder at the root with this folder structure

- typings
  - nsql-cache
    - index.d.ts

Then in you tsconfig.json file you need to add this folder

// tsconfig.json
{
  "compilerOptions": {
    ...
  },
  "include": [
    "src",
    "typings"
  ]
}

Let me know if it works for you.

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

No branches or pull requests

2 participants