title: Angular 6 typescript integration with KotlinJs
body: <p>I have just managed to import Kotlin compiled javascript module in an angular 6 typescript file. It was not easy and the result confuses me. I wanna know if more elegant way exists.</p>
  
  <p>Originally I take a Kotlin file:</p>
  
  <pre><code>package com.example.test
  
  data class SomeInterface(
      var id: String? = null,
      var value: String? = null
  ) {
  }
  </code></pre>
  
  <p>It well compiles to the following JavaScript</p>
  
  <pre><code>(function (root, factory) {
    if (typeof define === 'function' &amp;&amp; define.amd)
      define(['exports', 'kotlin'], factory);
    else if (typeof exports === 'object')
      factory(module.exports, require('kotlin'));
    else {
      if (typeof kotlin === 'undefined') {
        throw new Error("Error loading module 'TestKotlinCompiled'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'TestKotlinCompiled'.");
      }
      root.TestKotlinCompiled = factory(typeof TestKotlinCompiled === 'undefined' ? {} : TestKotlinCompiled, kotlin);
    }
  }(this, function (_, Kotlin) {
    'use strict';
    var Kind_CLASS = Kotlin.Kind.CLASS;
    function SomeInterface(id, value) {
      if (id === void 0)
        id = null;
      if (value === void 0)
        value = null;
      this.id = id;
      this.value = value;
    }
    SomeInterface.$metadata$ = {
      kind: Kind_CLASS,
      simpleName: 'SomeInterface',
      interfaces: []
    };
    SomeInterface.prototype.component1 = function () {
      return this.id;
    };
    SomeInterface.prototype.component2 = function () {
      return this.value;
    };
    SomeInterface.prototype.copy_rkkr90$ = function (id, value) {
      return new SomeInterface(id === void 0 ? this.id : id, value === void 0 ? this.value : value);
    };
    SomeInterface.prototype.toString = function () {
      return 'SomeInterface(id=' + Kotlin.toString(this.id) + (', value=' + Kotlin.toString(this.value)) + ')';
    };
    SomeInterface.prototype.hashCode = function () {
      var result = 0;
      result = result * 31 + Kotlin.hashCode(this.id) | 0;
      result = result * 31 + Kotlin.hashCode(this.value) | 0;
      return result;
    };
    SomeInterface.prototype.equals = function (other) {
      return this === other || (other !== null &amp;&amp; (typeof other === 'object' &amp;&amp; (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) &amp;&amp; (Kotlin.equals(this.id, other.id) &amp;&amp; Kotlin.equals(this.value, other.value)))));
    };
    var package$com = _.com || (_.com = {});
    var package$example = package$com.example || (package$com.example =     {});
    var package$test = package$example.test || (package$example.test = {});
    package$test.SomeInterface = SomeInterface;
    Kotlin.defineModule('TestKotlinCompiled', _);
    return _;
  }));
  </code></pre>
  
  <p>In package.json I add <code>"kotlin": "^1.2.70",</code> to the dependencies section.
  In angular component I have to use such a code for import.</p>
  
  <pre><code>import * as TestKotlinCompiled from "../../generated/TestKotlinCompiled";
  
  // @ts-ignore
  const SomeInterface = TestKotlinCompiled.com.example.test.SomeInterface;
  // @ts-ignore
  type SomeInterface = TestKotlinCompiled.com.example.test.SomeInterface;
  </code></pre>
  
  <p>This is minimal mandatory code to use class <code>SomeInterfac</code> in the package <code>com.example.test</code> generated to the module <code>TestKotlinCompiled</code>.</p>
  
  <p>The problems here are following.</p>
  
  <p><code>// @ts-ignore</code> is required because at the compile time the ts-comiler does not see the content of the module being imported.</p>
  
  <p><code>const</code> is required for <code>new SomeInterface()</code></p>
  
  <p><code>type</code> is required for <code>let x: SomeInterface;</code></p>
  
  <p>All these look terribly hacky.
  I wold like something easier like 
  <code>import {SomeInterface} from '../../generated/TestKotlinCompiled' using namespace com.example.test</code> without <code>const</code> and <code>type</code>.
  So, is there a way to simplify my above code?</p>