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?
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.
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.
...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 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.
Add some file patterns to one of Git's ignore files.
.gitignore
file is usually committed with the repository, so its ignores are shared by all users..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.
gitignore
manpageThere is this feature request : http://github.com/TypeStrong/atom-typescript/issues/253
For now, I used
myfile.ts.ts
*.ts.js
and *.ts.js.map
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With