public class Class1
{
private object X = new object();
}
results in typescript:
class Class1 extends NObject
{
private X: any = new any();
constructor()
{
super();
}
}
which is invalid as any isn't supposed to be instantiated, and the error runs through tsc to javascript. (That should be private X: any = new Object();)
I think this pattern is used to construct generic objects for use in lock and synchronization functions. I'm not 100% sure of my fix, so I'm not submitting it as a patch just yet, but I think the way to fix it is to check in GetPrimitiveTypeReplacement if the parent is a constructor:
public static PrimitiveType GetPrimitiveTypeReplacement (PrimitiveType primitiveType)
{
switch (primitiveType.KnownTypeCode) {
case KnownTypeCode.Object:
if (isAnyConstructor(primitiveType)) return new PrimitiveType("Object");
return new PrimitiveType ("any");
This code:
results in typescript:
which is invalid as any isn't supposed to be instantiated, and the error runs through tsc to javascript. (That should be
private X: any = new Object();
)I think this pattern is used to construct generic objects for use in lock and synchronization functions. I'm not 100% sure of my fix, so I'm not submitting it as a patch just yet, but I think the way to fix it is to check in
GetPrimitiveTypeReplacement
if the parent is a constructor:using the test function
but I'm not really familiar with NRefactory, so there's probably a simpler way to do it.