Defining TypeScript variable type function or string
问题 I have this interface: interface IParameters { form: number; field: string; ... } I want the form property 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" ?