Skip to content

TypeScript default overloads treated as multiple default exports #1590

Closed

Description

The following example causes 3 error Multiple default exports import/export errors, but there is only technically 1 default export the other 2 are overloads.

export default function foo(param: string): boolean;
export default function foo(param: string, param1: number): boolean;
export default function foo(param: string, param1?: number): boolean {
  return param && param1;
}

There seems to be some code for checking overloads: https://github.com/benmosher/eslint-plugin-import/blob/master/src/rules/export.js#L37-L40 but this does not seem to catch this case. I added some debug logs in and the rough contents of namespace is:

root: {
  default: [
    {
       type: 'ExportDefaultDeclaration'
    },
    {
       type: 'ExportDefaultDeclaration'
    },
    {
       type: 'ExportDefaultDeclaration'
    }
  ]
}

I am running this in the following environment:

  • eslint: 5.16.0
  • eslint-plugin-import: 2.19.1
  • eslint-import-resolver-typescript: 2.0.0
  • typescript: 3.7.2
  • @typescript-eslint/parser: 2.13.0

Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions