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

一个接口中只能定义一个任意属性这里的age不能是可选的 #225

Open
mengliren666 opened this issue Jun 20, 2022 · 1 comment

Comments

@mengliren666
Copy link

//这里的age不能是可选的,因为propName: string
interface Person {
name: string;
age?: number;
[propName: string]: string | number;
}

@L-icloud
Copy link

// 因为可选属性 涉及到 undefined propName 因缺少了 undefined 而报错

interface Person {
name: string;
age?: number;
[propName: string]: string | number | undefined;
}

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