Type is not assignable to type `object`
I really like the type-checking pino provides for the template strings, but the type for `%o` is too strict: it does not allow strings, numbers or even nullable objects. All of the following work at runtime, but are disallowed by type-checking (side note: I prefer using %o over %s for strings when I want clear string bounds):
```ts
log.info("uploaded %o", '"a file" and did something else') // uploaded '"a file" and did something else'
log.info("uploaded %o", 123) // uploaded 123
log.info("uploaded %o", null) // uploaded null
```
<img width="582" height="139" alt="Image" src="https://github.com/user-attachments/assets/abca768b-3e54-4388-92ae-cafcd7f3dde1" />
I think the only type that doesn't work is `undefined`, so `%o` could use `{} | null` instead of `object`?
关闭于 2026-01-09 1 条评论