FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: Duplicate declaration for type and value in ts · Issue #15262 · babel/babel · GitHub

/ babel Public

[Bug]: Duplicate declaration for type and value in ts #15262

Description

💻

  • Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

import { type Foo } from './foo'

function Foo() {}

REPL

Configuration file name

babel.config.json

Configuration

{
  "presets": [
    [
      "@babel/preset-env",
      {
        "targets": {
          "browsers": ["last 2 versions", "ie 11"]
        },
        "modules": "auto"
      }
    ],
    "@babel/preset-react",
    "@babel/preset-typescript"
  ],
  "plugins": ["@babel/plugin-proposal-class-properties"],
}

Current and expected behavior

Current behavior

Babel throws an error :

Duplicate declaration "Foo"
  1 | import { type Foo } from './foo'
  2 |
> 3 | function Foo() {}
    |          ^^^
  4 |

However there is no error if the type Foo is declared in the same file as the function Foo.

Expected behavior

Babel should accept that an imported type and a value can share the same name.

Environment

Babel version: v7.20.5
Node: 16.15.1
Yarn: 1.22.19
OS: Linux 6.0 Arch Linux
Monorepo: yes (yarn workspaces)

Possible solution

No response

Additional context

No response

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL