Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CrazyClass 在实现 Crazy 时报错 #251

Open
xindoucha opened this issue Dec 25, 2021 · 2 comments
Open

CrazyClass 在实现 Crazy 时报错 #251

xindoucha opened this issue Dec 25, 2021 · 2 comments

Comments

@xindoucha
Copy link

在《接口》这一节最后“注意”部分的示例有点问题。
CrazyClass 在实现Crazy时显示如下报错:
image

@zombiu
Copy link

zombiu commented Dec 19, 2023

我也遇到这个问题,大佬 解决没!

@zombiu
Copy link

zombiu commented Dec 21, 2023

interface Crazy {
new (): {
hello: number;
};
}

const CrazyClass = function() {

} as unknown as Crazy

// Because
const crazy = new CrazyClass();
crazy.hello = 156
console.log(crazy);
问题解决了,就是不知道为啥要这样解决!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants