摘要:
function getCacheData(key: string): any { return (window as any).cache[key]; } interface Cat { name: string; run(): void; } const tom = getCacheData(' 阅读全文
摘要:
function toBoolean(something: any): boolean { return something as boolean; } cc.log(toBoolean(1)); 上面代码输出还是1,something还是number类型,类型断言并没有什么用 function t 阅读全文
摘要:
interface Cat { run(): void; } interface Fish { swim(): void; } function testCat(cat: Cat) { return (cat as any as Fish); } 在上面的例子中,若直接使用 cat as Fish 阅读全文