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.

Dependency Bug - @types/pino breaking typescript in consumers

See original GitHub issue

Software versions

  • OS: Windows
  • pact-js-core version(s): Multiple. Testing with 13.12.0
  • Node Version: 16.16.0, 18.12.1
  • Other Versions:
    • Typescript Versions: 4.7.4, 4.8.4, probably others
    • @types/pino version: 6.3.11 <-- transitively pulled in through pact-core

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • (Not Applicable) I have triple checked, that there are no unhandled promises in my code
  • (Not Applicable) I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

The typescript compiler works in a project that has the @pact-foundation/pact-core package installed

Actual behaviour

The typescript compiler fails with: error TS2688: Cannot find type definition file for 'pino-std-serializers'

Steps to reproduce

Relevant log files

N/A

Additional Details

The problem is in separate typing libraries @types/pino + @types/pino-std-serializers that come through transitively.

NOTE: I’ve opened a separate issue here with them. It’s uncertain at this point if the maintainers plan to address the incorrect package format directly. https://github.com/pinojs/pino-std-serializers/issues/119

The pact-js-core library is referencing @types/pino with an explicit version of 6.3.11 https://github.com/pact-foundation/pact-js-core/blob/1d98a9b87ebea0c1646e5079108d3e755fa124ee/package.json#L56

This version is problematic because it has wildcard version references:

"@types/pino-pretty": "*"
"@types/pino-std-serializers": "*"

The wildcard @types/pino-std-serializers appears to be pulling in a new 4.0.0 version that is invalid (has no index.d.ts file) and thus breaking typescript functionality. If the maintainers put out an updated 4.0.1 version that is correct the problem will resolve. But if they do not put out a fixed package or if they are slow in doing so, consumers of pact-core will continue to encounter the problem.

An ideal long term solution would be for the pact-js-core library to update to the latest major pino version which ships with it’s type definitions built in and eliminate the @types/pino dependency all together.

In the short term I don’t think @types/pino needs to be a dependency, I believe it can be changed to a devDependency.

The only reason it would need to be a non dev dependency is if pact-core was re-exporting the pino types as part of the pact-core type definitions which does not appear to be the case.

Looking through the 13.12.0 package contents, for example, there is a pino.d.ts file in the package but it does not appear to be referenced by any of the exported type definitions and thus should be safe to change it to a devDependency` IMO.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RyanThomas73commented, Nov 28, 2022

@mefellows FYI - I was able to test this morning using the new pact-core v13.12.2 package that was released and confirmed that it solved the typing errors.

0reactions
mefellowscommented, Nov 28, 2022

Excellent, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing typings for previously existing libraries breaks ...
IMO, this change breaks semver and such updates should be released as ... Dependency Bug - @types/pino breaking typescript in consumers ...
Read more >
How to fix nasty circular dependency issues once and for all in ...
In this sandbox the from method has been pulled out the AbstractNode class and put into a separate file.
Read more >
Redwood v0.32 - Releases and Upgrade Guides
Rework and Cleanup Seed template for Typescript and multiple inserts ... this version is broke my auth, specifically my identity function.
Read more >
Understanding the dependency inversion principle in TypeScript
The first principle states that both high-level and low-level modules should depend on the same abstractions. If a module depends on an ...
Read more >
Node.js Agent version 3.x - Elastic
This is a technical preview to get feedback from Next.js users. The details on how exactly the instrumentation works may change in future...
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