Skip to main content

Hiding JS and Related Files While Working with TypeScript : Visual Studio Code

While I was exploring Angular 2, following their Tour of Heroes tutorial, I was excited to see it is using TypeScript. As we know, TypeScript is not directly supported by browsers. It has to be transpiled into JS code for it to work. Good thing, the guys at Google has come up with a startup kit when developing Angular application ( instruction how to get it here ). Now you dont have to worry about manually transpiling TypeScript codes to JS, the package will do that for you and a lot more ( BrowserSync, yeah). With that being taken care of, you only have to worry about your TS code. Because the transpiled files reside on the same folder, these files may cloud up your Visual Studio Code file list. I asked StackOverflow ( Google for devs haha ) and got a working solution, pronto!

FileList Before the Fix


The Fix

  1. Edit VSCode Preferences.
  2. Edit Settings. This will open the settings.json file. You can either edit the User Setting or the Workspace Setting.
  3. Search for the "files.exclude"
  4. Add the following values :
     "**/*.js.map": true,
     "**/*.js": {"when": "$(basename).ts"}
Note : The extra arguments on the last entry make sure that we only hide JS files when a file with the same base name but with a TS extension is present.

The Resulting List


Now you can concentrate on the TypeScript files. Enjoy coding!

References



Comments

Popular posts from this blog

renaming default namespaces for VSTO projects in VS2008

So here is the scenario , you are starting a VSTO project and decided that your default namespace is ExcelAddInTesterApp . You created the project and started coding the project. After several days , your boss called and said "hey marvin , make use of this namespace OurCompany.ExcelAddInTesterApp , we have to add our company name to it got it?" . You get back to your machine thinking its just a simple property just like any project you've been working on. So you right clicked the VSTO project and hit properties . Boom! What the F@#$? The default namespace textbox is disabled!!!!



I've been through this and I googled for ways to do it and ended up with a blog from a Microsoft MVP telling me it can't be done because it is disabled. Then I thought of Refactoring, the beauty and grandeur of the renaming process. I selected the namespace and hit the refactor menu hoping that this would solve the problem . Unfortunately , it did not rather it displayed the message box …

this year

.. i will learn new things, perhaps play a new instrument or go back to school.
.. i will find beauty on the open source community.
.. i will read more books and listen to more music.
.. i will pen more poems and possibly write more songs.
.. i will go for new distances and discover new terrains.
.. i will continue to pile running miles to stay fit and healthy.
.. i will strive to be free and make myself available to unknown future.
.. i will go out of my shell more often and be socially more open.

.. i will continue to grow and go with the changes of time.
.. i will be more patient and hopeful to things that may not even be possible.
.. i will be a better son, brother and more importantly a better father.
.. i will be closer with the great beyond.

.. i will continue to repair , refactor and upgrade myself to become a better version of me.

Automatic Properties and Object Initializers in .Net 3.5

With the release of .Net 3.5 alongside with Visual Studio 2008 , new enhancements was again introduced . Some maybe well pronounced such as the inclusion of WCF, WPF , LINQ in .Net 3.0 and some just came unnoticed. If you have been accustomed of using a particular method or technique in implementing a certain code in .Net 2.0 , because of backward compatibility , you may not even notice that there are new ways of implementing it in .Net 3.5.

Here are two new concepts in .Net 3.5 that a developer may not notice ( at least in my opinion ) : Automatic Properties and Object Initializers . To illustrate these two , I am going to present the pre-.Net 3.5 way (.Net 2.0) and the .Net 3.5 way in creating a simple class with simple properties.

Automatic Properties

Creating a class can be tedious , especially when working with a list of properties , . One way to get around having to type the code for a private field and its public property getter and setter is to use a refactoring tool. However, …