Skip to content

fix: address types of ArrayCsvStringifierParams and ObjectCsvStringifierParams#112

Open
baseballyama wants to merge 1 commit intoryu1kn:masterfrom
baseballyama:chore/fix-type
Open

fix: address types of ArrayCsvStringifierParams and ObjectCsvStringifierParams#112
baseballyama wants to merge 1 commit intoryu1kn:masterfrom
baseballyama:chore/fix-type

Conversation

@baseballyama
Copy link

It's unclear from which version of TypeScript this error started occurring, but at least in version 5.7.2, the following error appears, so I have made the necessary adjustments.

../../../node_modules/.pnpm/csv-writer@1.6.0/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         });
    ~~~~~~~~~

../../../node_modules/.pnpm/csv-writer@1.6.0/node_modules/csv-writer/src/lib/csv-writer-factory.ts:40:86 - error TS2379: Argument of type '{ header: ObjectStringifierHeader; fieldDelimiter: string | undefined; recordDelimiter: string | undefined; headerIdDelimiter: string | undefined; alwaysQuote: boolean | undefined; }' is not assignable to parameter of type 'ObjectCsvStringifierParams' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
  Types of property 'fieldDelimiter' are incompatible.
    Type 'string | undefined' is not assignable to type 'string'.
      Type 'undefined' is not assignable to type 'string'.

 40         const csvStringifier = this.csvStringifierFactory.createObjectCsvStringifier({
                                                                                         ~
 41             header: params.header,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
 45             alwaysQuote: params.alwaysQuote
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 46         });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant