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

fix: add type declaration paths to exports field #341

Merged
merged 3 commits into from
Jul 10, 2022

Conversation

andipaetzold
Copy link
Contributor

With TypeScript 4.7, a new module was introduced: Node16. https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#esm-nodejs

When using strict mode with module Node16, you receive the following error message because the type declaration cannot be found:

Could not find a declaration file for module 'csv-stringify'. '.../node_modules/csv-stringify/dist/cjs/index.cjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/csv-stringify` if it exists or add a new declaration (.d.ts) file containing `declare module 'csv-stringify';`

Reproduction

Create a new project with the following dependencies

  • typescript: 4.7.2
  • csv-stringify: 6.1.0

Create the following files:

// tsconfig.json
{
    "compilerOptions": {
        "module": "Node16",
        "strict": true
    }
}
// index.ts
import { stringify } from 'csv-stringify';

When building the project, you receive the error message above.

Solution

This issue can be solved by adding the types to the exports field in package.json

@wdavidw
Copy link
Member

wdavidw commented May 30, 2022

In packages/csv-generate/package.json, the stream field was removed. Could you place it back, thank you.

@andipaetzold
Copy link
Contributor Author

Done. Copy paste 🤦

The require path of csv-generate/stream (dist/cjs/stream.cjs) does not exist in the final bundle. I assume there is a build step missing.

@wdavidw wdavidw force-pushed the master branch 2 times, most recently from 5660ca1 to fb1b21c Compare June 8, 2022 13:11
wdavidw added a commit to andipaetzold/node-csv that referenced this pull request Jul 10, 2022
wdavidw added a commit to andipaetzold/node-csv that referenced this pull request Jul 10, 2022
@wdavidw wdavidw merged commit 4b0283d into adaltas:master Jul 10, 2022
@wdavidw
Copy link
Member

wdavidw commented Jul 10, 2022

Thank you for your insights!

  • csv-generate: 4.1.0 => 4.2.0
  • csv-parse: 5.2.2 => 5.3.0
  • csv-stringify: 6.1.3 => 6.2.0
  • csv: 6.1.5 => 6.2.0
  • stream-transform: 3.1.0 => 3.2.0

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.

3 participants