Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error when using with pnpm and nestjs #92

Open
rajivkr opened this issue Nov 3, 2022 · 5 comments · May be fixed by #98
Open

Build error when using with pnpm and nestjs #92

rajivkr opened this issue Nov 3, 2022 · 5 comments · May be fixed by #98

Comments

@rajivkr
Copy link

rajivkr commented Nov 3, 2022

Hello, I am getting this error, when I building my nestjs application using pnpm.

`node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/index.ts:11:14 - error TS2742: The inferred type of 'createArrayCsvStringifier' cannot be named without a reference to '.pnpm/[email protected]/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/[email protected]/node_modules/csv-writer/src/index.ts:14:14 - error TS2742: The inferred type of 'createObjectCsvStringifier' cannot be named without a reference to '.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/object'. This is likely not portable. A type annotation is necessary.

14 export const createObjectCsvStringifier = (params: ObjectCsvStringifierParams) =>
~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/index.ts:17:14 - error TS2742: The inferred type of 'createArrayCsvWriter' cannot be named without a reference to '.pnpm/[email protected]/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/[email protected]/node_modules/csv-writer/src/index.ts:20:14 - error TS2742: The inferred type of 'createObjectCsvWriter' cannot be named without a reference to '.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-writer'. This is likely not portable. A type annotation is necessary.

20 export const createObjectCsvWriter = (params: ObjectCsvWriterParams) =>
~~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/index.ts:20:14 - error TS2742: The inferred type of 'createObjectCsvWriter' cannot be named without a reference to '.pnpm/[email protected]/node_modules/csv-writer/src/lib/lang/object'. This is likely not portable. A type annotation is necessary.

20 export const createObjectCsvWriter = (params: ObjectCsvWriterParams) =>
~~~~~~~~~~~~~~~~~~~~~
node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-writer-factory.ts:39:5 - error TS2742: The inferred type of 'createObjectCsvWriter' cannot be named without a reference to '.pnpm/[email protected]/node_modules/csv-writer/src/lib/lang/object'. This is likely not portable. A type annotation is necessary.

39 createObjectCsvWriter(params: ObjectCsvWriterParams) {`

@rajivkr rajivkr changed the title Build error when using pnpm and nestjs Build error when using with pnpm and nestjs Nov 3, 2022
@kangshuisheng
Copy link

Same mistake.

@lukepearce
Copy link

lukepearce commented Apr 6, 2023

instead of using es6 import:
import { createObjectCsvWriter } from "csv-writer"

use require:
const createObjectCsvWriter = require("csv-writer").createObjectCsvWriter;

@stevenle
Copy link

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.

@stevenle stevenle linked a pull request Apr 24, 2023 that will close this issue
@piercy
Copy link

piercy commented Sep 20, 2023

Could this PR be merged? Seems like a simple change to massively improve the usability of the library.

@brakmic
Copy link

brakmic commented Jul 16, 2024

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

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 a pull request may close this issue.

6 participants