Open dvarnai opened 4 years ago
Array<any>
and any
doesn't seem the same, am I missing something ?
Well records
and record
are both Array<any>
so one of them must be wrong (if record
is indeed Array<any>
shouldn't records
be Array<Array<any>>
?).
IMO record
is wrong and should just simply be any
. I'm using this with your csv-parse module with columns: true
and record
is not even an Array
:
const parser = csvparse({columns: true});
const transformer = transform((record: Array<any>, cb) => {
console.log(typeof record, record instanceof Array); // prints "object false"
})
request.get('https://ourairports.com/data/airports.csv')
.pipe(parser)
.pipe(transformer);
Furthermore, accessing properties of record
fails at compilation time with Array<any>
:
Property 'id' does not exist on type 'any[]'.
With my fix it's possible to explicity tell the compiler the type of record
in the function definition. Without that I could only disable type checking by explicitly setting record
to any
and then doing type casting, but that will lead to eslint warnings (unexpected any):
const transformer = transform((e: any, cb) => {
e = e as {[key: string]: string};
}
Hope that makes sense.
I think it has been fixed with #30
If records is
Array<any>
a record should just beany
type