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
SimpleChanges type definition is incorrest #49361
Comments
Hi, this has already been reported by #48752 ! |
Yep, this is a TypeScript quirk and a duplicate of #48752. |
I agree that it is a duplicate (I was not able to find #48752 when creating this one, sry), but the orignal argument for closing should be reconsidered. |
I want to add that
would produce an error, even though the index access is obviously checked (in some sense). That makes |
@uap-universe That's an cumbersome way to check array bounds when you have nowadays optional chaining and null coalescing. |
@JeanMeche yes, but I prefer not only to think about myself and my own problems but also what it might mean for the millions of other people out there, that are not so "smart" and up to date as I am. Look, I am just saying, that it is a bad suggestion for people to say "enable this compiler option" effectively generating more problems for them than they had before. This only encourages people to disable linter and modern compiler features altogether. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Currently the
SimpleChanges
type is defined as:which means that whatever string index property you use, it will be defined and have value of
SimpleChange
.This is however not true as only the changed component properties will be present, the rest will be undefined, so type definition should be:
Common implementation of
ngOnChanges
check if the property of interest have changed, like so:but with current typing linters/code analysers correctly complain that such confition is always true.
Please provide a link to a minimal reproduction of the bug
https://typescript-eslint.io/play/#ts=4.9.3&sourceType=module&code=CYUwxgNghgTiAEBLAdgFxDAZlMCDKiAtgA4QgDCAFlMgOYgDO8A3gLABQ88A2sTAPbEAclEIgAXPAaoYKWgF1JBEmSo16Abg4BfDh1CRYCQwybLSFanQRtO8PiABuifgFcGANSgRXE+DQBPLTswVxg4NC8fP0DgrkxEGGk1a0kAI35+Mho4+DB+ZGkYVzBUfhgACgdnN09vX0lAgBo8sIjUKIb-ZACWhKTUFPp0zOzkAEpcxAYAMUTkq3oK8ZGskBydPXZMV2RSl2R4OgB5ZCHGCrBFxiUiC3OGFfhHfkRgFg4uREx4S+uGbgAckIAQACgJiBhUAFjpgAJJoDCMVCA+TjD52LjwAD02PgwH4UlQrkwPwA7ohUJQkKhPvBdOxtEA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0yHJgBNK+SpPRgA2pETRoHaJAC64MAF8Q+oA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: