[k6] Fix Tester callback parameter type: Element → Selection#75191
Open
tsushanth wants to merge 1 commit into
Open
[k6] Fix Tester callback parameter type: Element → Selection#75191tsushanth wants to merge 1 commit into
tsushanth wants to merge 1 commit into
Conversation
The Tester interface (used by Selection.filter(), .is(), and .not()) declared its second parameter as Element, but k6 passes a Selection at runtime. This caused code that called Element-only methods like querySelector() to type-check but throw at runtime. Mapper (the map() callback) was already correctly typed as Selection. Align Tester to match.
Contributor
|
@tsushanth Thank you for submitting this PR! This is a live comment that I will keep updated. 1 package in this PRCode ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. You can test the changes of this PR in the Playground. Status
Once every item on this list is checked, I'll ask you for permission to merge and publish the changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 75191,
"author": "tsushanth",
"headCommitOid": "80c1c9948fd2db41e112ebe04f7b9750f3cf0754",
"mergeBaseOid": "e186cd854fef1fbd5152877e78f9ab05743c226e",
"lastPushDate": "2026-07-01T15:23:23.000Z",
"lastActivityDate": "2026-07-01T15:23:23.000Z",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"tooManyCommits": false,
"tooManyReviews": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "k6",
"kind": "edit",
"files": [
{
"path": "types/k6/html/index.d.ts",
"kind": "definition"
},
{
"path": "types/k6/test/html.ts",
"kind": "test"
}
],
"owners": [
"MStoykov",
"codebien",
"oleiade",
"ankur22",
"inancgumus",
"joanlopez",
"AgnesToulet",
"szkiba"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [],
"mainBotCommentID": 4856911440,
"ciResult": "pass"
} |
Contributor
|
🔔 @mstoykov @codebien @oleiade @ankur22 @inancgumus @joanlopez @AgnesToulet @szkiba — please review this PR in the next few days. Be sure to explicitly select |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
Testerinterface (the callback type forSelection.filter(),.is(), and.not()) declares its second parameter asElement:At runtime, however, k6/html passes a
Selectionto these callbacks, not anElement. Code that callsElement-only methods (e.g.querySelector) inside the callback passes type-checking but throws at runtime withTypeError: Object has no member 'querySelector'.The
Mapperinterface (for.map()) is already correctly typed asSelection. This PR alignsTesterto match.Fixes the type mismatch documented in grafana/k6#6088.
Checklist
My changes:
The package I'm changing:
@types/k6).