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.

Ink v3 contains `@types` packages as dependencies

See original GitHub issue

Currently the package.json for v3 contains @types/ packages as dependencies:

https://github.com/vadimdemedes/ink/blob/9ebfe314e865506ccb37b48723a27485346d950b/package.json#L41-L51

These should be listed as devDependencies 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
G-Rathcommented, Jul 5, 2020

Sure! It’s primarily for the same reasons that other dependencies are listed as devDependencies: they’re not required by the library at runtime.

In theory none of these packages ever need to be listed as dependencies, but sometimes a library will use types from one or more of the packages in their typed API so those packages are sometimes included as dependencies. In that case, the definitions should usually be included using a looser version, depending on the type in question.

The other way you can do this is like what you’ve done with @types/react: mark the package as optional using peerDependenciesMeta.

Theres pros and cons to these two methods: the first (using dependencies) means that everyone will always get the @types packages that are required for TypeScript users to use your libraries types regardless of if they’re using TypeScript or not; the second (using peerDependenciesMeta) means that the users typically have to manually include the @types/ packages themselves if they’re using TypeScript.

Looking over the codebase, I believe the only @types that should be in dependencies is @types/react-reconciler.

Constraint wise, typically '*' is recommended as mixing type versions can be messy, and it’s usually easier to resolve problems with 1 package than with 2. The type packages are also not always 1:1 with the libraries they’re typing in terms of major versions, so using '*' saves you from having to manage the overhead of doing i.e 24 | 28 | 29 as your constraint, nor will you have to make new releases updating those constraints because a new version of the @types was released & people are getting dependency warnings.

You should also always use '*' as the constraint for @types/node (if it’s in dependencies, which it rarely needs to be), as it’s the one dependency you can’t actually control, and having two versions of it in your dependency tree can lead to some very confusing errors.

Hope that helps clarify things - let me know if you’ve got more questions! 😄

0reactions
vadimdemedescommented, Jul 22, 2020

Landed in 3.0.0-7.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@types/ink - npm
Stub TypeScript definitions entry for ink, which provides its own types definitions. Latest version: 2.0.3, last published: 3 years ago.
Read more >
Advanced guide to Ink v3.2.0 (w/ React, Node.js and TypeScript)
You can take a look at the dependencies that Ink has in its package.json . It relies on packages like: chalk , cli-boxes...
Read more >
@types/ink-table | Yarn - Package Manager
Fast, reliable, and secure dependency management. ... DefinitelyTyped189MIT1.0.3TS ... This package contains type definitions for ink-table ...
Read more >
Bundled scoped dependencies breaks npm 3 · Issue #572 · tapjs ...
Release 14.2.3 bundled treport and ink which in turn have some dependencies that are scoped packages. Unfortunately, this combination breaks npm install ...
Read more >
How do I decide whether @types/* goes into `dependencies ...
Let's say you're developing a package "A" that have @types/some-module package in devDependencies . For some reason you're exporting the ...
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