microsoft / microsoft/TypeScript

Quick Fix: Suggest correct capitalization when importing a file with incorrect capitalization

Open
#16,010 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: LS: Quick Fixes Experience Enhancement Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 2.3

Mac does not enforce file name capitalization. I had an issue where tests was passing on my Mac and I was getting an error like this in Linux:

Cannot find module './isKind' from 'index.ts'

File was named iskind by mistake.

It should be easy to detect errors like this by reading all files in target directory and look for similar file names. This can go beyond capitalization and can suggest correct file names with edit distance.

Code

import {foo} from './myModule'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the import example with a mismatched filename such as ./isKind versus iskind, comparing behavior on a case-insensitive Mac and Linux. Trace TypeScript's module-resolution diagnostics and directory file lookup; done means reporting the likely correctly capitalized filename, including cases with similar names or edit distance.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.