Typescript files in version history

Asked

Viewed 88 times

2

I started using Typescript in my web project to generate the Javascript files and my question is: In the version system I should put only the Javascript files, Typescript or both?

2 answers

5

Depends on what you’re doing and want.

If you are creating a normal Typescript application your code is in this language, these files are the source (source) of its application and is talking about the use of version control sources (although some people use for other things is not usually the most appropriate, so there are even ways to ignore certain files, in general the target files).

Each VCS software has its own way of doing this, but it is not the focus of the question.

JS files are the target (target) and so do not want to control version of them, are generated every modification, they do not exist by themselves, are generated on demand as it changes the original sources.

When you create an application in other technologies that generate a binary (a .exe for example) do you want to edit this file? I don’t think so. It’s the same thing.

But there may be some case that .js may be useful, only it is not the most common, you would have to give a good justification to do so. One of them is you mix the two languages.

  • They are web design with html, css and javascript only.

5

To indicate what goes to your repository or not, you must indicate the file path (or directory) in question in your archive .gitignore. For more details, see Configure . gitignore to not upload certain files.

What to ignore?

Well, depending on the language / framework that you use will have a different recommendation. See this repository from Github, it contains a .gitignore "standard" for various languages and frameworks.

In your specific case, you don’t need to javascript if it is generated from the typescript. Because any other developer who participates in the project will be able to generate the files javascript as needed.

Note that if you have a file that you don’t want to expose the information (for example, a file with the credentials of a database or a private key to access an API), you can add the file to the .gitignore not to publish it :)

  • Yes, only what to ignore. They are simple projects with only HTML, CSS and javascript running on the client side.

  • 1

    If the javascript is generated from the typescript, you don’t need to see the javascript. But when it’s time to do the deploy the recommended is the opposite: send HTML, CSS and JS without TS

Browser other questions tagged

You are not signed in. Login or sign up in order to post.