我想要一个返回数组的函数,但我希望返回的数组是只读的,所以当我尝试更改其内容时应该会收到警告/错误。functiongetList():readonlynumber[]{return[1,2,3];}constlist=getList();list[2]=5;//Thisshouldresultinacompileerror,thereturnedlistshouldneverbechanged这可以在TypeScript中实现吗? 最佳答案 这似乎可行...functiongetList():ReadonlyArray{retur