<p dir="auto">I have a few files for making HTTP requests. I want to extend those to allow easier access to our API. Here is some sample code:</p>
<p dir="auto">http.ts</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export type HTTPParameters = { [key: string]: string };
export type HTTPHeaders = { [key: string]: string };
export enum HTTPMethod { Get, Head, Post, Put, ... };"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">type</span> <span class="pl-smi">HTTPParameters</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">key</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">string</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-k">type</span> <span class="pl-smi">HTTPHeaders</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span> <span class="pl-kos">[</span><span class="pl-s1">key</span>: <span class="pl-smi">string</span><span class="pl-kos">]</span>: <span class="pl-smi">string</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-k">enum</span> <span class="pl-smi">HTTPMethod</span> <span class="pl-kos">{</span> <span class="pl-c1">Get</span><span class="pl-kos">,</span> <span class="pl-c1">Head</span><span class="pl-kos">,</span> <span class="pl-c1">Post</span><span class="pl-kos">,</span> <span class="pl-c1">Put</span><span class="pl-kos">,</span> ... <span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">api.ts (-&gt;Arrows&lt;- point out where the errors are.)</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { HTTPParameters, HTTPHeaders, HTTPMethod } from './http.ts';

export type ApiParameters = HTTPParameters;
export type ApiHeaders = HTTPHeaders;

/* Try one */
export type ApiMethod = HTTPMethod;

export class Foo {
  constructor(public method: ApiRequestMethod = -&gt;ApiRequestMethod&lt;-.Get) {}
  // Cannot find name 'ApiRequestMethod'
}

/* Try two */
export var ApiMethod = HTTPMethod;

export class Foo {
  constructor(public method: -&gt;ApiRequestMethod&lt;- = ApiRequestMethod.Get) {}
  // Cannot find name 'ApiRequestMethod'
}

/* Try three */
export enum ApiRequestMethod -&gt;=&lt;- HTTPRequestMethod;
// Expected '{'

/* Try four */
export enum ApiRequestMethod -&gt;HTTPRequestMethod&lt;-;
// Expected '{'"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-smi">HTTPParameters</span><span class="pl-kos">,</span> <span class="pl-smi">HTTPHeaders</span><span class="pl-kos">,</span> <span class="pl-smi">HTTPMethod</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'./http.ts'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">type</span> <span class="pl-smi">ApiParameters</span> <span class="pl-c1">=</span> <span class="pl-smi">HTTPParameters</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-k">type</span> <span class="pl-smi">ApiHeaders</span> <span class="pl-c1">=</span> <span class="pl-smi">HTTPHeaders</span><span class="pl-kos">;</span>

<span class="pl-c">/* Try one */</span>
<span class="pl-k">export</span> <span class="pl-k">type</span> <span class="pl-smi">ApiMethod</span> <span class="pl-c1">=</span> <span class="pl-smi">HTTPMethod</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
  <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-k">public</span> <span class="pl-s1">method</span>: <span class="pl-smi">ApiRequestMethod</span> <span class="pl-c1">=</span> <span class="pl-c1">-</span><span class="pl-c1">&gt;</span><span class="pl-smi">ApiRequestMethod</span><span class="pl-c1">&lt;</span><span class="pl-c1">-</span><span class="pl-kos">.</span><span class="pl-smi">Get</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
  <span class="pl-c">// Cannot find name 'ApiRequestMethod'</span>
<span class="pl-kos">}</span>

<span class="pl-c">/* Try two */</span>
<span class="pl-k">export</span> <span class="pl-k">var</span> <span class="pl-smi">ApiMethod</span> <span class="pl-c1">=</span> <span class="pl-smi">HTTPMethod</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
  <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-k">public</span> <span class="pl-s1">method</span>: <span class="pl-c1">-</span><span class="pl-c1">&gt;</span><span class="pl-smi">ApiRequestMethod</span><span class="pl-c1">&lt;</span><span class="pl-c1">-</span> <span class="pl-c1">=</span> <span class="pl-smi">ApiRequestMethod</span><span class="pl-kos">.</span><span class="pl-c1">Get</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
  <span class="pl-c">// Cannot find name 'ApiRequestMethod'</span>
<span class="pl-kos">}</span>

<span class="pl-c">/* Try three */</span>
<span class="pl-s1">export</span> <span class="pl-k">enum</span> <span class="pl-smi">ApiRequestMethod</span> <span class="pl-c1">-</span><span class="pl-c1">&gt;=</span><span class="pl-c1">&lt;</span><span class="pl-c1">-</span> <span class="pl-smi">HTTPRequestMethod</span><span class="pl-kos">;</span>
<span class="pl-c">// Expected '{'</span>

<span class="pl-c">/* Try four */</span>
<span class="pl-s1">export</span> <span class="pl-k">enum</span> <span class="pl-smi">ApiRequestMethod</span> <span class="pl-c1">-</span><span class="pl-c1">&gt;</span><span class="pl-smi">HTTPRequestMethod</span><span class="pl-c1">&lt;</span><span class="pl-c1">-</span><span class="pl-s1"></span><span class="pl-kos">;</span>
<span class="pl-c">// Expected '{'</span></pre></div>
<p dir="auto">The actual working solution looks like this:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { SomeEnum as MyEnum } from './http.ts';

export { MyEnum };

export class Foo {
  constructor(public method: MyEnum = MyEnum.Get) {}
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-smi">SomeEnum</span> <span class="pl-k">as</span> <span class="pl-smi">MyEnum</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'./http.ts'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-kos">{</span> <span class="pl-smi">MyEnum</span> <span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-smi">Foo</span> <span class="pl-kos">{</span>
  <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-k">public</span> <span class="pl-s1">method</span>: <span class="pl-smi">MyEnum</span> <span class="pl-c1">=</span> <span class="pl-smi">MyEnum</span><span class="pl-kos">.</span><span class="pl-c1">Get</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">I might be missing something here, but if this is really the only solution, then it's pretty ugly and it would be nice to have something better.</p>
<p dir="auto">It seems to me, it's very inconvenient, that import declaration can't have none qualified symbol as target. By the reason I have to use next way to do this:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class S {}

export type SS = S;
export var SS = S;"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-smi">S</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>

<span class="pl-k">export</span> <span class="pl-k">type</span> <span class="pl-smi">SS</span> <span class="pl-c1">=</span> <span class="pl-smi">S</span><span class="pl-kos">;</span>
<span class="pl-k">export</span> <span class="pl-k">var</span> <span class="pl-smi">SS</span> <span class="pl-c1">=</span> <span class="pl-smi">S</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Maybe, removing the qualified name restriction will be more convenient than combination of type alias and var alias.</p>