Aynı anda typescript modülü ve sınıf?

oy
4

Şu anda openlayers için daktilo tanım dosyası oluşturmak için çalışıyorum.

Sorun openlayers bir modül ve daktilo bir sınıf hem çevirmek olacak bazı sınıflar olmasıdır.

Örneğin olduğu Protocolmodül sınıf OpenLayersve bir sınıfı ResponsemodülündeOpenLayers.Protocol .

Nasıl daktilo o modeli deneyeyim Ben yapabilir Protocolbir sınıf ve tanımlamakResponse ihraç edilen bir iç sınıf olarak sınıfını? Nasıl bu sorunu çözme hakkında gitmek?

Oluştur 09/10/2012 saat 12:51
kaynak kullanıcı
Diğer dillerde...                            


2 cevaplar

oy
1

Bildirmek Responsebir şekilde staticalanında Protocolbir dönen bir yapıcı tip interfacetanımlayan Responsebir sınıf:

declare module OpenLayers {
    export interface IProtocolResponse {
        foo(): void;
    }

    export class Protocol {
        static Response: new () => IProtocolResponse;
    }
}

var response = new OpenLayers.Protocol.Response();
response.foo();

Düzenle:

Anders işaret ettiği gibi Ya bu tartışma liste soruya , bu şekilde iç sınıf için birden fazla kurucuya sahip olabilir:

declare module OpenLayers {
    export interface IProtocolResponse {
        foo(): void;
    }

    export class Protocol {
        static Response: {
            new (): IProtocolResponse;
            new (string): IProtocolResponse;
        };
    }
}

var response = new OpenLayers.Protocol.Response('bar');
response.foo();

Her iki yaklaşımın ana olumsuz bir sınıf türetmek edemezler OpenLayers.Protocol.Response.

Cevap 14/10/2012 saat 03:13
kaynak kullanıcı

oy
0

Burada yardımcı olur umarım benim güncellenen cevabı, - bu OpenType tanımlayan başlamak gerekir:

declare module OpenType {
   export class Protocol {
       constructor();
       Request;
   }
}

var x = new OpenType.Protocol();
var y = new  x.Request();
var z = x.Request;
Cevap 09/10/2012 saat 14:37
kaynak kullanıcı

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more