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

extension-less shebang scripts should be interpreted as TypeScript by default #9063

Closed
zhangyuannie opened this issue Jan 9, 2021 · 3 comments
Labels
cli related to cli/ dir suggestion suggestions for new features (yet to be agreed)

Comments

@zhangyuannie
Copy link
Contributor

From #929 and #1226, I believe that the intended behaviour is that extension-less shebang scripts are seen as TypeScript files, but that does not seems to be the case?

Minimal example:

#!/usr/bin/env -S deno run --allow-all
// filename: hi
interface Foo {
  bar: string;
}
console.log("Hi");

Running ./hi or deno run hi yields error: Unexpected token `interface`.

@caspervonb
Copy link
Contributor

Duplicate of #5088

@zhangyuannie
Copy link
Contributor Author

Duplicate of #5088

Thank you. Sorry for being unclear.

I guess it is more about the default behaviour here: extension-less shebang scripts should be interpreted as TypeScript by default instead of JavaScript.

I'm fine closing this if we don't wish to change that.

@zhangyuannie zhangyuannie changed the title extension-less shebang scripts can not be written in TypeScript extension-less shebang scripts should be interpreted as TypeScript by default Jan 26, 2021
@kitsonk kitsonk added cli related to cli/ dir suggestion suggestions for new features (yet to be agreed) labels Jan 27, 2021
@kitsonk
Copy link
Contributor

kitsonk commented Jan 27, 2021

I believe #5088 is a better solution/suggestion. Ideally we want to treat JavaScript and TypeScript equally. Technically it isn't a duplicate. I don't think we would consider this suggestion though as it would have significant breaking changes. We interpret TypeScript in strict mode, this means a lot of plain JavaScript would simply error out, which would be a bad experience for those already taking advantage of the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

No branches or pull requests

3 participants