Minimal reproducible examples for false positives in oxlint's typescript/no-unnecessary-type-assertion rule when typeAware is enabled.
Root cause: oxlint resolves generic type parameters from the as assertion target, rather than using the declared default. This causes it to conclude the expression "already has" the asserted type.
Each case is a self-contained project with its own dependencies.
querySelector<E extends Element = Element>() — assertion to a subtype like HTMLCanvasElement | null is flagged as unnecessary.
- Status: Fixed in
oxlint-tsgolint0.17.2 (see oxc#20656) - Reproduces on:
oxlint-tsgolint0.17.1
load<T = unknown>() — assertion from unknown to Record<string, unknown> is flagged as unnecessary.
- Status: Open
- Reproduces on:
oxlint-tsgolint0.17.2
cd cases/<case-name>
pnpm install
pnpm run lint