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

Compiler flag to specify line ending #1693

Closed
fMads opened this issue Jan 16, 2015 · 10 comments
Closed

Compiler flag to specify line ending #1693

fMads opened this issue Jan 16, 2015 · 10 comments
Labels
Fixed A PR has been merged for this issue Help Wanted You can do this Suggestion An idea for TypeScript

Comments

@fMads
Copy link

fMads commented Jan 16, 2015

All generated js-files have windows-style line endings.
It would be great, if we could specify the line endings - windows, unix etc.

We use PhpStorm as editor, and it keeps marking generated js, d.ts etc files as changed, even though the code is the same. The only difference is \n -> \r\n.

Relates to https://typescript.codeplex.com/workitem/258

@DanielRosenwasser
Copy link
Member

I don't know if you'd get different results if the line endings were the same - but you could also configure your editor's line ending options to make sure this is the case.

@DanielRosenwasser DanielRosenwasser added the Suggestion An idea for TypeScript label Jan 16, 2015
@fMads
Copy link
Author

fMads commented Jan 16, 2015

I have configured the editor - but I think the difference is, that this is an external change to the files and the editor therefor isn't updating the line endings.
Git is also configures to use unix-style, so it will be commited with unix style line endings.

The main problem is, when we're changing branches, and the .ts files are changed in the new branch. The TSC will se the .ts file change and recompile the file and thus overwriting the .js file (which was committed with unix style line endings) with windows style line endings. It marks as a change in PhpStorm.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 16, 2015

The line endings of the generated .js, .d.ts, and .sourcemap files are currently only dependent on the underlying system. so if you are running on windows you will always get /r/n if you are on macOS you would get /n.

@fMads you want a new compiler flag to toggle line endings, correct?

@DanielRosenwasser
Copy link
Member

If this is a matter of checking out something with Unix line endings, have you tried setting your git repo's autocrlf option?

@carlpaten
Copy link

@fMads: any particular reason you're committing the generated js files? I feel like they should be left out of the repo, just like binaries. Not being snarky, just curious.

@fMads
Copy link
Author

fMads commented Jan 19, 2015

@mhegazy Yes, a compiler flag would be great :)

@DanielRosenwasser Yes - it only converts the file, when the repo is committed. That's a step to late.

@LilRed You're proberbly right - that would be the best way to handle it.
We just don't have any post-processing of our code at our live systems. We commit and push to remote repo, when we do an update to our clients.
We could of course change it, so we compile the code at post-receive - but it's just easier doing it on dev-system (Before pushing)

@mhegazy mhegazy changed the title Specify line ending Compiler flag to specify line ending Jan 19, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Jan 19, 2015

updating the title for the issue.

@fMads, a PR would definitely be welcomed. The system now is wired to get the sys.newline, (see program.ts L72) the change would be to pass options.newLine instead.

@mhegazy mhegazy added the Help Wanted You can do this label Jan 19, 2015
@kmashint
Copy link
Contributor

+1 for this feature of specifying a line ending. GIT doesn't have quite the right mix of options for dealing with cross-platform line endings and the best I've found on a mixed team that deploys to UNIX-style systems is to just force those common line endings everywhere. Yes, having JS files in version control may not be ideal but it's pragmatic.

@hranicka
Copy link

+1 for this feature of specifying a line ending.

kmashint added a commit to kmashint/TypeScript that referenced this issue Apr 26, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue Apr 26, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue Apr 27, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue Apr 27, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue Apr 27, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 2, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 2, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 2, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 2, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 3, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 3, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 3, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 3, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 3, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 3, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 3, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 3, 2015
kmashint added a commit to kmashint/TypeScript that referenced this issue May 3, 2015
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 4, 2015
@mhegazy
Copy link
Contributor

mhegazy commented May 4, 2015

Thanks @kmashint!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants