ternjs / tern

A JavaScript code analyzer for deep, cross-editor language support
https://ternjs.net/
MIT License
4.25k stars 378 forks source link

Jump to definition of function in a library from ES6 file. #794

Open domi91c opened 8 years ago

domi91c commented 8 years ago

I have tern working well for functions and variables within a file, but I get "No definition found." when I try to jump to a function outside the current file.

Here's my .tern-config:

{
    "libs": [
        "browser",
        "jquery",
        "ecma5",
        "ecma6"
    ],
    "plugins": {
        "chai": {},
        "requirejs": {
            "baseURL": "./",
            "paths": {}
        }
    }
}

As an example, when my cursor is on DataSource, it should jump to the method DataSource within the 'react-native' node module.


import React, {Component} from 'react';
import * as Progress from 'react-native-progress';

import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Art,
  ListView,
  TouchableOpacity
} from 'react-native';

class MovieApp extends Component {
  constructor() {
    super();

    var ds = new ListView.**DataSource**({rowHasChanged: (r1, r2) => r1 !== r2});
   ...

I'm using ES6, and I'm not even sure if this works in ES5. So is this possible? Thanks for the help.

marijnh commented 8 years ago

You're using ES6 modules, so you should enable the es_modules plugin, and probably also the node_resolve one if you're relying on node's resolution rules to find libraries.