PhpStorm 2017.2 Help

TypeScript

PhpStorm supports developing and running TypeScript source code. PhpStorm recognizes *.ts files and provides full range of coding assistance for editing them without any additional steps from your side. TypeScript files are marked with the /help/img/idea/2017.2/ac_iconFileType_TypeScript.png icon.

On this page:

TypeScript-aware coding assistance

Parameter hints and type information

Parameter hints show the names of parameters in methods and functions to make your code easier to read. To see the inferred type for an object, hold on macOS or Ctrl on Windows and Linux and hover the mouse pointer over it:

ws_typescript_parameter_hints

By default parameter hints are shown only for values that are literals or function expressions but not for named objects.
To show parameter hints for all arguments

  1. Open the Appearance page (File | Settings | Editor | General | Appearance for Windows and Linux or PhpStorm | Preferences | Editor | General | Appearance for macOS).
  2. Click Configure next to the Show parameter name hint check box (the check box is selected by default).
  3. In the Configure Parameter Name Hints dialog that opens, select the Show name for all arguments check box in the Options area.

Configuring TypeScript coding assistance

TypeScript-specific coding assistance can be provided either by PhpStorm itself or based on the data from the TypeScript Language Service.

To configure coding assistance for TypeScript

  1. Open the TypeScript page (File | Settings | Languages and Frameworks | TypeScript for Windows and Linux or PhpStorm | Preferences | Languages and Frameworks | TypeScript for macOS).
  2. Select the Use TypeScript Service check box to get native support from the TypeScript Language Service according to the up-to-date specifications. As a result:
    • Syntax and error highlighting is based on the annotations from the TypeScript Language Service.
    • Completion lists contain both suggestions from the TypeScript Language Service and suggestions calculated by PhpStorm. To get only suggestions from PhpStorm, click Configure and clear the Code completion check box in the Service Options dialog that opens.
  3. In the Default options field, specify the command line options to be passed to the compiler when the tsconfig.json file is not found. See the list of acceptable options at TSC arguments. Note that the -w or --watch (Watch input files) option is irrelevant.

Common and TypeScript-specific refactoring

  • Common refactoring procedures, such as extract method, inline, rename/move, etc.
  • TypeScript-specific refactoring procedures, such as change signature, extract parameter, extract variable.

See also Refactoring Source Code and Refactoring JavaScript.

Code generation

  • Generating code stubs based on file templates during file creation.
  • Ability to create line and block comments (Ctrl+Slash/Ctrl+Shift+Slash).
  • Generating import statements for modules, classes, and any other symbols that can be exported and called as a type, see Importing TypeScript Symbols.
  • Configuring automatic insertion or skipping the public access modifier in generated code.

Learn more from Generating Code.

Compilation into JavaScript

Compiling TypeScript into JavaScript for further running, debugging, and testing, see Compiling TypeScript to JavaScript for details.

See Also

Language and Framework-Specific Guidelines:

Last modified: 21 August 2017