Common property check isn't performed when the target has any index signature #55709
Labels
Possible Improvement
The current behavior isn't wrong, but it's possible to see that it might be better in some cases
π Search Terms
common property check weak type index signature
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?noErrorTruncation=true&ts=5.3.0-dev.20230911#code/C4TwDgpgBAIhA2BDEAeAKnJIoQB7AgDsATAZylOACcBLQgcwD4oBeKDBZKAHykIFcAtgCMIVANwAoSXQJUAZogDG0ALLKAFnQgBhAPaF5Neukxc8BEuUq0GzAN6SoUUJFIB+AFxR+hANaEegDuhFLOiPJyXlCOzs4A2gDSUHSwnKgcWIwAutECImJhUAC+UsXSxBBKSFTQ8r5KwDQGLhCUKE7sZtgWRGQU1HT0ADSdaPqGxjj4feTqSlqEugZGJpnIjKOMABRKK8be9i7gbYdQlVik3uvYxSVQAGTsE6sAlN4Abno0xFKSBJRtrFjm5DndEORgc4LsgrlAAEQGaCkKoGYjwngIpFQQR0fgEeFFYqjcKRMSHTrOAD0VKgAAFgKQALR4SCNFlUKh6KiUqB6PRgUgAfWAWmFNGFvgCwUIQphIG8AEYAAzKkklUbFV5-eqERrNQitSgAJnQ00s-SO8Vw3gABj8mQASez5URUYq27LeGxDEo7RDXV4xcoA4DGoGdGn0xks3Bs4Acrk85xURAkPSCbzUfgQTXa6S6-UtUMAZjNvSsMSg1u9IBEengXoGtnofu2AfYQfsIbawBLEeptIZzNZVQTYiTnVT6czLioObzUiAA
π» Code
π Actual behavior
No errors are raised here since index signatures turn off the common property check completely.
π Expected behavior
I don't have a good intuition about the common property check so I'm not sure if all of those 3 examples should be treated as bugs/possible improvements. I think though that especially the first one is surprising because I have a list of 2 concrete string properties that are meant to be allowed there and yet the unrelated~ index signature for numbers turns off this check, leading to accidental problems at runtime.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: