Autocomplete for Node.js (Probably Ternjs issue)


#1

Hi,

I’m using Atom Ternjs plugin for code intelligence and autocomplete.

Here’s my problem. When I “call” an external file rather than full module (from node_modules), I can’t access its properties. How can I fix it?

Note : I only included the changes I’ve made to my Node.js app.

io.js

var io = require('socket.io')();
module.exports = io;

bin/www

var io = require('../io');
io.attach(server);

app.js

var io = require('./io');

When I type io and put a dot, (io.) while I’m in app.js , it should recognize socketio and show me “on”, but it doesn’t. The same thing applies to emit (io.emit).


#2

There’s only so much static analysis (as I understand it, Tern.js is a static analysis tool) can do for a dynamically typed language like JavaScript. In order to know what require('socket.io')(); is returning, the code would have to be executed. That’s typically where static analysis tools draw the line :grinning: