ryu1kn / csv-writer

Convert objects/arrays into a CSV string or write them into a CSV file
https://www.npmjs.com/package/csv-writer
MIT License
246 stars 39 forks source link

[Bug]: Remove typescript files from build #105

Open what1s1ove opened 11 months ago

what1s1ove commented 11 months ago

Because the package is published together with TypeScript files (which is bad practice), various errors occur depending on the build tool.

image

For example, the problem in this issue https://github.com/ryu1kn/csv-writer/issues/92. Another example is when I want to enable the exactOptionalPropertyTypes option in the TypeScript config, it complains about the use of TS files in the node_modules folder, which we cannot fix.

image
node_modules/csv-writer/src/lib/csv-writer-factory.ts:30:85 - error TS2379: Argument of type '{ header: string[] | undefined; fieldDelimiter: string | undefined; recordDelimiter: string | undefined; alwaysQuote: boolean | undefined; }' is not assignable to parameter of type 'ArrayCsvStringifierParams' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
  Types of property 'header' are incompatible.
    Type 'string[] | undefined' is not assignable to type 'string[]'.
      Type 'undefined' is not assignable to type 'string[]'.

 30         const csvStringifier = this.csvStringifierFactory.createArrayCsvStringifier({
                                                                                        ~
 31             header: params.header,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
 34             alwaysQuote: params.alwaysQuote
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 35         });
    ~~~~~~~~~

Please consider publishing the package with only JS files, along with type declarations (d.ts files).

brakmic commented 3 months ago

Hi @what1s1ove ,

It seems that the original project may have been abandoned, so I decided to fork it. This problem has been resolved in my version, which only publishes the JavaScript files along with the index.d.ts declaration file. I'm also working on fixing other unsolved issues from the old project's list.

You can check out the forked project here:

Feel free to try it out, and I hope it helps!

Best, Harris