Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@megheaiulian
Copy link
Contributor

@megheaiulian megheaiulian commented Oct 19, 2023

Improve typing for the when directive making it more dynamic.

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.

Fixes #4085

@changeset-bot
Copy link

changeset-bot bot commented Oct 19, 2023

🦋 Changeset detected

Latest commit: 4120a4f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
lit-html Patch
lit Patch
@lit-examples/nextjs Patch

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 19, 2023

📊 Tachometer Benchmark Results

Summary

A summary of the benchmark results will show here once they finish.

Results

The full results of your benchmarks will show here once they finish.

tachometer-reporter-action v2 for Benchmarks

@megheaiulian megheaiulian marked this pull request as ready for review October 19, 2023 20:54
@megheaiulian megheaiulian force-pushed the feat/when-guard-value branch 2 times, most recently from 582c880 to 63d626f Compare October 23, 2023 18:43
Copy link
Member

@augustjk augustjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

megheaiulian and others added 4 commits October 27, 2023 08:58
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.
@megheaiulian megheaiulian force-pushed the feat/when-guard-value branch from b800d32 to 4120a4f Compare October 27, 2023 05:58
@augustjk augustjk merged commit 8f674ab into lit:main Oct 27, 2023
This was referenced Oct 27, 2023
@megheaiulian megheaiulian deleted the feat/when-guard-value branch October 29, 2023 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lit-html] when directive should have better type def

3 participants