atom / ide-typescript

TypeScript and Javascript language support for Atom-IDE
MIT License
368 stars 63 forks source link

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

Closed robertrossmann closed 6 years ago

robertrossmann commented 7 years ago

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:

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 commented 7 years ago

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

damieng commented 7 years ago

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 commented 7 years ago

@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 commented 6 years ago

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 commented 6 years ago

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

robertrossmann commented 6 years ago

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 commented 6 years ago

We're at the mercy of the Typescript server here. Unless https://github.com/Microsoft/TypeScript/issues/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 commented 6 years ago

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.

robertrossmann commented 6 years ago

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