Skip to content

TypeScript guidelines: Document any requirement for callback parameters subject to bidirectional assignment#170

Open
MajorLift wants to merge 5 commits intomainfrom
jongsun/typescript/callback-any-contravariance
Open

TypeScript guidelines: Document any requirement for callback parameters subject to bidirectional assignment#170
MajorLift wants to merge 5 commits intomainfrom
jongsun/typescript/callback-any-contravariance

Conversation

@MajorLift
Copy link
Copy Markdown
Contributor

@MajorLift MajorLift commented Apr 14, 2026

View rendered version

I keep encountering this pattern. Seems worth documenting, especially since function contravariance is confusing enough on its own.


Note

Low Risk
Documentation-only change with no runtime behavior impact; risk is limited to potential confusion if the guidance is misapplied.

Overview
Adds a new TypeScript guideline section explaining when any is required for callback parameter types that must be assignable in both directions under --strictFunctionTypes (bidirectional assignment).

Includes an illustrative Wide/Narrow example, rationale for why unknown/never fail, guidance on scoping any to parameter positions (with intentional ESLint disable), and a couple of real-world references (e.g., messenger handler slots, coerces maps).

Reviewed by Cursor Bugbot for commit 5f5cc8f. Bugbot is set up for automated code reviews on this repo. Configure here.

@MajorLift MajorLift force-pushed the jongsun/typescript/callback-any-contravariance branch from f5a6e91 to 77548ad Compare April 14, 2026 21:22
Comment thread docs/typescript.md Outdated
@github-project-automation github-project-automation bot moved this to Needs dev review in PR review queue Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs dev review

Development

Successfully merging this pull request may close these issues.

1 participant