Describe the bug
[email protected]
I'm using stringify to cast output values within a file stream, but I see a type warning:
No overload matches this call.
The last overload gave the following error.
Argument of type { header: boolean; cast: { boolean: (value: boolean, ctx: CastingContext) => string | boolean; }; } is not assignable to parameter of type Input.
Object literal may only specify known properties, and header does not exist in type any[].
My code runs fine. This warning gives the impression that header and cast are mutually exclusive.
When I remove header, I see a different warning:
No overload matches this call.
The last overload gave the following error.
Argument of type { cast: { boolean: (value: boolean, ctx: CastingContext) => string | boolean; }; } is not assignable to parameter of type Input.
Object literal may only specify known properties, and cast does not exist in type any[].
To Reproduce
Here's my code:
fs.createReadStream(inFile)
// ...
.pipe(stringify({
header: isOutFileNew,
// ^^^^^ warning
cast: {
boolean: (value, ctx) => {
if (ctx.header) return value
if (ctx.column === 'Removed' && value === false) {
return '0'
}
return String(value)
}
}
}))
Additional context
My guess is the overloaded functions aren't being determined in the correct oder, where Input is being inferred instead of Options:
|
declare function stringify(options: Options, callback?: Callback): Stringifier |
|
declare function stringify(input: Input, callback?: Callback): Stringifier |
Describe the bug
[email protected]
I'm using
stringifyto cast output values within a file stream, but I see a type warning:My code runs fine. This warning gives the impression that
headerandcastare mutually exclusive.When I remove
header, I see a different warning:To Reproduce
Here's my code:
Additional context
My guess is the overloaded functions aren't being determined in the correct oder, where
Inputis being inferred instead ofOptions:node-csv/packages/csv-stringify/lib/index.d.ts
Lines 120 to 121 in 22f4017