🔎 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
importtype{Component}from'react';// TS errors on this while it is imported as a typeconstComponent: Component|null=null;importtype{FC}from'react';// TS allows this as it's a typeconstFC: 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.
🔎 Search Terms
Declaration merging, isolatedModule, type import conflict
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?isolatedModules=true&ts=5.4.0-beta#code/JYWwDg9gTgLgBDAnmApnA3nAwhcEB2K+8AvnAGZS5wDkUKAhgMYw0DccA9J3ACoDKcFFCpQAznAIIAFsAkB3WQBs0weHLihIsFABM4DCQwTIUAKCYEx8HHkLEAXNlyR78AD5x8AVyVK4ALxevkpsZmZa0PBIqBhwAGJYcGSU1HSMLOxcPAIGfhDyEjCyRhJqNEYmqBZW8IlOiXCePn6BwX5hQA
💻 Code
🙁 Actual behavior
TypeScript reports the following error:
🙂 Expected behavior
Because
Componentis imported as a type, it should be merged with the variableComponentwithout 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.