-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(crwa): Explicit check for possible null value in entry.client.tsx
#9251
Conversation
@jtoar - Do you think this one needs a larger team/group agreement or could we just get this in like any standard change? |
I'd do |
Happy to change it to the falsy condition |
I guess this would actually have to be a manual change for existing projects. Do we need to consider a codemod here or is the change simple enough to document? It's only encountered when you opt-in to strict types so there is already a manual barrier in that regard. Edit: I'll add a codemod for this. Please wait for that addition before merging. |
Added the complementary codemod for this change. It should easily cover the vast majority of users - only those who have customised the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @Josh-Walker-GM!
…x` (#9251) **Problem** Fixes #9059 which is a type error raised when you have strict type checking enabled. The `getElementById` call can return null as the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById#return_value) mention. **Changes** Adds a basic null check taken from the solution given in #9059. **Considerations** This adds some boilerplate code to a user facing file but I think it's a reasonable addition. It's readable and clear what the code is doing without the need for further explanation or technical knowledge. In the case where this causes a runtime error then the message is clearer: ![Screenshot from 2023-10-02 23-16-38](https://github.com/redwoodjs/redwood/assets/56300765/ca6d51bd-2c28-438e-87d3-7411e54721ec) I haven't immediately been able to think of some hidden solution to this that isn't exposed to the user in some boilerplate code.
…x` (#9251) **Problem** Fixes #9059 which is a type error raised when you have strict type checking enabled. The `getElementById` call can return null as the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById#return_value) mention. **Changes** Adds a basic null check taken from the solution given in #9059. **Considerations** This adds some boilerplate code to a user facing file but I think it's a reasonable addition. It's readable and clear what the code is doing without the need for further explanation or technical knowledge. In the case where this causes a runtime error then the message is clearer: ![Screenshot from 2023-10-02 23-16-38](https://github.com/redwoodjs/redwood/assets/56300765/ca6d51bd-2c28-438e-87d3-7411e54721ec) I haven't immediately been able to think of some hidden solution to this that isn't exposed to the user in some boilerplate code.
Problem
Fixes #9059 which is a type error raised when you have strict type checking enabled. The
getElementById
call can return null as the MDN docs mention.Changes
Adds a basic null check taken from the solution given in #9059.
Considerations
This adds some boilerplate code to a user facing file but I think it's a reasonable addition. It's readable and clear what the code is doing without the need for further explanation or technical knowledge. In the case where this causes a runtime error then the message is clearer:
I haven't immediately been able to think of some hidden solution to this that isn't exposed to the user in some boilerplate code.