-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
string: value interface not assignable to Record<string,unknown> #50087
Comments
This is working as intended. Interface types don't get implicit index signatures as per #15300. The behavior where |
Okay, looks like for my use case, I should be using a type alias instead of an Interface, and (i cut this from the reproduction) instead of extending the interface, I need to intersect two type aliases. |
@jcalz we're trying to upgrade from typescript 4.3.5 to 4.6.4 and are now receiving this error. Previously an interface like below would allow an interface to be passed in as the generic:
If this has been a breaking change since 3.5 I'm at a loss as to why this would be happening now? |
Bug Report
🔎 Search Terms
unknown record
Index signature
🕗 Version & Regression Information
Bug initially found in v4.7.4
Oldest found version with bug v3.5.1 in typescript playground
Bug found in nightly version v4.8.0-dev.20220728
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
OldProps type is not assignable to NewProps.
Typescript returns the following error:
Error is consistent with old style record syntax.
Error is consistent if OldProps["name"] type is
string
orany
Error not found if NewProps = Record<string, any>;
Error also not found if
[key:string]:[whatever type]
is added to OldProps (triggers different expected error if type conflicts with name).🙂 Expected behavior
OldProps type is assignable to NewProps.
The text was updated successfully, but these errors were encountered: