Is it possible to define a type (string literal union) within a class in TypeScript?
<p>In TypeScript 1.8, they added a new type called a "string literal type" which lets you declare a type that can only be one of a set of finite values. The example that they give is:</p>

<pre><code>type Easing = "ease-in" | "ease-out" | "ease-in-out";
</code></pre>

<p>But, in all their examples, the type is either defined <em>outside</em> of the class that it is used in or defined inline without an alias. As explained (fairly tersely) in the answers to <a href="https://stackoverflow.com/questions/33436192/what-is-the-scope-of-a-type-alias">this question</a>, type alias declarations are scoped to their containing module.</p>

<p>In my project, I would like to define type aliases for string literals that are paired with specific classes and used in multiple places. Because of the structure of the APIs that I am consuming, there are multiple classes which each have properties of the same name but different potential values. I'd like to keep my code neat and not have a bunch of global type declarations with prefixes (<code>MyClassAPropertyValue</code>, <code>MyClassBPropertyValue</code>, etc.) if I can help it.</p>

<p><strong>So, is there any way to declare a <code>type</code> within class scope (preferably so that it is consumable from external modules)?</strong> If not, is there a close substitute or planned feature that will fill this use case?</p>

<hr>

<p>Use case:</p>

<p>Suppose I have two classes that wrap my underlying API data. Each class represents different data, they just happen to have some properties with the same name. I want a way of defining properties like so:</p>

<pre><code>export class APIObjectA {
    // Valid values in APIObjectA
    public type Property1Value = "possible_value_A" | "possible_value_B";
    public type Property2Value = "possible_value_C" | "possible_value_D";

    // Here, "Property1Value" refers to the version in APIObjectA
    public get property1(): Property1Value {
        // Return value of property1 from underlying API data
    }

    public get property2(): Property2Value {
        // ...
    }
}

export class APIObjectB {
    // Valid values in APIObjectB
    public type Property1Value = "possible_value_E" | "possible_value_F";
    public type Property2Value = "possible_value_G" | "possible_value_H";

    // In this context, "Property1Value" refers to the version in APIObjectB
    public get property1(): Property1Value {
        // ...
    }

    public get property2(): Property2Value {
        // ...
    }
}
</code></pre>

<p>And then, ideally, I'd be able to refer to a specific type in consuming code so that I have types everywhere:</p>

<pre><code>var myNewValue: APIObjectB.Property1Value = "possible_value_F";
</code></pre>