इम सोच कैसे मैं एक मूल्य के रूप में कार्य पारित करने के लिए एक प्रकार निर्माता के लिए एक संदर्भ प्राप्त कर सकते हैं। मूल रूप से, मैं एक सामान्य प्रकार रजिस्ट्री कि उदाहरणों एक सामान्य प्रकार रजिस्ट्री उदाहरण के एक सदस्य फ़ंक्शन को कॉल करके बनाया जा करने की अनुमति होगी करना चाहते हैं।
उदाहरण के लिए:
class GeometryTypeInfo
{
constructor (public typeId: number, public typeName: string, public fnCtor: (...args: any[]) => IGeometry) {
}
createInstance(...args: any[]) : IGeometry { return this.fnCtor(args); }
}
}
बाद में:
class Point implements IGeometry {
constructor(public x: number, public y: number) { }
public static type_info = new GeometryTypeInfo(1, 'POINT', Point); // <- fails
// also fails:
// new GeometryTypeInfo(1, 'POINT', new Point);
// new GeometryTypeInfo(1, 'POINT', Point.prototype);
// new GeometryTypeInfo(1, 'POINT', Point.bind(this));
}
क्या किसी को पता है अगर यह एक कक्षाएं निर्माता समारोह संदर्भ के लिए संभव है?













