question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move `@types` packages to `dependencies` from `devDependencies`

See original GitHub issue

Bug report

  • I have checked other issues to make sure this is not a duplicate.

Describe the bug

I have a following error after running tsc --noEmit:

error TS7016: Could not find a declaration file for module 'yup'

This should be fixed by moving all @types modules to dependencies, not devDependencies (I should not install type definitions for package that is not my dependency.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
maticzavcommented, Apr 9, 2019

Makes sense now. I will implement the fix by the end of the week.

If you have some spare time, I could merge a PR as soon as it lands.

1reaction
Pauloozecommented, Apr 9, 2019

Short answer is yes.

Files src/constructors.ts and src/rules.ts export stuff that uses yup types, therefore they (@types/yup) should be available to the consumer (installing them as production dependencies). Example:

export const inputRule = <T>(
  name: string | ((yup: typeof Yup) => Yup.Schema<T>),
  schema?: (yup: typeof Yup) => Yup.Schema<T>,
) => {
  if (typeof name === 'string') {
    return new InputRule(name, schema(Yup))
  } else {
    return new InputRule(Math.random().toString(), name(Yup))
  }
}

Now, let’s say I use inputRule inside my code. My typescript doesn’t know what Yup.schema<T> or typeof Yup means, because I don’t have @types/yup package installed (as I don’t directly use yup package). Hope this make sense. This is a longer answer, because you don’t use yup only during development, but also in the distributed package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Move @types dependencies to devDependencies #862 - GitHub
We need them in dependencies so that their installed into packages that depend on dom5 as a regular dependency.
Read more >
Move a module from devDependencies to ... - Stack Overflow
So, if you need to switch a dependency from devDependencies to dependecies you can go to your package.json and move manually with no...
Read more >
npm move package from devdependencies to dependencies Code ...
Answers related to “npm move package from devdependencies to dependencies”. difference between devDependency and dependency · npm remove dev dependencies ...
Read more >
Understanding and organizing dependencies in node packages
json in one of five dependency types: dependencies (default); devDependencies; peerDependencies; bundledDependencies; optionalDependencies.
Read more >
Managing dependencies - AWS Documentation
To update the installed modules, the preceding npm install and yarn upgrade commands can be used. Either command updates the packages in node_modules...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found