Fix choose directive type inference#4240
Conversation
🦋 Changeset detectedLatest commit: 5f0a5ba 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 ResultsSummary⏳ Benchmarks are currently running. Results below are out of date. nop-update
render
update
update-reflect
Results⏳ Benchmarks are currently running. Results below are out of date. this-change
render
update
update-reflect
this-change, tip-of-tree, previous-release
render
update
nop-update
this-change, tip-of-tree, previous-release
render
update
this-change, tip-of-tree, previous-release
render
update
update-reflect
|
rictic
left a comment
There was a problem hiding this comment.
Mind adding a regression test to the choose_test.ts? Something like:
if (false as boolean) {
// Type-only regression test of https://github.com/lit/lit/issues/4220
type CheckoutStep = 'register' | 'delivery' | 'payment';
let step = 'register' as CheckoutStep;
return choose(step, [
// @ts-expect-error 'test' is not assignable to 'CheckoutStep'
['test', () => 1],
// @ts-expect-error 'random' is not assignable to 'CheckoutStep'
['random', () => 2],
// this should compile fine
['register', () => 3],
]);
}| * ``` | ||
| */ | ||
| export const choose = <T, V>( | ||
| export const choose = <T, V, K extends T = T>( |
There was a problem hiding this comment.
Nice! Yeah this fixes the issue. Playground demo
|
Also please add a changeset by running |
Of course! Done |
augustjk
left a comment
There was a problem hiding this comment.
Thank you for the PR and sorry it took so long to get it in! I fixed the build error for the test and made the changelog a bit more detailed.
AndrewJakubowicz
left a comment
There was a problem hiding this comment.
Great! Thank you!
Fixes #4220