1. There are two files ( 1.ts , 2.ts ) lying on the same level (next to each other).
    It works like this: import a from './2';
    And so no longer: import a from '2';

What is the reason? Do I need to specify additional parameters in tsconfig.js or if I compile via CLI? If so, which ones?

  1. How to import (using es2015-syntax) js-files? For example, I want to install lodash using npm and import it in a similar way: import _ from 'lodash'; How to do it?
  • judging by the help: if the .ts file, then the full path to it is needed, if .d.ts , then you can by name - Grundy

1 answer 1

The simplest solution would be:

  1. Use the package manager for TypeScript, such as Typings . Install globally: $ npm i typings -g .
  2. Install lodash locally (to the project folder): $ npm install lodash -D .
  3. Install the * .d.ts definition file using Typings:
    $ typings install lodash -D .
  4. In the 1.ts file, add a directive that will contain the path to the definition file: /// <reference path="typings/modules/lodash/index.d.ts" />
  5. Use the ES6 import syntax to connect the library:
    import * as _ from 'lodash';