Tern: Intelligent JavaScript tooling Demo Docs Code

Tern is a stand-alone code-analysis engine for JavaScript. It is intended to be used with a code editor plugin to enhance the editor's support for intelligent JavaScript editing. Features provided are:

- Autocompletion on variables and properties
- Function argument hints
- Querying the type of an expression
- Finding the definition of something
- Automatic refactoring

Tern is open-source (MIT license), written in JavaScript, and capable of running both on node.js and in the browser.

## Editor plugins

There is currently Tern support for the following editors:

- Emacs
- Vim
- Sublime Text
- Brackets (built in to the base editor)
- Light Table
- Eclipse (and general Java API)

Follow the links to find instructions on how to install the plugins.

## Community and support

There is a discussion forum for questions and discussion around Tern. For announcements, such as new releases, there is a low-volume mailing list. For reporting bugs, I prefer that you use the github issue tracker.

Code contributions are welcome, preferably through pull requests.

If you are getting value out of Tern, especially if you are using it in a for-profit way, consider funding further development by setting up a monthly contribution. The maintainer (Marijn Haverbeke) is available for Tern-related consulting work.

Current funding status:

## Documentation

The reference manual should be your first stop for figuring out how to use Tern.

If you are interested in the way the system works internally, take a look at this blog post or the video of the talk I gave about it at the Curry On conference.

## Release history

27-10-2015: Version 0.16

- Support completion of imported names and package names from `package.json`
- Allow importing non-ES6 modules using `import foo from "bar"` syntax
- Fix several crashes
- Small improvements to the browser and ECMA6 definitions
- Full list of patches

02-09-2015: Version 0.15

- Fix crash bug triggered by string/number properties in object literals
- Fix other crash bug triggered by holes in arrays
- Support doc comments above classes and class methods
- Full list of patches

31-08-2015: Version 0.14

- Support for ECMAScript 6 constructs and standard library
  - Block scopes and let/const bindings
  - Destructuring and default values
  - Tuples/heterogenously typed arrays
  - Rest arguments
  - Generators
  - Symbols and symbol properties
  - For/of iteration
  - Classes and super calls
  - Extended object literal notation
  - Arrow functions
  - Template strings
  - All methods and types added by the ES6 spec
  - Improved existing support for Promises
- Overhauled module system for CommonJS modules, separated it from node plugin
- Add support for ES6 modules
- Plugins can now have dependencies. If your setup needs to explicitly load them, adjust accordingly
- The `node_exports` query type was renamed to `exports` (and works on ES6 modules)
- The `registerPlugin` interface was changed. The old style (returning an object) will be supported until 1.0
- Improved completion of module names in CommonJS and ES6 module context
- Phantom objects were added to support `foo.bar.baz = 10` if `foo.bar` doesn't have a type
- Fix broken handling of non-ASCII requests in the Emacs mode
- Full list of patches

28-07-2015: Version 0.13

- Parse input as ES6 (but ignore most ES6 constructs for now)
- Improved type inference for promises (as defined in the `ecma6` json file)
- Fix another source of exponential complexity blowup
- Complete module names in the requirejs plugin
- Improved type guessing for overridden properties
- Fix a bug in the Emacs mode that caused cursor jumping in some situations
- Full list of patches

25-06-2015: Version 0.12

- Fix another infinite recursion bug
- Rework doc comment stripping, allow passing `docFormat: "full"` in a query to receive full strings.
- Add a `preParse` hook that plugins can register.
- Prevent observed calls from 'polluting' union types from JSON definitions.
- Full list of patches

29-04-2015: Version 0.11

- Fix infinite recursion bug in type's `toString` methods
- Support `defineProperties`
- Full list of patches

25-03-2015: Version 0.10

- Fix a problem where the existence of an incompatible Acorn 1.0.0 on NPM breaks new installs
- Solve another infinitely-expanding-graph bug
- Rewrite type parser (for .json definitions) to be more predictable
- Full list of patches

02-03-2015: Version 0.9

- Add support for union types. The strings for types will now often contain `|` characters separating alternatives. Such types are also allowed in JSDoc comments.
- Add a rough `ecma6.json` type definition, which adds some new variables and properties from ES6. (note that this is still a far way off from real ES6 support.)
- Various small bugfixes (full list of patches)

13-01-2015: Version 0.8

- Support `@self` and `@typedef` in doc_comments plugin
- Improved purging of stale properties on file reload
- Much improved completion of properties in object literals
- Added `fullDocs` option to retrieve entire doc comment blocks
- Improved support for `defineProperty` and getter/setter properties
- Support deleting files through requests to the server
- Support `module` object in RequireJS's simplified CommonJS mode
- Various small bugfixes (full list of patches)

14-08-2014: Version 0.7

- Further refinements of the RequireJS plugin's path resolution
- Add `isKeyword` and `isProperty` fields to completion query JSON repsonses
- Various small bugfixes (full list of patches)

06-06-2014: Version 0.6.2

Small update release that fixes a crash affecting asynchronous loading of files.

06-06-2014: Version 0.6

- Solves overload from pulling in huge dependency trees
- Fixes various issues with stale information sticking around after file reload
- Add support for a `~/.tern-config` default config file
- Support a `timeout` field in requests, to limit their running time
- Make it possible to load plugins installed with `npm`
- Lots of small bugfixes (full list of patches)

10-10-2013: Version 0.5

- Improvements to the node plugin.
- Experimental Angular.js plugin.
- Rewrite of the `condense` tool, tests added.
- Better handling of “global” `this` in non-method calls.
- Support `Array.<content>` and `Object.<key,value>`-style types in the doc_comment plugin.

12-08-2013: Version 0.4

- Several fixes for exponential running time on some inputs.
- New IDO completion frontend for the Emacs mode.
- Add missing `buffer` and `timers` modules to node plugin.
- A few fixes to the `bin/condense` tool.

10-07-2013: Version 0.3

- Better `this` handling.
- Added underscore definition file.
- Improved dependency resolution in node plugin.
- `node_exports` query type added.
- Glob patterns in `loadEagerly`/`dontLoad` settings.

11-06-2013: Version 0.2

- Make the codebase Windows-safe.
- Improved handling of large codebases.
- Move comment parsing logic into a plugin (`doc_comment`).
- Many bugfixes.

03-05-2013: Version 0.1

First numbered release. Should be considered beta status, but useable enough to test.