-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Update list of TypeScript/JavaScript interpreters #4470
Conversation
@Alhadis Could you add a sample file with that interpreter? If we remove the |
@pchaigno Couldn't we just |
Oh, right, it's a fixture one, so yes! |
I Deno if it was intentional or not, but the name "Deno" is an anagram of "Node". 😁 |
I'm not sure if that fixture makes sense for Deno. It's true that Deno is a TypeScript interpreter, but it does not have the same "core library" API as node, as far as i know. So things like call to |
This is a fixture file, it's only used for regression tests. The contents of |
@Alhadis ah, my mistake, sorry and thanks for explanation :). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Alhadis Could you also remove the node interpreter from TypeScript?
@pchaigno Done. 👍 |
@pchaigno Think now would be a good time to add other JS interpreters that we're missing?
Nothing "special" to any of these, they're just regular JS interpreters the same way Node.Js is. |
@@ -1,4 +1,4 @@ | |||
#!/usr/bin/env node | |||
#!/usr/bin/env deno |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is not valid in Deno. (mostly due to imports)
- Deno is not Node so you can not import packages like 'fs'
- The file extension is important (
./x.ts
is valid but./x
is not) - Deno does not use NPM, so
import * as tsickle from 'tsickle';
is not right
etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pchaigno Could we get away with using a "Hello, world" type script for the TypeScript/JavaScript hashbang fixtures? I mean, the content of the script is kind of irrelevant after all...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but if it's not too difficult to find a sample Deno file, it's even better. It'd help train the classifier to recognize the few differences of Deno.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. Well, when I substitute the contents of test/fixtures/TypeScript/main
for this TypeScript program, the tests fail, complaining that it identified as JavaScript. 😞
Do you think a heuristic is in order? Accurately differentiating TypeScript from JavaScript is impossible without a LOT of hairy regexes, but matching from "[^"]+\.ts"
should work, since Node doesn't grok that extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed my update. Have a look at the test feedback, I'm not really sure what's going on... 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure what's going on... 😢
You do 😉 ...
Accurately differentiating TypeScript from JavaScript is impossible without a LOT of hairy regexes
You've added deno
to both JS and TS so things will fall through to heuristics and then the classifier and as there isn't a heuristic we're falling through to the classifier which due to the similarities of JS and TS has guessed this is JS not TS:
$ LINGUIST_DEBUG=1 bundle exec bin/github-linguist test/fixtures/TypeScript/main
main: 66 lines (55 sloc)
type: Text
mime type: text/plain
JavaScript = -1455.108 + -4.009 = -1459.117
TypeScript = -1591.191 + -5.727 = -1596.918
language: JavaScript
appears to be a vendored file
$
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hold up. I thought the point of these fixtures was to assert that the interpreter directives were recognisable?
Not gonna lie, the tests are completely and utterly opaque to me. 😢 Really not familiar with unit-testing in Ruby, but this is what I'm used to reading.
so things will fall through to heuristics and then the classifier and as there isn't a heuristic we're falling through to the classifier which due to the similarities of JS and TS has guessed this is JS not TS:
Alrighty, sooo... the only sane solution is to remove Deno as a JavaScript interpreter. Which is okay, really, because TypeScript interpreters can compile JS, just not the other way around. 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's my fault for thinking too much about file extensions being tested before heuristics... of course, hashbangs are most relevant in files that don't have any extensions.
I'm an idiot, sorry. Deno's been pushed back into TypeScript-land. 👍 Hopefully the specs will pass now...
Note that this is now blocking another TypeScript-related PR. Any chance we could get this wrapped up? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Not sure if @pchaigno has any final comments or thoughts though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@ahwayakchih's mention of Deno in #4469 reminded me that we haven't added it yet as a TypeScript/JavaScript interpreter, so here it is. Deno is a newer JavaScript runtime which has already gained traction for being a novel alternative to Node.js. It supports TypeScript out-of-the-box, making it a "true" dual JS/TS interpreter.
Template removed as it doesn't apply.
UPDATE: This PR's been updated to remove
node
from TypeScript's interpreters list as well, following conversation between @pchaigno and @grant. Merging this PR will now also fix #4469.