-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Template Literal Types as key types get lost when implementing Interface #49889
Comments
Duplicate of #10570. The type of your When you add an explicit type annotation you will get the excess-properties check: |
@MartinJohns thanks for the explanation. What would be a way in TS to achieve what I would like to do here then? I would not want to explicitly redeclare the type of |
TypeScript is structurally typed. Additional properties that are not incompatible with the declared type are always allowed. You would need #12936 to disallow additional properties. |
There's no way to do this currently when implementing an interface. The types of class members are inferred the same way regardless of whether the class has an |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
π Search Terms
template literal key remapping interface inheritance
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
no TS error when defining key
click
.π Expected behavior
Error:
The text was updated successfully, but these errors were encountered: