Skip to content
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

TypeScript new line default on Windows breaks on *nix #29928

Closed
leidegre opened this issue Feb 15, 2019 · 6 comments
Closed

TypeScript new line default on Windows breaks on *nix #29928

leidegre opened this issue Feb 15, 2019 · 6 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@leidegre
Copy link

leidegre commented Feb 15, 2019

I would like to purpose that this is a bug because it causes needless trouble in cross platform environments and I cannot find a single reason for why we insist on having CR LF on Windows any more.

Expected behavior:
Linux/OS X users don't run into subtle issues because of carriage return in bin scripts.

Actual behavior:
When a TypeScript project is built on Windows and then published to NPM, the default new line options is CR LF. If your package.json has a bin script with a shebang like this #!/usr/bin/env node TypeScript will rewrite this with a CR LF line ending which breaks on at least Mac OS X with the following error env: node\r: No such file or directory error Command failed with exit code 127 (haven't tested this elsewhere).

I'm raising this as a bug because it has non obvious implications for people developing software with TypeScript if they publish their code to NPM. And I don't think that there is a valid reason for why CR LF should be used on Windows at all. It's an archaic historical artifact that should have been laid to rest a very long time ago.

I'm going to be bold and suggest that the option --newLine should never have been added. That it should be deprecated and that the option should be ignored. And that TypeScript only emit LF from now on.

@j-oliveras
Copy link
Contributor

This options already exists (from compiler options):

Option Type Default Description
--newLine string (platform specific) Use the specified end of line sequence to be used when emitting files: "crlf" (windows) or "lf" (unix).”

@leidegre
Copy link
Author

leidegre commented Feb 15, 2019

@j-oliveras please read the last paragraph.

I'm going to be bold and suggest that the option --newLine should never have been added. That it should be deprecated and that the option should be ignored. And that TypeScript only emit LF from now on.

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Feb 19, 2019
@RyanCavanaugh
Copy link
Member

There are certainly other people which have workflows which depend on CR+LF. Configuration is hard; making it harder on purpose by removing options or breaking backward compatibility is not a priority for us.

@leidegre
Copy link
Author

@RyanCavanaugh I respect your decision. I disagree wholeheartedly.

Ultimately, I think this leaves TypeScript in a worse place because it becomes just another thing you list of exceptions to consider, albeit only if you use Windows as a web development platform. The use case that you have effectively broken with this design decision is writing TypeScript on Windows and then publishing to NPM. It won't work without the --newLine option set to LF.

I don't think it should work like that. But what do I know, I'm just a guy with an opinion.

I would like to end this by just saying that I really enjoy TypeScript. And I appreciate all the good work that has went into TypeScript. It's made me look at typing stuff in a new way. And I'm not trying to be salty, I genuinely believe that what I try to argue here would make TypeScript better.

@leidegre
Copy link
Author

leidegre commented Feb 21, 2019

There are certainly other people which have workflows which depend on CR+LF.

@RyanCavanaugh you give me one example and I will believe it. 😄

@gmeligio
Copy link

gmeligio commented Jun 21, 2024

@leidegre In case it helps you, the new default in TS 5.5 is LF, according to the release notes. It might improve your use cases.
#51909
https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/

I just found this issue after reading the release notes of 5.5. I noticed this newline option I wasn't aware of and started investigating its usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants