TS 7: Property 'not' does not exist on type Assertion<void, T>
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- testing-qa
Research direction
Start at the exported Assertion type declaration and the Vitest assertion typings described in the issue. Reproduce the failure with the three files shown and run pnpm exec tsc --noEmit. The work is done when expect("a").not.toBe("b") typechecks under TypeScript 7.0.2 without affecting the existing runtime API.
Written by the indexing model from the issue text.
Description
Describe the bug
On TypeScript 7.0.2, expect(value).not.toBe(...) fails to typecheck:
error TS2339: Property 'not' does not exist on type 'Assertion<void, string>'.
Runtime is fine. Vitest 5.0.0 documents .not and the Jest/Chai APIs both use it.
Assertion does not declare not. It is supposed to come from the circular mapped type over Chai.Assertion:
type VitestAssertion<A, R extends void | Promise<void>, T = unknown> = {
[K in keyof A]: A[K] extends Chai.Assertion
? Assertion<R, T>
: /* ... */
} & ((type: string, message?: string) => Assertion<R, T>)
export interface Assertion<R extends void | Promise<void> = void, T = unknown>
extends VitestAssertion<Chai.Assertion, R, T>,
JestAssertion<R, T>,
ChaiMockAssertion<R, T>,
Matchers<R, T> { /* ... */ }
Under TypeScript 7 that mapping drops .not. Declaring not: Assertion<R, T> on Assertion restores it.
Happy to send a one-line PR if you want that explicit field.
Reproduction
Three files. Then pnpm exec tsc --noEmit.
package.json:
{
"type": "module",
"devDependencies": {
"typescript": "7.0.2",
"vitest": "5.0.0"
}
}
tsconfig.json:
{
"compilerOptions": {
"strict": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"skipLibCheck": true
},
"include": ["repro.ts"]
}
repro.ts:
import { expect } from "vitest"
expect("a").not.toBe("b")
Expected: tsc --noEmit succeeds (same as TypeScript 5 with Vitest 4).
Actual:
repro.ts:3:13 - error TS2339: Property 'not' does not exist on type 'Assertion<void, string>'.
System Info
System:
OS: macOS (Darwin arm64)
Binaries:
Node: 24.14.1
pnpm: 12.3.1
npmPackages:
typescript: 7.0.2
vitest: 5.0.0
vite: 8.2.2
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 89
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vitest-dev/vitest
-
pending triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
vitest-dev/vitest#11276 · 3 reactions ·
-
pending triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vitest-dev/vitest#11019 · 5 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
vitest-dev/vitest#10940 ·
-
p2-nice-to-have
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
vitest-dev/vitest#10793 · 1 comment ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vitest-dev/vitest#10381 · 2 comments ·
All issues in vitest-dev/vitest
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100