Skip to content

import from "." doesn't reference folder if folder and file have same nameΒ #45563

Closed
@ghost

Description

Bug Report

πŸ”Ž Search Terms

import folder file refactor

πŸ•— Version & Regression Information

4.4.0-insiders.20210805, next, and the 4.3.x branch

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

⏯ Playground Link

Can't reproduce in playground as it has to do with multiple files and imports

πŸ’» Code

This has to do with file imports, so I made a minimal repro:

https://github.com/MarkKahn/ts-import-refactor-bug.git

πŸ™ Actual behavior

I was refactoring a file, module.ts into a directory, module. I created module/index.ts, and in module/submodule.ts I had written: import { otherSubModule } from '.'

TS threw an error saying Module '"."' has no exported member 'otherSubModule'.ts(2305)

After some banging my head on the wall I figured out that from '.' wasn't referencing ./index.ts, but instead was referencing ../module.ts

πŸ™‚ Expected behavior

import from '.' should reference the current folder, always. This is likely only a bug that would be triggered when refactoring code as I can't think of a use case for a file and folder to have the same name and be a valid structure.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions