-
-
Notifications
You must be signed in to change notification settings - Fork 424
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
perf(form-core): reduce instantiations when type checking #1262
base: main
Are you sure you want to change the base?
perf(form-core): reduce instantiations when type checking #1262
Conversation
View your CI Pipeline Execution ↗ for commit 22bf0d2.
☁️ Nx Cloud last updated this comment at |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1262 +/- ##
==========================================
- Coverage 88.81% 88.79% -0.02%
==========================================
Files 28 28
Lines 1269 1267 -2
Branches 331 329 -2
==========================================
- Hits 1127 1125 -2
Misses 127 127
Partials 15 15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…e annotations and remove Omit
…es' into perf-annotations-deep-key-values
…es' into perf-annotations-deep-key-values
…es' into perf-annotations-deep-key-values
…es' into perf-annotations-deep-key-values
…es' into perf-annotations-deep-key-values
…es' into perf-annotations-deep-key-values
…es' into perf-annotations-deep-key-values
…es' into perf-annotations-deep-key-values
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 for the improvements and sorry for taking so long for the review!
I just added a couple comments, overall looks great! (and slightly beyond my TS knowledge, but I trust you :D)
@@ -32,7 +32,7 @@ it('should type value when nothing is passed into constructor', () => { | |||
}) | |||
|
|||
assertType<string | undefined>(field.state.value) | |||
assertType<'name'>(field.options.name) |
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.
I think field.option.name
should be 'name'
only and that's also true on the code, maybe this change was lost there during a refactor? (same for the two instances below on this file).
I see the test is still passing with assertType<'name'>
@@ -24,8 +24,13 @@ assertType< | |||
type ArraySupport = DeepKeys<{ users: User[] }> | |||
assertType< | |||
| 'users' | |||
| `users[number]` |
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.
I have used the large example in the repo (this isn't very large so difference is not so large) to check reduction in instantiations and type checking time. I am using
extendedDiagnostics
but also traced the exampleBefore:
After
There are three main things contributing to lower instantiations:
TName
is not constrained and uses aValidateName
utility instead. I prefer not to use contraints at inference sites against complex types that could be unions. This is becauseTName
could default to the union and this can slow things down in a few situations.DeepKeys
andDeepValue
. Instead of creating a union and then parsingTName
again, a map is constructed soTValue
can be grabbed byTName
.TName
->TValue