Open rajivkr opened 2 years ago
Same mistake.
instead of using es6 import:
import { createObjectCsvWriter } from "csv-writer"
use require:
const createObjectCsvWriter = require("csv-writer").createObjectCsvWriter;
FYI I'm getting this error using esbuild, since you're already using typescript and tsc, this feels like an easy fix. Just update your tsconfig to output a .d.ts declaration file to dist/index.d.ts and update "types" in package.json to point to the declaration file. Are you willing to accept a pull request for this? I'm happy to submit send one over.
Could this PR be merged? Seems like a simple change to massively improve the usability of the library.
Hi @rajivkr,
I saw your issue about the build error when using the package with pnpm and NestJS. I've forked the original project and am working on fixing such issues. My fork only publishes JavaScript files and includes type declaration files, which should resolve the TypeScript errors you're encountering.
Check it out here:
Give it a try and let me know if it helps!
Best, Harris
Hello, I am getting this error, when I building my nestjs application using pnpm.
`node_modules/.pnpm/csv-writer@1.6.0/node_modules/csv-writer/src/index.ts:11:14 - error TS2742: The inferred type of 'createArrayCsvStringifier' cannot be named without a reference to '.pnpm/csv-writer@1.6.0/node_modules/csv-writer/src/lib/csv-stringifiers/array'. This is likely not portable. A type annotation is necessary.
11 export const createArrayCsvStringifier = (params: ArrayCsvStringifierParams) =>
node_modules/.pnpm/csv-writer@1.6.0/node_modules/csv-writer/src/index.ts:17:14 - error TS2742: The inferred type of 'createArrayCsvWriter' cannot be named without a reference to '.pnpm/csv-writer@1.6.0/node_modules/csv-writer/src/lib/csv-writer'. This is likely not portable. A type annotation is necessary.
17 export const createArrayCsvWriter = (params: ArrayCsvWriterParams) =>
node_modules/.pnpm/csv-writer@1.6.0/node_modules/csv-writer/src/index.ts:20:14 - error TS2742: The inferred type of 'createObjectCsvWriter' cannot be named without a reference to '.pnpm/csv-writer@1.6.0/node_modules/csv-writer/src/lib/lang/object'. This is likely not portable. A type annotation is necessary.
20 export const createObjectCsvWriter = (params: ObjectCsvWriterParams) =>