Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Huge] Alternative File-Type extension for typescript files (.ts = mpeg-2 video) #47611

Closed
5 tasks done
adroste opened this issue Jan 26, 2022 · 28 comments
Closed
5 tasks done
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript

Comments

@adroste
Copy link

adroste commented Jan 26, 2022

Suggestion

Huge request. One thing that I don't like about typescript is the file extension itself. ".ts" was already reserved for mpeg-2 video long before anyone thought about shipping JS apps with the complexity we see today.
This causes a lot of problems:

  • backup tools consider them as videos and handle them differently
  • nearly every file management/operation tool think it's a video (file recovery, search, remote access, ...)
  • file explorers think it's a video (tested on windows and macOS)
  • file patterns (e.g. web servers, custom apps) that are not optimised for the existence of typescript send typescript files with wrong mime type or apply the wrong handling per default <=> again changing this manually breaks handling of actual video files
  • even vscode is confused (see Code Helper attempts to index MPEG-TS files in project and eats 100% cpu #21136)

I think giving typescript the extension ".ts" was a mistake.
As there is just no simple solution, we could introduce an alternative file extension like ".reallynotavideo", ".tscript", ".tsc", ... (I really don't care).

🔍 Search Terms

  • video
  • mpeg-2

Somewhat related issue: #25945

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

=> However, it would still be a breaking change and could also require a lot of reconfiguration (e.g. file-patterns).

⭐ Suggestion

Introduce an "official" alternative file extension that can be used ootb for typescript files (e.g. ".tsc", ".tscript", ...).

📃 Motivating Example

See above

💻 Use Cases

See above

@nmain
Copy link

nmain commented Jan 26, 2022

How does an alternative file extension benefit you? If you're consuming other people's work that uses the normal extension, you'll still have the same issues.

@adroste
Copy link
Author

adroste commented Jan 26, 2022

@nmain True, to really fix this problem the whole community must adopt a new file extension. I just don't understand why they went with .ts in the first place. This is a huge problem as a file extension should tell the system or other software what the file is about. Confusing one text format with another is not that bad but creating ambiguity between a common media/video format and a code-file is (see linked issues above).

@MartinJohns
Copy link
Contributor

This is a huge problem as a file extension should tell the system or other software what the file is about.

I can count the amount of times I encountered .ts mpeg files on one hand. Haven't heard of anyone struggling with this either. I would say this problem is rather niche, definitely not huge.

@RyanCavanaugh
Copy link
Member

You can use .tsx even if you're not using JSX syntax. Think of it as the "TypeScript eXtension" if that helps 😉

@RyanCavanaugh RyanCavanaugh added Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript labels Jan 26, 2022
@adroste
Copy link
Author

adroste commented Jan 26, 2022

While using tsx is definitely an option to circumvent the problems mentioned above it breaks semantic consistency. Using tsx in a context without jsx-elements will certainly lead to confusion when sharing code as the assumption is: tsx will contain jsx elements so it‘s probably code for the view.

Edit: Additionally, tsx is not a superset of ts which means that renaming ts files to tsx could be a breaking change. Unlikely because I‘m talking about edge cases but possible.

@RyanCavanaugh
Copy link
Member

If it makes you feel any better, even if we did add a brand new file extension (which we won't), we'd almost certainly eschew the ts/tsx distinction and just have it only be tsx grammar. The <T>expr syntax has largely fallen out of favor.

@adroste
Copy link
Author

adroste commented Jan 26, 2022

Thanks for the statement. I just wanted to raise awareness that file extension ambiguity is a thing (and it‘s annoying).

@fatcerberus
Copy link

fatcerberus commented Jan 27, 2022

This isn't a huge problem day-to-day, but it can cause problems when opening a folder full of .ts files in Windows Explorer - the file manager thinks they're all video files, puts the folder in thumbnail view, and then often spends several seconds trying to load their thumbnails, during which time the Explorer window is unresponsive. Sometimes it even crashes. It can be fixed by switching the folder to Details view, but that setting isn't always remembered.

macOS Finder sometimes stumbles in the same way.

@nmain
Copy link

nmain commented Jan 27, 2022

I feel a lot of the blame is on the file explorer applications here: If you're going to make something that implicitly opens every single file and scans every single one of them for content, it has to be bulletproof for both performance concerns and security concerns. File explorers should be incapable of crashing or performing slowly regardless of the inputs.

@fatcerberus
Copy link

If you're going to make something that implicitly opens every single file and scans every single one of them for content, it has to be bulletproof for both performance concerns and security concerns. File explorers should be incapable of crashing or performing slowly regardless of the inputs.

I definitely agree, but sadly we don't live in a perfect world. 😞 That being said, I was a bit surprised to find out that Finder was affected by this, since I always thought macOS used file content to determine the types of files in addition to their extensions.

@jackpunt
Copy link

Cost me a few hours wondering why MacOS Spotlight finds text in [compiled] .js files but not in [source] .ts files.
And there's no way to tell Spotlight to override/disable the mpeg interpretation of the '.ts' extension.

Can you say what potential conflict from renaming my *.ts -> *.tsx?
Where/How does the expr syntax apply?

@berniegp
Copy link

I was quite annoyed by Windows explorer's sluggishness with .ts and .d.ts files and found a solution that involves remapping their "file kind" to document instead of video.

More info here: https://superuser.com/questions/1304114/windows-explorer-hangs-creating-thumbnails-for-typescript-files/1733384#1733384

@pouriap
Copy link

pouriap commented Sep 15, 2022

I fully agree.
I also have a huge problem with this because I have to choose whether to associate .ts files with a text editor or a video player. And 'open with' is not an option when dealing with archives, etc. I don't know why they would pick an extension that is already in use by another file type. It is unprofessional and extremely annoying.

@NPhGit
Copy link

NPhGit commented Nov 3, 2022

Just to voice my agreement. I understand that some people rarely encounter .ts media. But it's not rarely used as you think. ts files used a lot via internet stream. It flows like water when you view something via browser. So people who work with video/keep them will often face the drawback.
I know how to set .ts as text but given I have ten thousands of ts media in my pc. It's really inconvenient to not see thumbnail of media, a huge tradeoff. This is a reason I completely avoid typescript for my personal project. If I use it, I will face day-to-day problem.
I understand why some feel it niche though. A lot of my colleagues completely not program outside work hours. Their own computer (no programming) can see it as media. And office's as text.

Can explorer/finder try to smart? maybe. But we all know name check(extension) is a lot cheaper than bom check or both. That's why it's born. It's the same if some weird guy use exe/jpg/mp4 as other file type, or even byte mark. How smart and overhead it need to spend?

@DaveyJake
Copy link

+1

I would also like to see something done that doesn't involve renaming .ts to .tsx. .tsc seems like it would be the ideal extension name as well as a HUGE help, especially in regards to CPUs hitting 100% in VSCode.

@mattcph
Copy link

mattcph commented Mar 14, 2023

Is it just too late for this extension violation (blunder) to be changed? is it like the www sub-domain misunderstanding from 1994?

@adroste
Copy link
Author

adroste commented Mar 14, 2023

This already got the label declined from @RyanCavanaugh a year ago. I think a 'no' is not a great answer here tbh.
The web-dev world is changing super fast. Improvements can always be made. Would like to see this considered again.

even if we did add a brand new file extension (which we won't), we'd almost certainly eschew the ts/tsx distinction and just have it only be tsx grammar.

Making and promoting tsx as the default would definitely be one possible solution. What holds you back?

If you compare it with Word, .doc is the legacy format and .docx is the new one. Let's be consistent, Microsoft 😉.

@ritschwumm
Copy link

ritschwumm commented Mar 15, 2023

i think the problem goes much deeper: metadata meant for consumption by the OS should not be part of the file name - the file name should cater for human users, and only them. other operating systems like mac os classic and amiga os got this right, it's just windows that didn't...

@adroste maybe we should ask microsoft what's holding them back :)

@RyanCavanaugh
Copy link
Member

I don't know what anyone expects us to do here beyond what's already available. There are 10 years of TypeScript files out there; we can't unring that bell. You can write .tsx, .mts, or .cts depending on what you're doing. It's extremely realistic to switch your code over to those extensions today, and unrealistic to expect everyone else in the world to rename their files because you somehow have actual real transport stream files as part of your daily routine.

I tried to write a .reg file to completely unassociated .ts from video, but only got this far before giving up (this stuff is pretty buried these days). Anyone able to make it work faster than just choosing "Open With" -> VS Code -> Always?

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.ts]
@=-
"Content Type"=-
"PerceivedType"="text"

[-HKEY_CLASSES_ROOT\.ts\OpenWithProgids]
[-HKEY_CLASSES_ROOT\.ts\ShellEx]

[HKEY_CLASSES_ROOT\.ts\OpenWithProgids]
"VSCode.ts"=""

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.TS\OpenWithProgids]
"WMP11.AssocFile.TTS"=-

[HKEY_CLASSES_ROOT\Applications\wmplayer.exe\SupportedTypes]
".ts"=-

[-HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\PackageRepository\Extensions\windows.fileTypeAssociation\.ts]

[-HKEY_CLASSES_ROOT\SystemFileAssociations\.ts]

[HKEY_CURRENT_USER\Software\Classes\.ts\OpenWithProgids]
"VSCode.ts"=""

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.TS\OpenWithList]
"a"="Code.exe"
"MRUList"="a"

@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2023
@kkirby
Copy link

kkirby commented Apr 5, 2023

You can write .tsx, .mts, or .cts

For the record, .mts is also reserved for video files. And .cts is falling out of favor. My only issue with using .tsx is that its reserved for React and can be confusing if your app doesn't use React. Plus, TypeScript will do additional, unnecessary parsing if you use .tsx.

I'm in favor of switching to .tsc and .tscx. You can keep .ts and .tsx as legacy extensions and still support them.

edit

Also, we shouldn't fall into the sunken cost fallacy here. It's okay that the mistake was made to use .ts, but just because there's 10 years of code out there doesn't mean we shouldn't fix it. It's not too late.

@gabrielgortabns
Copy link

gabrielgortabns commented Oct 10, 2023

MS Teams always treat TS files as video, and it shows error when it contains text. I also meet with issues regarding .ts extension a lot of times everywhere, where I look (even windows explorer still has issues with .ts files).

@0GHatMak3r
Copy link

0GHatMak3r commented Jan 10, 2024

Haven't heard of anyone struggling with this either. I would say this problem is rather niche, definitely not huge.

I am, it keeps showing up in my gallery app

@QA-Anant
Copy link

Do we have any generic workaround this issue. It has literally stopped my progress on working on a typescript project all of a sudden.

@cjens19
Copy link

cjens19 commented Jan 17, 2025

Do we have any generic workaround this issue. It has literally stopped my progress on working on a typescript project all of a sudden.

Looks like we arrived here at this closed post for the same reasons today. I too have just noticed some weirdness while working on my angular project in webstorm. Changes I was making in my IDE were not being saved to the file system so git was not seeing my changes. Went to just edit my .ts files in notepad to see if my IDE changes were there and saw that all my .ts files are being seen as type 'WMP11.AssocFile.TTS'.

Still looking around online for how to correct this. I did install the Win 11 24H2 update last night, and it borked my work VPN so I rolled back to the previous build. Not sure if that's the cause of this new issue for me, but it's worth mentioning. I've been working on this same project for 18 months now and just today have seen this issue. Very strange. Best of luck!

@RyanCavanaugh
Copy link
Member

Most modern code targets either explicitly ESM or CJS, so you can use .mts or .cts file extensions respectively instead.

@QA-Anant
Copy link

A quick update on the issue being faced. I did a complete uninstallation of nodejs and npm packages from my machine and reinstalled the packages and this time I used homebrew command to do the installation part. And for some reason I was able to again edit and save my typescript files normally without any issues. Posting this message after 2 days of playaround and I am not facing any issue untill now. PS : make sure all the relevant directories are deleted from your global and local scopes for the nodejs and npm and things should start working again without needing to change the extension of your files. However, my quicklook or finder app ( I am on a Mac machine, OS version : sonoma ) still shows the .ts files as video files but it is not bothering me much. Hope this helps someone who is looking out for a quick workaround.

@nanaya
Copy link

nanaya commented Jan 22, 2025

Most modern code targets either explicitly ESM or CJS, so you can use .mts or .cts file extensions respectively instead.

.mts is already used for another video related file (a lot less common for me but it's registered as video file by windows media player).

@RyanCavanaugh
Copy link
Member

Dunno what to say folks, 26^3 is only 17,576, and there are 8 billion people on Earth with lots of ideas on file formats. Eventually someone is going to have to configure their system on setup, and that person is us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests