Typescript: SUGGESTION: enable forceConsistentCasingInFileNames by default

Created on 1 Aug 2017  路  10Comments  路  Source: microsoft/TypeScript

I just spent pretty much the whole day trying to get vscode debugger to stop on breakpoints set in typescript files.

The issue ended up being that one of the files in my project was importing a resource from a file using wrong file casing (and it just so happened to be that this file was the one I was trying to set breakpoints in) ...

import { foo } from "../bar/Awesomebaz"

With the target file actually named 'AwesomeBaz.ts'.

No warnings or execution problems occurred from this mistake ... Everything seemed to work except my debugging experience was myseriously broken in a very hard to understand way. It took a long time to discover the forceConsistentNaming compiler flag and get the idea to try turning it on which led immediately to the correct fix.

I think having this聽flag off is a bad default -- I would like to suggest turning it on by default instead. Or at least turn it on when strict: true ...

Suggestion good first issue help wanted

All 10 comments

First off, really sorry you had a lot of frustration there. The option wasn't initially built into TypeScript which is why it's not the default. This would likely be a breaking change for users, so we'd need to discuss it.

I forget the specific issue number but the --forceConsistentCasingInFileNames option does not appear to work correctly with --paths. I would like to use it outside of NodeJS projects but I always get --paths errors even though my imports are all consistent. Someone filed a bug about this recently, I will try to hunt it down.

I'm seeing the same issue as @aluanhaddad, but I'm not able to the find the issue referred to. If the issue has not actually been filed, I'd be happy to.

@aluanhaddad I tried reproducing our issue in a minimal setup. At first, I could not, but after setting up configuration inheritance with extends, I was able to expose the issue. While this could be a red herring, I'm wondering if your setup also leverages extends.

FYI, issue filed: https://github.com/Microsoft/TypeScript/issues/17617
cc @aluanhaddad

I've submitted a pull request for this by the way @RyanCavanaugh. Enabling this by default would help prevent people from running into cross-platform issues with casing.

Note: Accepting PRs here only for changing what gets created in tsc --init's tsconfig.json (see comments in #18394). We still don't want to change the default value due to breaking change concerns.

Im interested if this died ad infinitum or if there is a plan having this implemented with a declared breaking change at some point? I just ran into the same problem using Deno. As Deno grows I could imagine there will be more and more complaints with the exact same problem.

Our general policy is that the default values of commandline values never change unless there's a very compelling reason to; I don't think this would qualify. tsc --init is our "good" set of commandline options.

I think it would, as well as strict. The most compelling reason to me is exactly that we need an extra --init command to have it override the defaults.
forceConsistentCasingInFileNames feels more like a patch instead of a design choice.

Was this page helpful?
0 / 5 - 0 ratings