GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — `vp migrate`: Recognize asynchronous assertions awaited through local variables · Issue #3131 · voidzero-dev/vite-plus Closed Copy link Labels DescriptionDescriptionWhen running This can occur in tests that intentionally inspect the return type of an asynchronous assertion before awaiting it: import { expect, expectTypeOf, it } from 'vite-plus/test'; it('checks an asynchronous matcher return type', async () => { const assertion = expect(Promise.resolve(1)).resolves.toBe(1); expectTypeOf(assertion).toEqualTypeOf<Promise<void>>(); await assertion; }); The assertion is properly awaited, and the test passes under Vitest v5. However, I understand that the migration analyzer intentionally uses conservative static analysis and that Because the warning persists across subsequent migration runs, it adds unnecessary review noise for code that has already been inspected and verified. It would be useful for the migration analyzer to recognize this pattern or provide a way to acknowledge intentionally retained code without repeatedly reporting the same finding. Suggested solutionExtend the Vitest v5 migration analyzer to recognize simple cases where an asynchronous assertion's returned promise is assigned to a local For example, the following should not produce an const assertion = expect(Promise.resolve(1)).resolves.toBe(1); expectTypeOf(assertion).toEqualTypeOf<Promise<void>>(); await assertion; The analysis could remain intentionally conservative for more complex control flow, reassigned variables, or cases where the promise may not be awaited on every execution path. This would preserve the existing safety checks while avoiding recurring findings for a common and easily verifiable pattern. AlternativeAn alternative would be to provide a documented mechanism for acknowledging or suppressing specific migration review findings. For example, a narrowly scoped inline directive or configuration option could allow developers to mark an This could also benefit other migration checks that intentionally report ambiguous cases requiring manual verification. I would prefer improved recognition of straightforward awaited bindings, but an acknowledgment mechanism would be useful when more complex code cannot be analyzed safely. Additional contextThis was encountered while upgrading a TypeScript application using Vite+ and Vitest v5. The original test verifies the return types of synchronous and asynchronous DOM matchers. The promise is intentionally retained in a variable so its type can be checked before awaiting it. Relevant migration analyzer implementation: https://github.com/voidzero-dev/vite-plus/blob/main/packages/cli/src/migration/vitest-v5/source.ts The current analyzer appears to determine whether an asynchronous assertion is awaited or returned primarily by examining its immediate AST parent. An assertion assigned to a local variable therefore produces a review item even when the variable is awaited later. The finding is reported as Observed output: The warning persists when rerunning This request concerns the usability and precision of Vite+'s migration diagnostics, not a Vitest runtime or assertion failure. Validations
Activity
MetadataMetadataAssigneesLabelsTypeFieldsPriority None yet Start date None yet Target date None yet Effort None yet ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |