Closed adroste closed 1 year ago
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.
@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).
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.
You can use .tsx
even if you're not using JSX syntax. Think of it as the "TypeScript eXtension" if that helps π
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.
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.
Thanks for the statement. I just wanted to raise awareness that file extension ambiguity is a thing (and itβs annoying).
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.
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.
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.
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
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
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.
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?
+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.
Is it just too late for this extension violation (blunder) to be changed? is it like the www sub-domain misunderstanding from 1994?
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 betsx
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 π.
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 :)
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"
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.
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).
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
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:
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
Somewhat related issue: https://github.com/microsoft/TypeScript/issues/25945
β Viability Checklist
My suggestion meets these guidelines:
=> 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