Fix TypeScript with node shebang detected as JavaScript#7919
Fix TypeScript with node shebang detected as JavaScript#7919mondeja wants to merge 1 commit intogithub-linguist:mainfrom
Conversation
lildude
left a comment
There was a problem hiding this comment.
Please update the PR body to use the "I am adding a new extension to a language." part of the template and fill it in as if you're adding an extension.
The important part is we need real-world samples with their original filenames, and a link to the original source location and the license for legal reasons.
Please also update the test_find_by_interpreter test like in #7878 (the test wing pass until that PR is merged).
|
Since TypeScript is a clean superset of JavaScript, how will you identify a Node executable that ends in This is a can-of-worms we've dealt with before at Linguist… |
You can differentiate them by the extension of the file. If it's JavasScript you can put a .js extension to the file, but if the file becomes TypeScript you can rename to use a .ts extension. |
|
@mondeja And what about Node.js executables that don't have any file extensions? |
For a file without an extension containing the |
This is the very issue that's plagued Linguist's past attempts at getting Node.js executables containing TypeScript to be recognised as the latter. Both JavaScript and TypeScript's syntaxes are very similar, and heuristics that match dead-giveaways (like Also, does |
Yes. Starting with Node.js 23.6 ts files can be executed running
If there are bugs in linguist's classification logic we can fix them, of course. But that is out of the scope of this PR. |
Fixes #7348
Description
TypeScript files with .ts extension which include
"#!/usr/bin/env nodeor"#!/usr/bin/env nodeshebangs are misclassified as JavaScript files.Checklist:
I am adding a new extension to a language.
I am adding a new language.
#RRGGBBI am fixing a misclassified language
I am changing the source of a syntax highlighting grammar
I am updating a grammar submodule
I am adding new or changing current functionality
I am changing the color associated with a language