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)
- TextMate
- SourceLair (built in to the base editor)
- Chocolat (built in to the base editor)

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.

## 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

13-10-2019: Version 0.24.2

Small update release that fixes crashes when writgin catch clause

10-07-2019: Version 0.24.1

Small update release that fixes crashes when using doc_comment plugin

30-05-2019: Version 0.24

- Make bootstrapping of a Tern server easiert .
- Support complete string property name in object notation.
- Update def files for Date, DOM Node ...
- More robust JSDoc handler
- Fix bug where condense codes with spread operator.
- Fix bug where rename cause object property also affected.

10-11-2018: Version 0.23

- Upgrade Acorn to version 6.
- Fix some crash issues caused by ECMAScript 6 syntax.
- Update React definition.
- Add Clipboard API to browser definition.

27-09-2018: Version 0.22.3

Small update release that fixes crashes affecting spread operator in object notation, rest operator in object pattern and export default anonymous class or function.

28-08-2018: Version 0.22

- Support async functions and async iteration.
- Make the base type definitions match the current standards.
- Make sure dynamic properties don't show up when completing object literal property names.
- Pre-emptively start analyzing on startup.
- Fix bug where renaming a variable might rename properties in the code.

18-02-2017: Version 0.21

- Support JSDoc-style object property docs in `doc_comments` plugin.
- Various fixes and completions in the type definitions.
- Fix bug where server self-resets left old state on AST.
- Improve and document the `webpack` plugin.
- Fix issue where file offsets were interpreted wrong when the file contained astral plane characters.

16-08-2016: Version 0.20

- Breaking: The `ecma5.json` and `ecma6.json` definition files were combined into `ecmascript.json`. If you are explicitly loading these, for example in a web page, you'll have to update your filenames.
- Improved the typing of `Promise.resolve` calls
- Support webpack config files in the webpack plugin
- Make the Emacs mode mode robust when files are renamed
- New option `inLiteral` in the JSON protocol to turn off completions inside string/regexp literals
- Define the ECMA7 `Array.includes` method

11-07-2016: Version 0.19

- Breaking: Drops the `from_ts` utility
- New command line flag: `--ignore-stdin` to not exit when stdin is closed
- Fix another crash related to omitted array elements
- Improve handling of shorthand object properties during rename

15-03-2016: Version 0.18

- Improve typing of `this` bindings in arrow functions
- Fix crash when fetching the type of a module without known type
- Fix bug in scoping of renames, which erroneously included the scope's function name
- Full list of patches

04-01-2016: Version 0.17

- Support `@class` and `@constructor` JSDoc directives
- Improve completion and finding of module exports and methods
- Server objects now have a `deleteDefs` method
- New plugin: webpack
- Full list of patches

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
- 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 rough ECMAScript 6 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.