The Typewriter is generating date type in TypeScript for DateTime types in C#, I want to change it to "string", but not able to do so
here is what I tried in .tst
string TypeConverter(Type type){
if(type.Name == "Month") return "string";
return type.Name;
}
And then in latter section tried
//1
export class $Name {$Properties[
public $Name: TypeConverter($Type);]
}
//2
export class $Name {$Properties[
public $Name: TypeConverter;]
}
//3
export class $Name {$Properties[
public $Name: $TypeConverter;]
}
But none of them are working
Custom methods are called like any other property using $MethodName
using the current context as the parameter. So in your example there are two ways to solve the problem.
Change the parameter of the method to match the context:
${
string TypeConverter(Parameter parameter)
{
if(parameter.Type.Name == "Month")
return "string";
return parameter.Type.Name;
}
}
export class $Name {$Properties[
public $Name: $TypeConverter;]
}
Or, call the method from a Type
context:
${
string TypeConverter(Type type)
{
if(type.Name == "Month")
return "string";
return type.Name;
}
}
export class $Name {$Properties[
public $Name: $Type[$TypeConverter];]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With