sindresorhus / camelcase-keys

Convert object keys to camel case
MIT License
691 stars 95 forks source link

No default export found in imported module "camelcase-keys" #63

Closed w4-jake closed 4 years ago

w4-jake commented 4 years ago

Hi and thank you for your work on this. This might be more appropriate to ask over at eslint-plugin-import -- I am not sure yet.

camelcase-keys: 6.2.2 snakecase-keys: 3.2.0

eslint: 6.8.0 eslint-plugin-import: 2.20.1

typescript: 3.8.2 vs Code: 1.44.2

In my project, camelcaseKeys is imported and called successfully, but I get the below error when linting:

import camelcaseKeys from 'camelcase-keys' // <-- here
import { expect } from 'chai'
import snakecaseKeys from 'snakecase-keys'

describe('keys tests', () => {
  describe('camelcaseKeys', () => {
    it('changes keys to camelcase', () => {
      // eslint-disable-next-line @typescript-eslint/camelcase
      const result = camelcaseKeys({ snake_case: 'value' })
      expect(result).to.be.deep.equal({ snakeCase: 'value' }) // <-- passes
    })
  })

  describe('snakecaseKeys', () => {
    it('changes keys to snakecase', () => {
      const result = snakecaseKeys({ camelCase: 'value' })
      // eslint-disable-next-line @typescript-eslint/camelcase
      expect(result).to.be.deep.equal({ camel_case: 'value' }) // <-- passes
    })
  })
})

1:8 error No default export found in imported module "camelcase-keys" import/default

If it is useful, here is the tsconfig:

{
  "compilerOptions": {
    "alwaysStrict": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "noImplicitAny": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "*": ["@types/*.d.ts"]
    },
    "allowJs": true,
    "typeRoots": ["overrides", "node_modules/@types"]
  }
}

Strangely, I have no linting issue default importing from snakecase-keys, whose index file seems structurally the same to that of camelcase-keys.

Thank you for any guidance. I am pretty new to typescript so I may be missing something simple.

sindresorhus commented 4 years ago

This might be more appropriate to ask over at eslint-plugin-import

It is ^

w4-jake commented 4 years ago

Thanks for the fast reply. I'll ask them.