Skip to content

Proposal. Internal class declaration. #4460

Closed
@xLama

Description

@xLama

I think it´s a good idea to let an internal class declaration:

class A{
   class B{}
}

Emit proposal:

var A = (function () {

     var B = (function () {
    function B() {
    }
    return B;
})();


    function A() {
    }
    return A;
})();

We can use it to make Singleton very easy.

class Singleton{

    class B{
        private enforcer:string;
    }

    private static _instance:Singleton;

    constructor(enforcer: B){}

    public static get instance():Singleton{
        if (Singleton._instance === undefined){
            Singleton._instance = new Singleton(new B())
        }
        return Singleton._instance;
    }
}

Related: #3266

Metadata

Metadata

Assignees

No one assigned

    Labels

    SuggestionAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it adds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions