查找: Missing 返回类型
找错误 简单
题目
这个函数有 类型错误. 查找 mistake:
代码
function getAge(): number {
return "25";
}
提示
Look at 什么函数返回对比什么它 declares.
解释
函数 declares 返回类型的 数字, 但它 返回字符串 "25" (with quotes). TypeScript errors: Type 'string' is not assignable to type 'number'. Fix: return the number 25 without quotes: 返回 25;.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。