JetBrains Rider 2019.2 Help

JavaScript

With JetBrains Rider, you can develop modern web, mobile, and desktop applications with JavaScript and Node.js.

JetBrains Rider supports JavaScript and TypeScript programming languages, React and Angular frameworks and provides tight integration with various tools for web development.

To open an application that is organized in the directory structure and does not have a solution file, press Ctrl+O or choose File | Open | Open File or Folder... from the main menu, and then specify the root folder of the application.

Choosing the JavaScript language version

To get reliable and efficient coding assistance, you need to specify the language version that will be used in all JavaScript files of your application by default.

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | JavaScript. The JavaScript page opens.

  2. From the list, choose one of the supported JavaScript language versions:

Using multiple JavaScript versions

If you are working on an application that uses both ECMAScript 5.1 and a newer version of ECMAScript, or JSX, or Flow, the easiest way is to choose the highest language version for the whole project from the list on the JavaScript page. For example, if you use ES5.1 and JSX, enable JSX (since it is a superset of ES5.1 and ES6).

To configure different JavaScript language versions for different folders

  1. On the JavaScript page, click the Browse button next to the JavaScript language version list. The JavaScript Language Versions dialog opens.

  2. Click Add and in the dialog that opens select the folder where you need a custom language version. JetBrains Rider brings you back to the JavaScript Language Versions dialog where the selected folder is shown in the Path field.

  3. From the Language list, choose the language version for the files in the selected folder. In all the other JavaScript files in the project JetBrains Rider will use the version chosen on the JavaScript page.

    ws_js_choose_language_version.png

Downloading npm dependencies

Make sure you have Node.js on your computer. If your application uses some tools, libraries, or frameworks, download the required packages.

To install a package in an empty project

In the embedded Terminal Ctrl+Alt+1, type:

npm install <package name>.

If you already have a package.json file in your project

  • Right-click the package.json file in the editor or in the Project tool window and choose Run 'npm install' from the context menu.

  • Alternatively, run npm install in the Terminal Ctrl+Alt+1.

Configuring code completion for project dependencies

To provide code completion for project dependencies, JetBrains Rider automatically creates a node_modules library. In JetBrains Rider, a library is a file or a set of files whose functions and methods are added to JetBrains Rider's internal knowledge in addition to the functions and methods that JetBrains Rider retrieves from the project code that you edit. See Configuring JavaScript Libraries and Code Completion (IntelliSense) for details and examples.

Viewing parameter hints

Parameter hints show the names of parameters in methods and functions to make your code easier to read. By default, parameter hints are shown only for values that are literals or function expressions but not for named objects.

Parameter hints in JavaScript

To configure parameter hints

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to Editor | General | Appearance. The Appearance page opens.

  2. Click Configure next to the Show parameter name hint checkbox (the checkbox is selected by default).

  3. In the Configure Parameter Name Hints dialog that opens, select the Show name for all arguments checkbox in the Options area.

Auto import in JavaScript

JetBrains Rider can generate import statements for modules, classes, components, and any other symbols that are exported. If you are using ES6 in your project, JetBrains Rider can add missing import statements on the fly, when you complete ES6 symbols.

For earlier JavaScript versions or wheauto-importrt on completion is disabled, JetBrains Rider marks the symbol as unresolved and shows a tooltip:
ws_es6_autoimport_off_tooltip.png
On pressing Alt+Enter, JetBrains Rider displays the suggested quick-fix:
ws_es6_autoimport_off.png
If there's more than one possible source of import, JetBrains Rider shows a list of suggestions:
ws_js_import_quick_fix_multiple_choices.png

Learn more from Choosing the JavaScript language version.

To add ES6 import statements on code completion

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to Editor | General | Auto-import. The Auto Import page opens.

  2. In the TypeScript/JavaScript area, select the Add ES6 imports on code completion checkbox.

JetBrains Rider can also generate import statements for symbols defined in the project’s dependencies. Auto-import works for symbols from packages that contain TypeScript definition files (like in moment or redux) or sources written as ES modules.

Configuring syntax highlighting

You can configure JavaScript-aware syntax highlighting according to your preferences and habits.

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to Editor | Color Scheme | JavaScript.

  2. Select the color scheme, accept the highlighting settings inherited from defaults or customize them as described in Configuring Colors and Fonts.

Running JavaScript in browser

  1. In the editor, open the HTML file with the JavaScript reference. This HTML file does not necessarily have to be the one that implements the starting page of the application.

  2. Do one of the following:
    • Choose View | Open in Browser from the main menu or press Alt+F2. Then select the desired browser from the list.

    • Hover your mouse pointer over the code to show the browser icons bar: the bar with the icons of configured browsers Click the icon that indicates the desired browser.

Debugging JavaScript

JetBrains Rider provides a built-in debugger for your client-side JavaScript code that works with Chrome.
You can also debug your client-side JavaScript in Firefox, version 36 and later. However it is strongly recommended that you use Chrome or any other browser of the Chrome family. With JetBrains Rider, you can debug JavaScript applications running on the built-in server, on an external server, or on a remote server. For details, see Debugging JavaScript in Chrome and Debugging JavaScript in Firefox.

Last modified: 16 August 2019