Dependency Bug - @types/pino breaking typescript in consumers
See original GitHub issueSoftware 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
- Install the @pact-foundation/pact-core package into a project using typescript
- Run the
tsc
command
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:
- Created 10 months ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top GitHub Comments
@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.
Excellent, thanks!