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

Different ac behaviour on js and ts files #160

Open
LionyxML opened this issue Mar 22, 2022 · 4 comments
Open

Different ac behaviour on js and ts files #160

LionyxML opened this issue Mar 22, 2022 · 4 comments

Comments

@LionyxML
Copy link
Contributor

LionyxML commented Mar 22, 2022

Hello again! Sorry to spam you guys like this. :D

As I am more then happy editing a new .tsx / .ts project, but I happened to be maintaining some older JS code also.

And now emacs behaves differently. No auto complete and no docs over functions. I know VsCode made me spoiled by providing the same linting for both .js and .ts files, am I asking to much expecting it to behave the same?

Inside a .tsx file if I type console. I get the following suggestions:
image

The same if the file is a .ts:
image

But inside a .js (also jsx) file:
image

My modes:

Inside JS(X) files:

RJSX mode defined in ‘rjsx-mode.el’:
Major mode for editing JSX files.

Enabled minor modes: All-The-Icons-Completion All-The-Icons-Ibuffer
All-The-Icons-Ivy-Rich Auto-Composition Auto-Compression
Auto-Encryption Blink-Cursor Centaur-Tabs Column-Number Cursor-Sensor
Display-Line-Numbers Doom-Modeline Electric-Indent File-Name-Shadow
Flycheck Flycheck-Pos-Tip Font-Lock Git-Gutter Global-Auto-Complete
Global-Eldoc Global-Font-Lock Ivy Js2-Refactor Line-Number Mini-Frame
Mouse-Wheel Prettier-Js Shell-Dirtrack Smartparens Tooltip
Transient-Mark Treemacs-Filewatch Treemacs-Follow
Treemacs-Fringe-Indicator Treemacs-Git Xterm-Mouse Yas

Inside TS(X) files:

Web mode defined in ‘web-mode.el’:
Major mode for editing web templates.

Enabled minor modes: All-The-Icons-Completion All-The-Icons-Ibuffer
All-The-Icons-Ivy-Rich Auto-Complete Auto-Composition Auto-Compression
Auto-Encryption Blink-Cursor Centaur-Tabs Column-Number Company
Display-Line-Numbers Doom-Modeline Eldoc Electric-Indent
File-Name-Shadow Flycheck Flycheck-Pos-Tip Font-Lock Git-Gutter
Global-Auto-Complete Global-Eldoc Global-Font-Lock Ivy Line-Number
Mini-Frame Mouse-Wheel Prettier-Js Shell-Dirtrack Smartparens Tide
Tide-Hl-Identifier Tooltip Transient-Mark Treemacs-Filewatch
Treemacs-Follow Treemacs-Fringe-Indicator Treemacs-Git Xterm-Mouse

For comparison, on both js(x) and ts(x) inside VSCode:
image

@cowboyd
Copy link
Member

cowboyd commented Mar 28, 2022

@LionyxML We actually used tide for .ts and .tsx and js2-refactor-mode for js. But really, we should be using those for both. I just haven't gotten around to it because I don't really do much .js coding these days.

Would it be acceptable to put a jsconfig.json in your project, and typescript language server in your package dependencies?

https://github.com/ananthakumaran/tide#javascript

If so, we could see if that file exists, and then load tide in stead of a vanilla JS environment.

GitHub
Tide - TypeScript Interactive Development Environment for Emacs - GitHub - ananthakumaran/tide: Tide - TypeScript Interactive Development Environment for Emacs

@cowboyd
Copy link
Member

cowboyd commented Mar 28, 2022

Hello again! Sorry to spam you guys like this. :D

Oh, and no need to apologize ever. Really appreciate ways that this can be improved.

@LionyxML
Copy link
Contributor Author

Hello there!

I asked around about having a fallback for when jsconfig.json or tsconfig.json is not present into the directory, but I guess I am too dumb to understand the reason (lol).

In short. For projects I maintain, it is ok to do so. For projects I do not have any decision power, I will probably have to manage it locally.

I would love this feature, but I do not think it is for everyone (due to jsconfig mandatory presence), it might be some option to set in frontside custom-group.

Points to VSCode in this regard. If no config is present, it runs typescript in the background using its own defaults.

@cowboyd
Copy link
Member

cowboyd commented Mar 31, 2022

I asked around about having a fallback for when jsconfig.json or tsconfig.json is not present into the directory, but I guess I am too dumb to understand the reason (lol).

There are a couple of reasons.

  1. on javascript projects, generally, there is no dependency on typescript in package.json. As a result, you can't even start the tsserver because where is the actual js code to do so?
  2. without a jsconfig.json how can you know which typescript compiler options to use?

Maybe we can have defaults for these? Not sure how that could work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants