我剛剛從TypeScript 1.5升級(jí)到最新版本,并且在代碼中看到錯(cuò)誤:interface Options { /* ... others ... */ callbackOnLocationHash?: boolean;}function f(opts: Options) { /* ... */ }// Error: Object literal may only specify known properties,// and 'callbackOnLoactionHash'does not exist in type 'Options'.f( { callbackOnLoactionHash: false });代碼對(duì)我來(lái)說(shuō)看起來(lái)不錯(cuò)。怎么了?(替代的Universe版本:我認(rèn)識(shí)到錯(cuò)字,我確實(shí)確實(shí)想寫(xiě)錯(cuò)字。我應(yīng)該怎么做才能消除錯(cuò)誤?)
為什么會(huì)出現(xiàn)錯(cuò)誤“對(duì)象文字只能指定已知屬性”?
慕田峪9158850
2019-11-14 15:11:32