node-csv: TS type errors with latest changes
The latest change doesn’t work well with TypeScript
Compiled with problems:
ERROR in src/views/data-manage/dictionary-manage/create-edit-modal/create-edit-modal.ts:1:35
TS2307: Cannot find module 'csv-parse/browser/esm/sync' or its corresponding type declarations.
> 1 | import { parse as csvParse } from 'csv-parse/browser/esm/sync';
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | import { Form } from 'element-ui';
3 |
4 | import { DictionaryApi } from '@/apis';
Can be work around with:
declare module 'csv-parse/browser/esm/sync' {
export * from 'csv-parse/dist/esm/sync';
}
Why not export csv-parse/dist/* directly?
Ref: https://github.com/adaltas/node-csv/issues/302#issuecomment-975037165
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 18 (8 by maintainers)
I created the branch feat/webpack_ts with a
webpack+ TypeScript demo.webpackis configured with Node.js polyfill, I hope this is not a problem for you. Other than this, it works pretty and doesn’t involve extra complexity. Removing the polyfill requirement involves the creation of a fifth distribution, cjs + polyfill, which I really hope to avoid because supporting all those environments (web, node.js, cjs, esm, ts, …) is already way too complex for the end users.*.d.ts. The path doesn’t matter.