我是键入脚本的新手。我正在编写一个函数来格式化字符串。
type patamTypes = string | number | number[];
function myFunc(sTemplate: string, params: patamTypes): string {
if (typeof params == 'string'){
params = [params]; //getting the error here
}
}
我收到这个错误。Type 'string' is not assignable to type 'number'.