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

Cron type error when building in strict mode #140

Closed
Robfz opened this issue Apr 16, 2020 · 1 comment
Closed

Cron type error when building in strict mode #140

Robfz opened this issue Apr 16, 2020 · 1 comment

Comments

@Robfz
Copy link

Robfz commented Apr 16, 2020

I'm submitting a...


[ ] Regression 
[x ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When trying to build a project that uses @nestjs/schedule (either by running yarn build, nest build or yarn run tsc --build) and has strict: true set in tsconfig.json, a Typescript error halts the process:

node_modules/@nestjs/schedule/dist/scheduler.registry.d.ts:1:25 - error TS7016: Could not find a declaration file for module 'cron'. '/Users/roberto/Dev/nest/scheduler-bug/node_modules/cron/lib/cron.js' implicitly has an 'any' type.
  Try `npm install @types/cron` if it exists or add a new declaration (.d.ts) file containing `declare module 'cron';`

1 import { CronJob } from 'cron';
                          ~~~~~~

Found 1 error(s).

Expected behavior

Build should be able to finish without errors. A workaround is manually installing @types/cron, but as the user of the library I don't expect to install additional dependencies. A probable fix is to add @types/cron to the project dependencies (right now it is a dev dependency).

Minimal reproduction of the problem with instructions

Minimal reproduction repo

Just clone it and run yarn && yarn build.

What is the motivation / use case for changing the behavior?

Environment


Nest version: 7.0.7

 
For Tooling issues:
- Node version: v12.16.1
- Platform:  Mac

Others:

@kamilmysliwiec
Copy link
Member

A workaround is manually installing @types/cron, but as the user of the library I don't expect to install additional dependencies. A probable fix is to add @types/cron to the project dependencies (right now it is a dev dependency).

It's not a workaround. If you enable strict: true but don't enable skipLibCheck: true at the same time, you must install types. This is the desired behavior.

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