How to resolve 'multiple UTIs, one file extension'

My PreviewCode app provides QuickLook previews and Finder icon thumbnails for source code files written in many popular programming languages.

The only one it doesn't work will with is TypeScript, which typically uses the ts file extension. This is because Apple's CoreTypes bundle maps the ts file extension to its own MPEG-4 Transport Stream UTI. Right now I have two UTIs mapped to the ts extension: the above one and another, com.microsoft.typescript.

The question is, how can I tell macOS' Launch Services to favour the latter over the former so that PreviewCode's previewer app extension is called whenever then user QuickLooks a TypeScript file and not (as currently happens) macOS' MPEG-4 previewer?

I'd like to code this into PreviewCode or at the very least provide the technique in the response to the many tech support requests I get about this ts mix-up specifically.

HI, I'm not sure if it's intended from the system to refuse relinquishing control of some filename-extensions, or not.
Me, I'm trying to get hold of the '.avi' filename-extension.
I suppose you noticed I used "filename-extension' rather than UTI.
From my understanding, it might be because the system's previewer plug-ins for those are in a legacy format o in the undocumented format "qldisplay".
I am deeply interested in understanding more of that, FYI I made an app to investigate extensions, initially dedicated to Quick Looks', it's 'PluginKits" and it's on my (Oil3) Github .

So far, the only thing I can advise is to have those ".ts" files instead saved as ".tsx", which only conforms like 'com.microsoft.typescript' and nothing of video.

I can change the file extension of my TypeScript files, you're right. But I can't expect my customers to do that too, especially when .ts is the de facto standard extension across all platforms.

There needs to be a mechanism (even if it's only a "defaults write...") whereby the QuickLook system can be told 'treat any .ts files as com.microsoft.typescript and preview accordingly'. I could then offer that to my customers as a config option and warn them that this might affect .ts MPEG files they have. But so far, I can't even offer any kind of choice or solution. It's very frustrating!

How to resolve 'multiple UTIs, one file extension'
 
 
Q