-
Notifications
You must be signed in to change notification settings - Fork 58
FED-3585 Fix fragment type check assert #974
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
Conversation
…gment isPotentiallyValidComponentType is incorrect in dart2js (see TODO on that function) and it returns false for Fragment's Symbol type. There's not a great way to fix that behavior until Dart 3 (see TODO), so in the meantime, we'll just remove this assert. The assert really isn't necessary, since only types from ReactElements and ReactComponentFactoryProxys get passed into it, as opposed to consumer arguments, so we should be able to safely remove it. Any cases it might have caught should also be covered by test coverage on type checking code.
// TODO handle that case in dart2js once our Dart SDK constraint is >=3.0.0, with the following code: | ||
// typeofEquals(type, 'symbol') || | ||
// TODO also add a test (see TODO in component_type_checking_test.dart) |
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.
#nit has the ticket for this already been created?
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.
Nope, I hadn't made one, wasn't sure if it was worth it or if we could just roll it in with other updates when we rip out pre-3.0.0 code
QA +1
@Workiva/release-management-pp |
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.
+1 from RM
Motivation
getProps(child, traverseWrappers: true)
incorrectly raises the following assertion error, only in dart2js (when using--enable-asserts
):For Fragment ReactElements (
Fragment()(...)
),.type
is apparently JS Symbol instance, and is a case not handled by this check causing this assertion to fail.This case should not throw.
Also, we just shouldn't try to validate the
.type
that originates fromReactElement
s; if we don't make any assumptions about what type it can be, this issue won't occur.Changes
Remove unnecessary assert as a workaround for false positive with Fragment, add TODOs
isPotentiallyValidComponentType is incorrect in dart2js (see TODO on that function) and it returns false for Fragment's Symbol type.
There's not a great way to fix that behavior until Dart 3 (see TODO), so in the meantime, we'll just remove this assert.
The assert really isn't necessary, since only guaranteed-to-be-valid component types from ReactElements and ReactComponentFactoryProxys get passed into it, as opposed to consumer arguments, so we should be able to safely remove it. Any cases it might have caught should also be covered by test coverage on type checking code.
Add regression test
Note: due to current behavioral differences of isPotentiallyValidComponentType between dart2js and DDC, these regression tests only fail in dart2js with
--enable-asserts
, which we don't want to run our tests with.As opposed to adding a whole new build configuration and updating our test setup just for that one case, which we'll be able to fix once we move to Dart 3, we'll just verify this manually as part of QAing this PR.
Release Notes
Fix false positive
assert
in dart2js (when using--enable-asserts
) when passing aFragment
intogetProps(..., traverseWrappers: true)
Review
See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.
Please review:
QA Checklist
Verify locally that regression tests fail in dart2js with
--enable-asserts
, before the fix.Normally you'd need to update build.yaml, but you can also use
--build-args
, which I've done here for convenience. Just run the following commands:You should see failures that look like this: https://gist.github.com/greglittlefield-wf/afb337f5b9ccf15f93be5a3a2d956edc
Verify locally that regression tests (and other tests in suite) pass in dart2js with
--enable-asserts
, after the fix.Use the following commands:
Merge Checklist
While we perform many automated checks before auto-merging, some manual checks are needed: