Skip to content

Typings issues with exactOptionalPropertyTypes and Disposable #9854

@mnaoumov

Description

@mnaoumov

Describe the bug

When I set in tsconfig.json: "skipLibCheck": false and "exactOptionalPropertyTypes": true,

Get compiler issues

node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts:1407:11 - error TS2430: Interface 'FailureScreenshotArtifactAttachment' incorrectly extends interface 'TestAttachment'.
  Types of property 'body' are incompatible.
    Type 'undefined' is not assignable to type 'string | Uint8Array<ArrayBufferLike>'.

1407 interface FailureScreenshotArtifactAttachment extends TestAttachment {
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@vitest/runner/dist/tasks.d-D2GKpdwQ.d.ts:1418:11 - error TS2430: Interface 'FailureScreenshotArtifact' incorrectly extends interface 'TestArtifactBase'.
  Types of property 'attachments' are incompatible.
    Type '[FailureScreenshotArtifactAttachment] | []' is not assignable to type 'TestAttachment[]'.
      Type '[FailureScreenshotArtifactAttachment]' is not assignable to type 'TestAttachment[]'.
        Type 'FailureScreenshotArtifactAttachment' is not assignable to type 'TestAttachment' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
          Types of property 'body' are incompatible.
            Type 'undefined' is not assignable to type 'string | Uint8Array<ArrayBufferLike>'.

1418 interface FailureScreenshotArtifact extends TestArtifactBase {
               ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@vitest/spy/dist/index.d.ts:158:81 - error TS2304: Cannot find name 'Disposable'.

158 interface MockInstance<T extends Procedure | Constructable = Procedure> extends Disposable {
                                                                                    ~~~~~~~~~~

node_modules/vitest/dist/index.d.ts:357:83 - error TS2304: Cannot find name 'Disposable'.

357  doMock(path: string, factory?: ModuleMockFactoryWithHelper | ModuleMockOptions): Disposable;
                                                                                      ~~~~~~~~~~

node_modules/vitest/dist/index.d.ts:358:95 - error TS2304: Cannot find name 'Disposable'.

358  doMock<T>(module: Promise<T>, factory?: ModuleMockFactoryWithHelper<T> | ModuleMockOptions): Disposable;
                                                                                                  ~~~~~~~~~~


Found 5 errors.

Disposable issue can be fixed by switch to ESNext, however, it's a questionable fix...

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-gjqbkk8w

System Info

System:
    OS: Windows 11 10.0.26200
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Memory: 4.23 GB / 31.86 GB
  Binaries:
    Node: 25.4.0 - C:\nvm4w\nodejs\node.EXE
    npm: 11.7.0 - C:\nvm4w\nodejs\npm.CMD
  Browsers:
    Chrome: 145.0.7632.117
    Edge: Chromium (140.0.3485.54)
    Firefox: 138.0.1 - C:\Program Files\Mozilla Firefox\firefox.exe
  npmPackages:
    @vitest/coverage-v8: latest => 4.1.0
    vitest: latest => 4.1.0

Used Package Manager

npm

Validations

Metadata

Metadata

Type

Projects

Status

P2 - 2

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions