Skip to content

Imported symbol as a type is not merged with a local variableΒ #57414

@Conaclos

Description

@Conaclos

πŸ”Ž Search Terms

Declaration merging, isolatedModule, type import conflict

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about declaration merging

⏯ Playground Link

https://www.typescriptlang.org/play?isolatedModules=true&ts=5.4.0-beta#code/JYWwDg9gTgLgBDAnmApnA3nAwhcEB2K+8AvnAGZS5wDkUKAhgMYw0DccA9J3ACoDKcFFCpQAznAIIAFsAkB3WQBs0weHLihIsFABM4DCQwTIUAKCYEx8HHkLEAXNlyR78AD5x8AVyVK4ALxevkpsZmZa0PBIqBhwAGJYcGSU1HSMLOxcPAIGfhDyEjCyRhJqNEYmqBZW8IlOiXCePn6BwX5hQA

πŸ’» Code

import type { Component } from 'react'; // TS errors on this while it is imported as a type
const Component: Component | null = null;

import type { FC } from 'react'; // TS allows this as it's a type
const FC: FC | null = null;

πŸ™ Actual behavior

TypeScript reports the following error:

Import declaration conflicts with local declaration of Component.

πŸ™‚ Expected behavior

Because Component is imported as a type, it should be merged with the variable Component without emitting an error.

Additional information about the issue

A related issue was recently fixed and discussed in a design meeting.

Fixing the current issue could make TypeScript behavior more consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions