【发布时间】:2026-01-19 23:05:02
【问题描述】:
使用 typescript 编译文件时出现错误:
Property 'qaz' does not exist on type '{ bar: string; }'.
文件中有如下代码:
let foo = {
bar: "Can you perform a Quirkafleeg?"
}
let { qaz = "I'm feeling manic!" } = foo;
console.log(qaz);
console.log(qaz.bar);
基于页面上的示例代码:“解构对象”部分中的https://zellwk.com/blog/es6/。
我希望得到第二个字符串作为输出,但我有点困惑,因为该页面上还有另一个示例:
let { fizz: faz = "Eugene was my friend." } = foo; // as defined above
console.log(fizz);
console.log(fizz.faz);
这给出了类似的错误:
Property 'fizz' does not exist on type '{ bar: string; }'.
【问题讨论】:
-
该链接更清晰/质量更好,谢谢。
标签: javascript typescript tsc