-
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
lowercase filename in triple slash directives #45096
Comments
Do you have |
Yes, it is on |
Sorry, I misread the issue - I don't know if that's actually relevant, though it does help avoid the issue. If the underlying file is |
yes, my point is more about the fact that it seems the triple slash directives by default convert all filenames to lowercase, but that is not documented anywhere |
This bug broke a couple pipelines for us the other day- it seems that compilation on an OS which is case insensitive produces reference tags in d.ts files which are lowercase, whereas on an OS which is case-sensitive it maintains proper casing in the output. Failures were caused when we started validating the reference directives in the generated API document, and there was platform-based mismatch. It seems unnecessary to lowercase the path on case-insensitive platforms in the first place. |
Example source:
Compiled declaration file in Unix (case sensitive):
Generated declaration file in Windows (case insensitive):
|
I'm not sure how you got into a state where a relative |
You said the underlying file is lowercase. I don't think it's a blind conversion like you suggest--it's observing that the filename in the directive doesn't match what's on disk and warning you about that. Blindly converting all filenames to lowercase wouldn't make sense and would actually break things on a case-sensitive FS. |
Hey, not really, that's not what I meant. the underlying file name is but it gives an error on Linux about inconsistent casing |
lowercase all type declaration files to work around microsoft/TypeScript#45096. Change PipelineStage.d.ts to kebab-case for clarity.
We got today a Bug Report on mongoose by @Davis-owen regarding this bug. This is totally undocumented and unexpected behavior. I think the bug was introduced with #10340 by @andy-ms when the lowercasing was only about the npm package name. I think that the solution is to check if it is a string, which does not contain a slash "/" and lowercase it, and if it contains a slash to split the string and only lowercase the the first part and keep the rest unchanged. Or maybe even remove the lowercasing. It was imho in the first place wrong, to implicitly transform the reference path to lowercase. |
Here again a proof, that the lowercase is because of that PR which was only targetting to lowercase the npm package name. s-panferov/awesome-typescript-loader#326 (comment)
|
Btw. this is not about blaming @andy-ms . I just wanted to tag @andy-ms so that he maybe adds his thoughts on this. But now I see he is not active on github anymore. Well anyway: Is removing the lowercasing actually an option? Unfortunately Typescript Codebase seems to be kind of heavy to work in, so I would not be able to provide a PR with the necessary Quality. Or we just make it crystal clear in the documentation that filenames of types should be lowercase. |
This had come up in #26948 |
This is not about d. Ts emit but how we lowercase type ref names for file |
Sorry, I thought this was about emit 😅 |
+1 on Linux, affecting https://www.npmjs.com/package/stripe Feature request raised there since this issue hasn't had any love for a long while. |
+1. Issue seems resolved on MacOS for typescript@4, but not on Linux. |
I'd be happy to send a PR over to TS if this is something the team is willing to approve! While we could downcase the entire |
Bug Report
Referencing a file name in triple slash directives automatically looks for the lower case filename
🔎 Search Terms
🕗 Version & Regression Information
have seen it since ts > 3.x
⏯ Playground Link
not sure how to reproduce it in the playground
This requires multiple files, and there is no easy way to verify
💻 Code
🙁 Actual behavior
on case sensitive OS, i got a warning from tscompiler about the casing being incorrect.
🙂 Expected behavior
should not get this warning
More Info:
I guess this is related to #26948
and it seems this is correct behaviour.
If that is the case, it would be great to document it alongside triple slash directives or add it to FAQs
https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html
The text was updated successfully, but these errors were encountered: