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

typescript error with verbatimModuleSyntax: true in tsconfig.json #113

Open
nktnet1 opened this issue Jan 16, 2025 · 2 comments
Open

typescript error with verbatimModuleSyntax: true in tsconfig.json #113

nktnet1 opened this issue Jan 16, 2025 · 2 comments

Comments

@nktnet1
Copy link

nktnet1 commented Jan 16, 2025

If we have the following in our tsconfig.json:

{
  "compilerOptions": {
    "skipLibCheck": true,

    // https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax
    "verbatimModuleSyntax": true
    
    
  },
  "exclude": ["node_modules"]
}

The following error occurs when running tsc:

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/index.ts:2:5 - error TS1484: 'ArrayCsvStringifierParams' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

2     ArrayCsvStringifierParams,
      ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/index.ts:4:5 - error TS1484: 'ObjectCsvStringifierParams' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

4     ObjectCsvStringifierParams
      ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/index.ts:6:9 - error TS1484: 'ArrayCsvWriterParams' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

6 import {ArrayCsvWriterParams, CsvWriterFactory, ObjectCsvWriterParams} from './lib/csv-writer-factory';
          ~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/index.ts:6:49 - error TS1484: 'ObjectCsvWriterParams' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

6 import {ArrayCsvWriterParams, CsvWriterFactory, ObjectCsvWriterParams} from './lib/csv-writer-factory';
                                                  ~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifier-factory.ts:4:9 - error TS1484: 'ObjectStringifierHeader' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

4 import {ObjectStringifierHeader} from './record';
          ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/abstract.ts:2:9 - error TS1484: 'Field' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

2 import {Field} from '../record';
          ~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/array.ts:3:9 - error TS1484: 'Field' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

3 import {Field} from '../record';
          ~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/object.ts:3:9 - error TS1484: 'Field' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

3 import {Field, ObjectHeaderItem, ObjectStringifierHeader} from '../record';
          ~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/object.ts:3:16 - error TS1484: 'ObjectHeaderItem' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

3 import {Field, ObjectHeaderItem, ObjectStringifierHeader} from '../record';
                 ~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/object.ts:3:34 - error TS1484: 'ObjectStringifierHeader' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

3 import {Field, ObjectHeaderItem, ObjectStringifierHeader} from '../record';
                                   ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/object.ts:4:19 - error TS1484: 'ObjectMap' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

4 import {isObject, ObjectMap} from '../lang/object';
                    ~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-writer-factory.ts:3:9 - error TS1484: 'ObjectStringifierHeader' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

3 import {ObjectStringifierHeader} from './record';
          ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/field-stringifier.ts:1:9 - error TS1484: 'Field' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.

1 import {Field} from './record';
          ~~~~~


Found 13 errors in 7 files.

Errors  Files
     4  node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/index.ts:2
     1  node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifier-factory.ts:4
     1  node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/abstract.ts:2
     1  node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/array.ts:3
     4  node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-stringifiers/object.ts:3
     1  node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/csv-writer-factory.ts:3
     1  node_modules/.pnpm/[email protected]/node_modules/csv-writer/src/lib/field-stringifier.ts:1
 ELIFECYCLE  Command failed with exit code 2.
@adam-nielsen
Copy link

I just had this same issue. The problem is that the NPM package includes the Typescript source files, not just the compiled Javascript and the *.d.ts files.

This means it's hitting this bug from 2020 and failing the build.

As a temporary workaround you can delete the node_modules/csv-writer/src/ folder, but the proper solution is that the src folder shouldn't be included as part of the NPM package.

@nktnet1
Copy link
Author

nktnet1 commented Jan 26, 2025

Yeah, thanks @adam-nielsen. This should indeed be removed:

"src",

Doesn't look like csv-writer is being actively maintained anymore though, so I've switched to using csv-stringify.

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

No branches or pull requests

2 participants