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

Skip to content

Conversation

@augustjk
Copy link
Member

Fixes #4155

The optional notation on 2nd param and the signal option made TypeScript not accept a task function with an explicit second param. Removing the ? fixes this. Since we always provide the second argument with the abort signal when calling the provided function, it makes sense to type it so.

TypeScript is still happy to accept a function that doesn't have a 2nd param.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 30, 2023

📊 Tachometer Benchmark Results

Summary

nop-update

  • this-change, tip-of-tree, previous-release: unsure 🔍 -8% - +5% (-1.70ms - +1.00ms)
    this-change vs tip-of-tree

render

  • this-change: 71.74ms - 75.67ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -7% - +4% (-1.87ms - +1.03ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -0% - +3% (-0.22ms - +1.50ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -4% - +2% (-1.89ms - +0.69ms)
    this-change vs tip-of-tree

update

  • this-change: 755.07ms - 780.17ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -6% - +3% (-4.03ms - +2.07ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -1% - +2% (-1.26ms - +2.54ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -2% - +1% (-13.48ms - +4.41ms)
    this-change vs tip-of-tree

update-reflect

  • this-change: 729.51ms - 745.51ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -1% - +1% (-9.89ms - +4.80ms)
    this-change vs tip-of-tree

Results

this-change

render

VersionAvg timevs
71.74ms - 75.67ms-

update

VersionAvg timevs
755.07ms - 780.17ms-

update-reflect

VersionAvg timevs
729.51ms - 745.51ms-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
26.25ms - 28.24ms-unsure 🔍
-7% - +4%
-1.87ms - +1.03ms
unsure 🔍
-7% - +2%
-2.00ms - +0.70ms
tip-of-tree
tip-of-tree
26.62ms - 28.72msunsure 🔍
-4% - +7%
-1.03ms - +1.87ms
-unsure 🔍
-6% - +4%
-1.62ms - +1.16ms
previous-release
previous-release
26.98ms - 28.81msunsure 🔍
-3% - +7%
-0.70ms - +2.00ms
unsure 🔍
-4% - +6%
-1.16ms - +1.62ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
69.55ms - 73.23ms-unsure 🔍
-6% - +3%
-4.03ms - +2.07ms
unsure 🔍
-5% - +3%
-3.44ms - +2.13ms
tip-of-tree
tip-of-tree
69.94ms - 74.81msunsure 🔍
-3% - +6%
-2.07ms - +4.03ms
-unsure 🔍
-4% - +5%
-2.88ms - +3.54ms
previous-release
previous-release
69.95ms - 74.14msunsure 🔍
-3% - +5%
-2.13ms - +3.44ms
unsure 🔍
-5% - +4%
-3.54ms - +2.88ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
18.59ms - 20.75ms-unsure 🔍
-8% - +5%
-1.70ms - +1.00ms
unsure 🔍
-7% - +9%
-1.27ms - +1.74ms
tip-of-tree
tip-of-tree
19.20ms - 20.84msunsure 🔍
-5% - +9%
-1.00ms - +1.70ms
-unsure 🔍
-4% - +10%
-0.75ms - +1.92ms
previous-release
previous-release
18.38ms - 20.49msunsure 🔍
-9% - +6%
-1.74ms - +1.27ms
unsure 🔍
-10% - +4%
-1.92ms - +0.75ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
49.61ms - 50.94ms-unsure 🔍
-0% - +3%
-0.22ms - +1.50ms
unsure 🔍
-2% - +2%
-1.06ms - +0.93ms
tip-of-tree
tip-of-tree
49.09ms - 50.18msunsure 🔍
-3% - +0%
-1.50ms - +0.22ms
-unsure 🔍
-3% - +0%
-1.62ms - +0.21ms
previous-release
previous-release
49.60ms - 51.08msunsure 🔍
-2% - +2%
-0.93ms - +1.06ms
unsure 🔍
-0% - +3%
-0.21ms - +1.62ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
103.64ms - 106.14ms-unsure 🔍
-1% - +2%
-1.26ms - +2.54ms
unsure 🔍
-1% - +2%
-0.89ms - +2.52ms
tip-of-tree
tip-of-tree
102.82ms - 105.68msunsure 🔍
-2% - +1%
-2.54ms - +1.26ms
-unsure 🔍
-2% - +2%
-1.67ms - +2.02ms
previous-release
previous-release
102.92ms - 105.24msunsure 🔍
-2% - +1%
-2.52ms - +0.89ms
unsure 🔍
-2% - +2%
-2.02ms - +1.67ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
43.40ms - 44.46ms-unsure 🔍
-4% - +2%
-1.89ms - +0.69ms
unsure 🔍
-2% - +2%
-0.85ms - +0.69ms
tip-of-tree
tip-of-tree
43.35ms - 45.71msunsure 🔍
-2% - +4%
-0.69ms - +1.89ms
-unsure 🔍
-2% - +4%
-0.78ms - +1.83ms
previous-release
previous-release
43.45ms - 44.57msunsure 🔍
-2% - +2%
-0.69ms - +0.85ms
unsure 🔍
-4% - +2%
-1.83ms - +0.78ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
747.41ms - 758.46ms-unsure 🔍
-2% - +1%
-13.48ms - +4.41ms
unsure 🔍
-1% - +1%
-11.16ms - +6.21ms
tip-of-tree
tip-of-tree
750.44ms - 764.50msunsure 🔍
-1% - +2%
-4.41ms - +13.48ms
-unsure 🔍
-1% - +2%
-7.66ms - +11.77ms
previous-release
previous-release
748.72ms - 762.11msunsure 🔍
-1% - +1%
-6.21ms - +11.16ms
unsure 🔍
-2% - +1%
-11.77ms - +7.66ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
739.74ms - 749.46ms-unsure 🔍
-1% - +1%
-9.89ms - +4.80ms
unsure 🔍
-2% - +0%
-12.07ms - +3.21ms
tip-of-tree
tip-of-tree
741.64ms - 752.65msunsure 🔍
-1% - +1%
-4.80ms - +9.89ms
-unsure 🔍
-1% - +1%
-9.95ms - +6.18ms
previous-release
previous-release
743.14ms - 754.92msunsure 🔍
-0% - +2%
-3.21ms - +12.07ms
unsure 🔍
-1% - +1%
-6.18ms - +9.95ms
-

tachometer-reporter-action v2 for Benchmarks

@changeset-bot
Copy link

changeset-bot bot commented Aug 30, 2023

🦋 Changeset detected

Latest commit: 2c6d31b

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

This PR includes changesets to release 1 package
Name Type
@lit-labs/task 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

Copy link
Collaborator

@rictic rictic left a comment

Choose a reason for hiding this comment

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

Please add a type test that fails without this change and passes with it.

We've been writing these as:

if (false as boolean) {
  // This is good code because [...]
  codeThatShouldCompileCorrectly();

  // We want this to be a type error because [...]
  // @ts-expect-error
  codeThatShouldFailToCompile()
}

@augustjk
Copy link
Member Author

Please add a type test that fails without this change and passes with it.

@rictic Thanks! I added a test following an existing pattern shown here

test('task args functions can return const arrays', () => {
return class MyElement extends ReactiveElement {
task = new Task(
this,
([a, b]) => [a * 2, b.split('')],
// Make sure that we can use `as const` to force inference of the args
// as [number, string] instead of (number | string)[]
() => [1, 'b'] as const
);
};
});

@augustjk augustjk requested a review from rictic August 30, 2023 18:44
@augustjk augustjk merged commit 4fdc47c into main Aug 30, 2023
@augustjk augustjk deleted the task-func-type branch August 30, 2023 20:29
@lit-robot lit-robot mentioned this pull request Aug 30, 2023
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.

[labs/task] Type error for task function using abort signal

3 participants