Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Most features do not work in JS files with non-standard extensions #42

Closed
robertrossmann opened this issue Sep 21, 2017 · 9 comments
Closed

Comments

@robertrossmann
Copy link

Disclaimer: I have read and understood that this package consumes data from a language server and that this issue is probably related to that package. However, I have decided to open this issue here in order to provide feedback about this potentially broken functionality and also with hopes that someone more informed about the inner workings of the whole mechanism behind the IDE-like functionality will be able to pin-point where exactly the problem is. 😇

In my project, I use a different file extension (.es) than the standard .js for JavaScript files (these files are compiled with Babel into the same folder to .js files).

In these .es files, none of the IDE functionality seems to work except for the diagnostics:

  • function hinting (no autocomplete suggestions appear)
  • type/function info on hover (nothing shows up)
  • outline view (view is always empty)
  • hyperclick (nothing happens when cmd+clicking a symbol)

When opening the compiled .js file, all of these features work as expected, therefore I have come to conclusion that the cause must be related to the non-stnandard file extension.

I have also checked that the scope of the file is either source.js or source.js.jsx.

I should note that I am experiencing the same problem with the .mjs file extension which the Node.js community has decided to use for JavaScript ES Module files. Now that Node.js 8.5 includes experimental ES modules loader we can expect more and more people experiencing this problem.

Thank you for looking in this issue! Let me know if I can provide further information for troubleshooting/testing or help in other ways.

@bronson
Copy link

bronson commented Sep 21, 2017

Just checking, you added the extensions in your config.cson? http://flight-manual.atom.io/using-atom/sections/basic-customization/#customizing-language-recognition

@damieng
Copy link
Contributor

damieng commented Sep 21, 2017

It's worth a try although given the typescript server is going to chose typescript for .ts and javascript for .js I have no idea what it's going to make of .es files

@robertrossmann
Copy link
Author

@bronson Nope it was not there and adding it did not help. I use language-babel package which recognises these extensions automatically.

@damieng Looks like it can't make anything of them. 😞 If there's some "debugging" knob on the typescript server I can turn on let me know if that would help!

@robertrossmann
Copy link
Author

I understand this is likely a problem in the language server itself, however if someone more knowledgeable were to try to dig deeper into this I have managed to capture an error which seems to indicate that the language server is refusing to "locate" the currently-worked-on file when triggering datatips with the following error:

"Error: Unknown text document file:///Users/BeBe/Dropbox/Repositories/strv/iooi-api/src/actions/emails/index.mjs
    at new ResponseError (/Users/BeBe/.atom/packages/ide-css/node_modules/vscode-jsonrpc/lib/messages.js:46:28)
    at handleResponse (/Users/BeBe/.atom/packages/ide-typescript/node_modules/vscode-jsonrpc/lib/main.js:430:48)
    at processMessageQueue (/Users/BeBe/.atom/packages/ide-typescript/node_modules/vscode-jsonrpc/lib/main.js:258:17)
    at Immediate.<anonymous> (/Users/BeBe/.atom/packages/ide-typescript/node_modules/vscode-jsonrpc/lib/main.js:242:13)
    at runCallback (timers.js:651:20)
    at tryOnImmediate (timers.js:624:5)
    at processImmediate [as _immediateCallback] (timers.js:596:5)"

which seems to further indicate that the language server is not considering non-.js files at all. I know not where to go next to troubleshoot this - any advice is much appreciated!

The whole error object caught:

{
  "message":"Unknown text document file:///Users/BeBe/Dropbox/Repositories/strv/iooi-api/src/actions/emails/index.mjs",
  "code":-32001,
  "data":{}
}

@damieng
Copy link
Contributor

damieng commented Nov 28, 2017

Does that file exist on disk? What language is it written in?

@robertrossmann
Copy link
Author

robertrossmann commented Nov 28, 2017

Yes, the file definitely exists - it is the current file opened in the editor - I double-checked the path and it's a match. The extension is .mjs, which is the Node's ES modules extension (JavaScript).

@damieng
Copy link
Contributor

damieng commented Nov 28, 2017

We're at the mercy of the Typescript server here. Unless microsoft/TypeScript#15416 changes position ide-typescript is only ever going to work with .js files.

The only other option would be to create an ide-javascript package based on a pure Javascript language server. Alas no such thing exists right now and it is a large undertaking even basing it on esprima or babel's babylon ast parser.

@damieng
Copy link
Contributor

damieng commented Nov 28, 2017

I'm going to close this issue as there's nothing we can do unless Microsoft's position on this changes or somebody makes a javascript language server.

@damieng damieng closed this as completed Nov 28, 2017
@robertrossmann
Copy link
Author

Good find on that issue! Thanks for pointing that out - I'll go bash on Microsoft's door 😡.

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

No branches or pull requests

3 participants