-
Notifications
You must be signed in to change notification settings - Fork 1k
[labs/task] Disambiguate TaskFunction type
#4161
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
Conversation
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultsthis-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
|
🦋 Changeset detectedLatest commit: 2c6d31b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
rictic
left a comment
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.
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()
}
@rictic Thanks! I added a test following an existing pattern shown here lit/packages/labs/task/src/test/task_test.ts Lines 626 to 636 in 170e916
|
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.