-
Notifications
You must be signed in to change notification settings - Fork 888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New bundled TypeScript typings do not expose various top-level exports #1193
Comments
Would you be open to send a PR that would address this? |
Not sure if removing namespace is feasible without it being a breaking change, though. |
@pinojs/typescript I assume our next window for any breaking changes is pino 8? |
It might be feasible to have all the type/interface exports as top-level, and keep the namespace bundle for legacy support until the next breaking release. I'll take a quick look now. |
My "quick look" was not so quick. I have a version that works exactly as I want it to, but only with |
OK, I think I have it working in https://github.com/thw0rted/pino/tree/issue-1193 Does someone want to look over my approach first, or should I just open a PR? |
go open a PR, it's easy to review |
If types are invalid it should be considered a bug and fixed with an appropriate |
@Ethan-Arrowood There are two parts to this issue. I would see adding missing exports as a bug and it can be addressed in a patch release. Adding namespace-less exports on top of existing ones are closer to semver minor in my book. Removing namespace altogether would definitely be a semver major. |
In the linked PR, I think you could ship what I wrote as patch or minor, then remove the final |
FTR I found this thread because I'm upgrading a project's dependencies and tsc complains about non-existing Logger type, whereas it worked before. |
I stumbled over the same lost exported top-level Logger type when upgrading to the new version. I agree it should be a patch, as adding another top-level export does not mean the export within the namespace P needs to be dropped. It - for sure - becomes redundant, but won't be breaking (as it is for now for people, blindly upgrading the dependency to 7.x). |
Released in 7.5.0 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
As I commented in #910, the bundled TypeScript type definitions do not allow
import {destination, stdSerializers} from "pino"
, which is perfectly legal code.Looking at
pino.js
(as shipped in v7.0.5), I see top level exports defined for the following variables:Since these can be imported from the module, the typings should include definitions for them, to accurately describe the shape of the JS module.
While you're at it, consider removing the namespace "P" that wraps all your type and interface declarations, and exporting them directly. Namespace bundling is no longer considered a best practice in TS, and prevents the use of the (relatively recently introduced)
import type
syntax.This has real-world consequences. If I want to write a library that takes a
DestinationStream
, writingimport pino from "pino"; export function withStream(str: pino.DestinationStream) { ... }
results in including the entirepino
library at runtime, even though I'm not actually constructing a logger or using any of pino's runtime logic, while the exact same code withimport type {DestinationStream} from "pino"
instead, only requires the library at compile-time, and doesn't bundle the pino implementation.The text was updated successfully, but these errors were encountered: