TypeScript·Advanced·Coding·1 min read
Can two interfaces with the same name in the same scope coexist?
Short interview answer
Yes — this is declaration merging. TypeScript combines their members into a single interface. Two type aliases with the same name in the same scope, by contrast, produce a compile error because type aliases can't be merged.
Example
interface Window { myGlobal: string; } // merges with the built-in Window// type Window = { ... } // Error: Duplicate identifierKey takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.