Skip to content

Commit 2df0821

Browse files
committed
fix(logger): add type assertions for Console stream properties
Fixes TypeScript compilation errors when accessing private Console stream properties (_stderr, _stdout): - assert(): Cast message parameters to proper types for console.assert - progress(): Add type assertion for streamObj write method - clearLine(): Add type assertions for TTY properties (isTTY, cursorTo, clearLine, write) These properties are not properly typed in Node.js Console type definitions, so explicit type assertions are needed for type safety.
1 parent 9373be8 commit 2df0821

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/logger.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ export class Logger {
694694
*/
695695
assert(value: unknown, ...message: unknown[]): this {
696696
const con = this.#getConsole()
697-
con.assert(value, ...message)
697+
con.assert(value, message[0] as string, ...message.slice(1))
698698
this[lastWasBlankSymbol](false)
699699
return value ? this : this[incLogCallCountSymbol]()
700700
}
@@ -1503,7 +1503,9 @@ export class Logger {
15031503
progress(text: string): this {
15041504
const con = this.#getConsole()
15051505
const stream = this.#getTargetStream()
1506-
const streamObj = stream === 'stderr' ? con._stderr : con._stdout
1506+
const streamObj = (
1507+
stream === 'stderr' ? con._stderr : con._stdout
1508+
) as NodeJS.WriteStream & { write: (text: string) => boolean }
15071509
streamObj.write(`∴ ${text}`)
15081510
this[lastWasBlankSymbol](false)
15091511
return this
@@ -1540,7 +1542,14 @@ export class Logger {
15401542
clearLine(): this {
15411543
const con = this.#getConsole()
15421544
const stream = this.#getTargetStream()
1543-
const streamObj = stream === 'stderr' ? con._stderr : con._stdout
1545+
const streamObj = (
1546+
stream === 'stderr' ? con._stderr : con._stdout
1547+
) as NodeJS.WriteStream & {
1548+
isTTY: boolean
1549+
cursorTo: (x: number) => void
1550+
clearLine: (dir: number) => void
1551+
write: (text: string) => boolean
1552+
}
15441553
if (streamObj.isTTY) {
15451554
streamObj.cursorTo(0)
15461555
streamObj.clearLine(0)

0 commit comments

Comments
 (0)