-
Notifications
You must be signed in to change notification settings - Fork 0
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
Name of properrty #1
Comments
It's not possible, because IModel is TypeScript Interface. TypeScript Entities doesn't exist in runtime. I can add |
@sotnikov-link Yes, if the name "name" will wrong ES will detect the error? |
@scinfu if you use function below then TypeScript gives error for your case: function getKeyOf<T extends object>(keyName: keyof T) {
return keyName;
}
interface IModel {
id: string
name: string
}
getKeyOf<IModel>("name") === "name" // 👍
getKeyOf<IModel>("wrongKey") // 👎 Argument of type '"wrongKey"' is not assignable to parameter of type 'keyof IModel'.(2345) This function doesn't work for TypeScript Refactoring so I don't want add this function in package |
@sotnikov-link nice. |
Can I access to name property of class or interface?
like:
The text was updated successfully, but these errors were encountered: