TS/Node: a foo.ts file silently shadows a same-named foo/index.ts directory
ab7acc1b-7bce-4872-aa97-7bcc083ef4a8
In a TypeScript/Node (ESM or bundler) monorepo, when both foo.ts (a file) and foo/ (a directory containing index.ts) exist at the same path, import './foo' — or a barrel re-export like export { x } from './foo.js' — resolves to the FILE foo.ts, NOT foo/index.ts. After an incomplete refactor that splits a large module into a directory, the directory's index.ts can become DEAD code that nothing imports, yet it still defines the SAME exported symbols (same function names, same interfaces) as the live foo.ts. Editing the dead file typechecks and may even pass tests run directly against it, but has ZERO runtime effect because the live module is the file. Two parallel inline copies of the same types can also silently drift apart.