feat(lit-html/directives/when.ts): improve typing#4310
Conversation
🦋 Changeset detectedLatest commit: 4120a4f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Tachometer Benchmark ResultsSummaryA summary of the benchmark results will show here once they finish. ResultsThe full results of your benchmarks will show here once they finish. |
582c880 to
63d626f
Compare
augustjk
left a comment
There was a problem hiding this comment.
Thank you for the PR!
The change is pretty minimal but does affect runtime and usage will look different if you want to take advantage of this. Whether we want to document this everywhere I think is up for debate but it should be fine to merge this and leave it as an undocumented feature in the interim.
I did leave a suggestion to make at least the changelog entry more verbose as the one place to document this behavior change.
Improve typing for the `when` directive making it more dynamic.
```ts
let user = {name: string} | undefined;
when(
user,
(user)=>user.name
)
```
In the trueCase and falseCase functions the condition is correctly type
and we no longer need a non-null assertion.
Co-authored-by: Augustine Kim <ajk830@gmail.com>
b800d32 to
4120a4f
Compare
Improve typing for the
whendirective making it more dynamic.In the trueCase and falseCase functions the condition is correctly type
and we no longer need a non-null assertion.
Fixes #4085