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.

@types/mysql should be in devDepenencies

See original GitHub issue

@types inclusion should be optional. Use case: in our project we share code for client and server, and server types conflict with client types. Consider setInterval, which has different return type on Node and DOM.

Also, I think that this is the convention for many libraries, since TypeScript in general is optional.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
move-zigcommented, Nov 13, 2017

There was a bit of a discussion about this on https://gitter.im/DefinitelyTyped/DefinitelyTyped from Nov 06 19:47 to Nov 07 08:23 (ET, I think). It seems like the consensus was a standard dependency, not devDependency. I think that makes sense.

1reaction
gamlielacommented, Nov 14, 2017

I understand the rationale for this change. Still, there is a reason why many libraries put it in devDependencies after all, and some of these reasons are given in the links you presented.

Here are my arguments:

  1. TypeScript is not mandatory. By putting types in the dependencies section you signal that the types are essential and required part of the project, which is not the case.

  2. It is easy to add @types for those who want it, but it is much harder to remove it for those who don’t want it (like me). For me, it involves to write a specific postinstall script to deal with this problem.

  3. There is a technical problem that affect (probably minority) of users. Some types are inferred incorrectly. See discussion at the end of this thread, and note that eventually they chose to put @types/node at devDependencies.

I will try to explain # 3 from our perspective. A variation of our problem is demonstrated also here.

We have sever code (Node) and client code (ES5) on the same project tree. Both share the same tsconfig file and both code parts get compiled together. Let’s put aside the question whether it’s a good setup or not; that’s the way we work now and I assume we are not the only ones that work this way. In our client code we have expressions like setTimeout(...). We actually mean window.setTimeout(...) (doc) and therefore expect to get a number type as result. But because of the inclusion of @types/node (as side effect of @types/mysql inclusion) the TypeScript compiler automatically picks the node version of setTimeout, which returns a Timer object instead of number. So we ends up with TS2323: Type 'Timer' is not assignable to type 'number' error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

types/mysql should be in devDepenencies · Issue #72 - GitHub
The idea is that @types dependencies should be installed when you install the package. When it was setup as just a devDep as...
Read more >
How do I decide whether @types/* goes into `dependencies ...
I would think that @types should be in devDependencies , as types are needed for development and aren't used in runtime, but I...
Read more >
How to decide whether @types/* goes into `dependencies` or ...
I would think that @types should be in devDependencies , as types are needed for development and aren't used in runtime, but I...
Read more >
Rust dev-dependencies and dependencies - TURRETA
We can use the command's -e ( --edges ) flag to choose which set of dependencies to list out. To display dev dependencies,...
Read more >
typescript-mysql-model - npm
Start using typescript-mysql-model in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type ...
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