[key: string]: string
overrides more specific properties
#59495
Labels
Working as Intended
The behavior described is the intended behavior; this is not a bug
🔎 Search Terms
"[key: string]: string"
🕗 Version & Regression Information
[key: string]
(one mention and seems to be not it)⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.6.0-dev.20240731#code/C4TwDgpgBAKghgJwOYWFAvFA3gWAFBRQD0RUwAFgJYDO+hAxlQDYAmCEAdgFzZ2FSUWPasASUOSANx8AvgG0AutLwyoAMl4EocgNYQQw0eKQLDYicpnL8oSFACSHMAFc0mXFpJQ4HFmSrU3uwCLJzAlPRwTHxe1AD2-vpQ1ORxzqxQAEbQ9HEAtmCIEH7ACRBwjFBxFBAIMaTiIuV+cQBm2noGyUYSpt3mSHyMlKzs3Jr8IWbGyoTySvhW+Pi5HCICTq48ji5uE1DDo5w8clhTUABE5BBMTHEXUDIKADSL1nitzhz04XEc3vR6BAwMB7MAIHkABTARAoYA8eDIVAASn27GAzgQ-xhSOAlmWeAqQJBYIhkPEu2RyiAA
💻 Code
🙁 Actual behavior
If
key: string]: string
is present in target type, it overrides more specific fields. Even if both target and input have identically defined fields, it will be used instead and might give error (if this field is not string).🙂 Expected behavior
As less specific, it should be used as fallback. This way it will allow more specific fields to be compared first and avoid potential type error for valid js.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: