9

I'm new to development, currently working on Angular 2. I came across a problem while saving a .ts (typescript) file on my computer (Win 7).
I have run the commands using npm:

>npm install typescript

but when I try to save the text file to a .ts file it creates MPEG 2 TS file.
How to resolve this problem.

3
  • 1
    It's just that the file association in Windows is MPEG-2 TS, rather than TypeScript. No formatting issues whatsoever. Mar 21, 2019 at 12:40
  • Try right click the file, "open with" and then set the default application, rather than media player or whatever it's trying to use. Mar 21, 2019 at 12:41
  • See superuser.com/a/1464304/4522 for registry settings to make Windows recognise .ts files as text.
    – Joe Daley
    Aug 4, 2021 at 0:56

6 Answers 6

8

The fact that windows treats .ts files as video is super annoying for anyone working with typescript daily.

I couldn't find a way to change this in regedit, but I found an app called FileTypeMan.

I used it to set mime type to text/plain and perceived type to text.

Now the explorer doesn't try to generate a video thumbnail when i open a folder with typescript files any more.

I don't like that I had to download a program for this, but at least it doesn't need admin rights to run.

If someone find a way to do it with only regedit please share.

1
  • 1
    I found how to do it in regedit. Open HKEY_CLASSES_ROOT\.ts, and change the 3 values to make them similar to the .txt key. See my answer below.
    – Keorl
    Jan 28, 2022 at 9:38
7

It doesn't get saved in MPEG-2 TS format. Windows just interprets the .ts extension as MPEG-2 TS and shows a video file like icon for your .ts file. You can ignore that.

5
  • 1
    Unfortunately, when clicked on, Windows will attempt to open a ts file as video then crash.
    – Quentin 2
    Jan 3, 2018 at 15:20
  • 1
    Is there a way to prevent windows 10 from thinking it is a video file? Even when I tell it to open .ts extensions with VSCode it still thinks it is a video file and shows video tools when I click on it in the file browser.
    – Almenon
    Jun 24, 2018 at 1:53
  • 5
    @Almenon It's possible but Microsoft don't make anything easy in Win10. Right-click the file, Open with/Choose another app (DONT choose VS Code here). Now Visual Studio Code should appear in the list, click it and check 'Always use this app to open .ts files', click OK, and the association should be changed. If the app you want to associate with .ts doesn't appear you can scroll down, choose 'More apps', scroll down again, choose 'Look for another app on this PC' and Windows will open a file browser so you can find the executable on the file system.
    – Rich N
    Jul 10, 2018 at 15:14
  • 2
    @RichN that associates ts with vscode, yes, but the video tools still appear on the top of the file explorer when I click on the file.
    – Almenon
    Jul 17, 2018 at 2:34
  • @Almenon Windows (rather stupidly) just adds the Video Tools as an available menu at the end of the ribbon. It still displays the menu it was showing before. Does that actually cause a problem somehow - you can just ignore it can't you?
    – Rich N
    Jul 18, 2018 at 10:11
5

Telling Windows to open .ts with VS Code or Notepad++ isn't enough : it will still try and fail to create thumbnails every time you open a directory containing .ts files, which makes the explorer hang for a while ; and switch the view to icons.

It can be fixed in the registry.

  • Open regedit
  • Navigate to HKEY_CLASSES_ROOT\.ts
  • Change the values similarly to the ones in .txt key :
    • (default) : txtfile
    • Content Type : text/plain
    • PerceivedType : text
  • Restart computer or VM
4

You can modify how Windows opens any file, with these steps (in this case, a TypeScript source code file):

  • Right click on the file (just open the context menu)
  • Click in Properties
  • You will see the properties configuration window (showing second section in the General tab):

    configuration window

  • Click in the Change... button

  • Then, select your preferred text/code editor or IDE

    enter image description here

  • In this case, I have selected Visual Studio Code:

    enter image description here

  • Click in OK, and that is all. Windows 10 will read all .ts files as source code files.

0

This is because a TS file is a type of video stream file. It's used to store video content on DVD and Blu-ray discs.

The solution is very simple

  1. Right click on typescript file
  2. Click on properties
  3. Click the change button and set this to Visual Studio Code

Click to see image

This will only change the file icon. If you have multiple files in the folder the folder icon should look like this

In this case

  1. Right click on the folder
  2. Click on properties
  3. Click on Customise Tab

Change the Optimise this folder for: option to Documents

Or

You can create desktop.ini file inside the folder and paste this code

[ViewState]
Mode=
Vid=
FolderType=Documents
0

Simple fix for windows:

  • Right click on typescript file
  • Click Open with
  • Choose another app (if win11)
  • Select Notepad or any text editor
  • Always/OK

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.