-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tsc doesn't output proper file case on Windows 10 #15129
Comments
Isn't windows case insensitive when it comes to files? So This makes sense why it doesn't create a new file, because it sees that a file with the same name already exists...so it simply overwrites it |
@smac89 yes, I realize that, but it seems pretty important for the |
The compiler does not do any thing special here. this is the node fs apis on windows c:\test>node
> const fs = require("fs");
undefined
> console.log("Foo.js first");
Foo.js first
undefined
> fs.writeFileSync("./Foo.js", "a");
undefined
> fs.writeFileSync("./foo.js", "a");
undefined
> console.log(JSON.stringify(fs.readdirSync("./"), undefined, 2));
[
"Foo.js"
]
undefined
>
> fs.unlinkSync("./Foo.js");
undefined
>
> console.log("foo.js first");
foo.js first
undefined
> fs.writeFileSync("./foo.js", "a");
undefined
> fs.writeFileSync("./Foo.js", "a");
undefined
> console.log(JSON.stringify(fs.readdirSync("./"), undefined, 2));
[
"foo.js"
]
undefined
> |
Thanks @mhegazy! I posted an issue at nodejs/node#12521. |
@mhegazy the Node.js ticket has been rejected as a Windows issue. I realize Windows has been like this, probably from the beginning, but do you think there's any chance this could go up the ladder at Microsoft? Not sure where to file the issue at this point. |
Everything in Windows works the way it does to avoid breaking decades of backward compatibility. Zero chance this is changeable. |
Thanks @RyanCavanaugh. If that's the case, I think this remains a TypeScript issue. I just did a little test and it turns out that the following works as expected:
The issue here, of course, is that it makes an assumption that the file already exists. I see two ways to solve this problem:
Would the TypeScript team be open to any of these options? |
It seems like overkill to slow down every single build for the sake of not having to run |
I guess we're OK with |
You don't have to rename the file, just always do this:
Doing an unlink should be fast, and then the output case will be what is expected. |
@sam-github it's still an extra step. If it takes only an additional nanosecond, it sounds like they don't want it to accumulate for an edge case. |
Dev: So basically, a code compiled on WIndows won't run on Linux because it will try to require the wrong file name, for exemple. Gj guys. Then wonder why dev doesn't give a damn about Microsoft products. |
|
@mhegazy that flag is not at all related to this issue, as it only pertains to the import statements within the source code. This issue is more about the casing of the file names on the actual operating system / file system. |
that is why i said "some" and not all. |
Handle it in the software then. Excuses never made good softwares. |
@mhegazy there is only one scenario in this issue and Microsoft team says it's Node's fault. The Node.js team says it's Windows' fault. Nobody takes ownership of the issue; thus, the issue is never resolved. I think the compiler should always produce the same result, just like a pure function. Given the same input, I should always receive the same output. Unfortunately, this is not the case with the TypeScript compiler if the compilation folder already has js files in it. This is a side effect and should be fixed, if not by default, then with a compiler flag. The input is the same, but the output directory is not. That shouldn't make a difference! |
This is how case insensitive systems work and I'd argue it is to be expected. My advice would be to always clean before building or use a case sensitive system. Either way, it's not TypeScripts fault and should not be handled by the compiler. |
At the end of the day I only see two output : will I be able to use TypeScript without pain or not ? Also, people want you to handle this issue. Just handle it. Why wouldn't you ? Windows is not gonna become case sensitive tomorrow, and we will neverrun a clean before each compilation. So you are the only one who can fix this. I'm sending this to twitter, because you really behave like kids. You should be ashamed of yourself. |
@JesusTheHun I'm not sure what has triggered you. I'm just a community member that shared their opinion. The only thing that's shameful is your attitude and sense of entitlement. |
OK I thought you were a TypeScript developer. As a community member too indeed I'm entitled to make the proper development happen. And refusing to resolve an issue that does belong to you, simply because no one else can resolve it, is not the proper development. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.2.2
Code
irrelevant
Expected behavior:
On Windows 10, compiling
Foo.ts
writes a file namedFoo.js
to output folder.Actual behavior:
If
foo.js
(lowercase) already exists in output folder, the new file contents ofFoo.ts
are written tofoo.js
, but the file name's case doesn't change.This issue just bit me in the real world on the EditorConfig vscode extension.
Workaround
Deleting
foo.js
and runningtsc
again solves the problem; though, this is not ideal.The text was updated successfully, but these errors were encountered: