chore: use TSTyche for type testing#650
Conversation
| import { DestinationStream, Level } from 'pino' | ||
| import * as Colorette from 'colorette' | ||
|
|
||
| type LogDescriptor = Record<string, unknown>; |
There was a problem hiding this comment.
LogDescriptor was used only once, so I moved it inline. Otherwise it should be exported, but would that be useful?
| } | ||
|
|
||
| function build(options: PrettyOptions): PrettyStream; | ||
| export function build (options?: PrettyOptions): PrettyStream |
There was a problem hiding this comment.
Seems like here options must be optional. Same as #327
| type ColorizerFactory = typeof colorizerFactory; | ||
| type PrettyFactory = typeof prettyFactory; | ||
| type Build = typeof build; |
There was a problem hiding this comment.
These three types are not used and not exported. Can be removed. ESLint detected that.
| "lint:fix": "eslint --fix", | ||
| "test": "borp", | ||
| "test-types": "tsc && tsd && attw --pack .", | ||
| "test:types": "tstyche && attw --pack .", |
There was a problem hiding this comment.
There is no need to run tsc, because TSTyche does check .d.ts files as well.
| type Build = typeof build; | ||
| type PrettifierExtras = { colors: Colorette.Colorette, label: string, labelColorized: string } | ||
| export type Prettifier = (inputData: string | object, key: string, log: object, extras: PrettifierExtras) => string | ||
| export type MessageFormatFunc = (log: Record<string, unknown>, messageKey: string, levelLabel: string, extras: Pick<PrettifierExtras, 'colors'>) => string |
There was a problem hiding this comment.
Signature is updated to align with behaviour:
pino-pretty/lib/utils/prettify-message.js
Line 58 in ccc5b69
|
Sorry, I had some second thoughts. The code is updated and ready for review. |
Similar to pinojs/pino#2376
This PR migrates type test to TSTyche.
Current type test file is rather short (only 58 lines). I took the opportunity and wrote the tests from scratch. This way I could use
test()helper to organise the tests and to cover all public types with tests.Linting for
.tsfiles also got enabled. I hope this is not too much to review.The
test()helper is one of the advantages of TSTyche. You can use.skipor.onlywith it.Also you can test types against specific TypeScript version. For example,
tstcyhe --target next.And much more: https://tstyche.org