zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
47.36k stars 2.75k forks source link

Typescript file with NodeJS shebang gets detected as Javascript #13981

Open ewen-lbh opened 2 months ago

ewen-lbh commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I'm building a CLI with Typescript, but the resulting transpiled JS files will have to be executed by Node.

Shebang language detection is a feature (as per https://github.com/zed-industries/zed/issues/6089), but in that case it leaves me with plenty of linter errors and no autocompletion '^^

I'd argue that special-casing .ts file that have a javascript-matching shebang as typescript files would be the solution

Environment

Zed: v0.142.6 (Zed) OS: Linux Wayland endeavouros unknown Memory: 15.6 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

No response

osiewicz commented 2 months ago

Hey, thanks for filling out this issue. For what it's worth, we always treat files with node shebang as JS files; see: https://github.com/zed-industries/zed/blob/main/crates/languages/src/javascript/config.toml#L4 I wonder if it's as easy as adding the same detection in TS config.toml (that currently doesn't specify any shebang: https://github.com/zed-industries/zed/blob/main/crates/languages/src/typescript/config.toml).

Tobbe commented 3 weeks ago

I came here to report this same issue. Is there anything I can do to help move this forward?

Tobbe commented 1 week ago

Ran into this again. The workaround is to manually switch to TypeScript (by clicking the language selector down in the bottom right corner) and then restarting the language server.