I have this interface:
interface IParameters {
form: number;
field: string;
...
}
I want the formproperty to be number or function and field to be string or function.
I try something like this:
interface IParameters {
form: number | Function;
field: string | Function;
...
}
I need this because in my code i use this variables like this:
var form = (typeof _oParameters.form === "function" ? _oParameters.form() : _oParameters.form);
var field = (typeof _oParameters.field === "function" ? _oParameters.field() : _oParameters.field);
I don't want change this variable in all my code from string/number to default function and to prevent setting this variables to other types.
but if I try to call one of this two variable like function:
var param:IParameters;
param.form();
...
I get this error:
Cannot invoke an expression whose type lacks a call signature.
but param.form = 12; works.
The only solution that i have found is to declare form and field to any type.
Is other way to define this variable without any type?