Skip to content

allowSyntheticDefaultImports not working with ESNext moduleΒ #60107

@bosens-China

Description

@bosens-China

πŸ”Ž Search Terms

allowSyntheticDefaultImports
lodash-es

πŸ•— Version & Regression Information

Version 4. x does not support 'moduleSolution': 'Bundler', so I only tried 5.6.2

⏯ Playground Link

https://github.com/bosens-China/picture-bed

πŸ’» Code

import _ from 'lodash-es';

// Usage of lodash function
console.log(_.debounce(() => console.log('Hello, world!'), 1000));
  • tsconfig.json
{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,
    "resolveJsonModule": true,
    /* Bundler mode */
    "moduleResolution": "Bundler",
    "allowImportingTsExtensions": true,
    "isolatedModules": true,
    "moduleDetection": "force",
    "noEmit": true,
    "jsx": "react-jsx",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    },
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true
  },
  "include": ["src"]
}

πŸ™ Actual behavior

src/store/features/users/slice.ts:3:8 - error TS1192: Module '"E:/picture-bed/node_modules/.pnpm/@types+lodash-es@4.17.12/node_modules/@types/lodash-es/index"' has no default export.

πŸ™‚ Expected behavior

I expected to be able to use the syntax import _ from 'lodash-es'; without errors, as allowSyntheticDefaultImports should allow default imports for modules that do not have a default export.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions