Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2013 with GitHub - Stop JS files made from typescript files from commits

I am using Visual Studio 2013 and GitHub for my source control, and a problem I keep having is that it keeps trying to commit all of the .js files that are generated from .ts (Typescript) files.

The reason this is bad is because I've had experiences where committing these causes building to fail, and only closing and re-opening Visual Studio fixes the issues.

My knowledge of git is still rudimentary in general, but it seems to me this must be a common problem. I do not want to just exclude all .js files because there are many that are not generated from typescript; So is there anything I can do about this other than MANUALLY excluding the files every single time I do a commit?

like image 302
Ciel Avatar asked May 05 '14 10:05

Ciel


People also ask

How does typescript get compiled?

this is actually typescripts main use case it gets compiled to .js + d.ts files which you then publish. e.g. even full typescript project have "only" js in their node_modules folder. often these .js files are accompanied by d.ts files or there is a dedicated package @types/packageName.

Is there a way to have T / JS without typescript?

To summarize: Idea is to have .ts / .js files without any typescript specific language construct, with only .d.ts files accompanying them Anyone used it like this or any thoughts on this ? this is actually typescripts main use case it gets compiled to .js + d.ts files which you then publish.

Can typescript generate DTS files from JSdoc annotated files?

...and TypeScript will generate *.js and *.d.ts files for us. (Note that the output of the js file is exactly the same we wrote in our js version.) Sadly, as of now tsc does not support generating *.d.ts files from JSDoc annotated files.

How to ignore JS files with the same name as TTS?

How to ignore .js files that are the same name as the .ts files? Change the outDir entry of your tsconfig.json file. This is conventionally called build but you can name it whatever you'd like.


2 Answers

Add some file patterns to one of Git's ignore files.

  • The .gitignore file is usually committed with the repository, so its ignores are shared by all users.
  • The .git/info/exclude file is not committed with the repository, so it can be used for your own personal ignores.

To ignore all .js file in a directory foo, use something like this:

foo/*.js

Note that patterns in the ignore files only prevent files from being tracked. This means that if you have already committed a file, it will continue to be tracked. Modifications will cause the file to show up in your "uncommitted changes", and something like git commit -a will cause changes to be committed.

If you have a committed file that you wish to ignore going forward, you will have to remove it from the repository. This is a frequent question on SO, and there are many questions about handling this.

It is worthwhile to read up on Git's ignore feature, as it has a few gotchas.

  • The gitignore manpage
  • GitHub's "Ignoring files" help page
  • A popular SO question about removing already tracked files
like image 200
Chris Avatar answered Oct 21 '22 17:10

Chris


There is this feature request : http://github.com/TypeStrong/atom-typescript/issues/253

For now, I used

  • rename file, ex, myfile.ts.ts
  • include in .gitignore my auto-generated typescript *.ts.js and *.ts.js.map
like image 39
Wagner Pereira Avatar answered Oct 21 '22 15:10

Wagner Pereira