Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Interface 'TransformOptionsTsJest' incorrectly extends interface 'TransformOptions<unknown>' compile error #4028

Closed
DetachHead opened this issue Mar 14, 2023 · 4 comments · Fixed by #4196
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@DetachHead
Copy link

DetachHead commented Mar 14, 2023

Version

29.0.5

Steps to reproduce

  1. import a type from ts-jest in your jest.config.ts, eg:
    import type { JestConfigWithTsJest } from 'ts-jest/dist/types'
  2. disable skipLibCheck in your tsconfig
  3. run tsc

repro repo: https://github.com/DetachHead/typescript-nodejs-project/tree/ed417986d0671525f46efd14e2e4a367891863aa

Expected behavior

no compile error

Actual behavior

>tsc
node_modules/ts-jest/dist/types.d.ts:128:18 - error TS2430: Interface 'TransformOptionsTsJest' incorrectly extends interface 'TransformOptions<unknown>'.
  Types of property 'config' are incompatible.
    Type 'ProjectConfigTsJest' is missing the following properties from type 'ProjectConfig': fakeTimers, id, openHandlesTimeout, sandboxInjectedGlobals

128 export interface TransformOptionsTsJest extends TransformOptions {
                     ~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in node_modules/ts-jest/dist/types.d.ts:128

Debug log

n/a, ts-jest is not being run

Additional context

No response

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11500T @ 1.50GHz
  Binaries:
    Node: 19.7.0 - ~\AppData\Roaming\node\node.EXE
    npm: 9.5.0 - ~\AppData\Roaming\node\npm.CMD
  npmPackages:
    jest: ^29.5.0 => 29.5.0
@Maxim-Mazurok
Copy link

Maxim-Mazurok commented Apr 1, 2023

I believe I'm getting the same error:

../../node_modules/ts-jest/dist/legacy/ts-jest-transformer.d.ts:19:5 - error TS2416: Property 'process' in type 'TsJestTransformer' is not 
assignable to the same property in base type 'SyncTransformer<unknown>'.
  Type '(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest) => TransformedSource' is not assignable to type 
'(sourceText: string, sourcePath: string, options: TransformOptions<unknown>) => TransformedSource'.
    Types of parameters 'transformOptions' and 'options' are incompatible.
      Type 'TransformOptions<unknown>' is not assignable to type 'TransformOptionsTsJest'.
        Types of property 'config' are incompatible.
          Property 'openHandlesTimeout' is missing in type 'ProjectConfig' but required in type 'ProjectConfigTsJest'.

19     process(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): TransformedSource;
       ~~~~~~~

  ../../node_modules/@jest/types/build/index.d.ts:950:3
    950   openHandlesTimeout: number;
          ~~~~~~~~~~~~~~~~~~
    'openHandlesTimeout' is declared here.

../../node_modules/ts-jest/dist/legacy/ts-jest-transformer.d.ts:20:5 - error TS2416: Property 'processAsync' in type 'TsJestTransformer' is not assignable to the same property in base type 'SyncTransformer<unknown>'.
  Type '(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest) => Promise<TransformedSource>' is not assignable to type '(sourceText: string, sourcePath: string, options: TransformOptions<unknown>) => Promise<TransformedSource>'.
    Types of parameters 'transformOptions' and 'options' are incompatible.
      Type 'TransformOptions<unknown>' is not assignable to type 'TransformOptionsTsJest'.

20     processAsync(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): Promise<TransformedSource>;
       ~~~~~~~~~~~~

../../node_modules/ts-jest/dist/legacy/ts-jest-transformer.d.ts:30:5 - error TS2416: Property 'getCacheKey' in type 'TsJestTransformer' is 
not assignable to the same property in base type 'SyncTransformer<unknown>'.
  Type '(fileContent: string, filePath: string, transformOptions: TransformOptionsTsJest) => string' is not assignable to type '(sourceText: string, sourcePath: string, options: TransformOptions<unknown>) => string'.
    Types of parameters 'transformOptions' and 'options' are incompatible.
      Type 'TransformOptions<unknown>' is not assignable to type 'TransformOptionsTsJest'.

30     getCacheKey(fileContent: string, filePath: string, transformOptions: TransformOptionsTsJest): string;
       ~~~~~~~~~~~

../../node_modules/ts-jest/dist/legacy/ts-jest-transformer.d.ts:31:5 - error TS2416: Property 'getCacheKeyAsync' in type 'TsJestTransformer' is not assignable to the same property in base type 'SyncTransformer<unknown>'.
  Type '(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest) => Promise<string>' is not assignable to type '(sourceText: string, sourcePath: string, options: TransformOptions<unknown>) => Promise<string>'.
    Types of parameters 'transformOptions' and 'options' are incompatible.
      Type 'TransformOptions<unknown>' is not assignable to type 'TransformOptionsTsJest'.

31     getCacheKeyAsync(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): Promise<string>;
       ~~~~~~~~~~~~~~~~


Found 4 errors in the same file, starting at: ../../node_modules/ts-jest/dist/legacy/ts-jest-transformer.d.ts:19

Both of these seem to resolve the issue

"compilerOptions": {
  "strict": false
}

or

"compilerOptions": {
  "skipLibCheck": true
}

@ahnpnl
Copy link
Collaborator

ahnpnl commented Apr 3, 2023

PR is welcome

@Maxim-Mazurok
Copy link

I ended up avoiding this error altogether by completing the migration to vitest

@ologbonowiwi
Copy link
Contributor

PR open as a possible solution to this one @ahnpnl

@ahnpnl ahnpnl closed this as completed Jan 22, 2024
Vylpes pushed a commit to Vylpes/Droplet that referenced this issue Apr 10, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [ts-jest](https://kulshekhar.github.io/ts-jest) ([source](https://github.com/kulshekhar/ts-jest)) | devDependencies | patch | [`29.1.1` -> `29.1.2`](https://renovatebot.com/diffs/npm/ts-jest/29.1.1/29.1.2) |

---

### Release Notes

<details>
<summary>kulshekhar/ts-jest (ts-jest)</summary>

### [`v29.1.2`](https://github.com/kulshekhar/ts-jest/blob/HEAD/CHANGELOG.md#2912-2024-01-22)

[Compare Source](kulshekhar/ts-jest@v29.1.1...v29.1.2)

##### Bug Fixes

-   calculated cache key based on `supportsStaticESM` ([a5d6f2d](kulshekhar/ts-jest@a5d6f2d))
-   correct error handling in `processAsync` ([e7be4bf](kulshekhar/ts-jest@e7be4bf)), closes [#&#8203;4207](kulshekhar/ts-jest#4207)
-   use `Config.ProjectConfig` ([918312b](kulshekhar/ts-jest@918312b)), closes [#&#8203;4028](kulshekhar/ts-jest#4028)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/Droplet/pulls/264
Reviewed-by: Vylpes <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
Vylpes pushed a commit to Vylpes/vylbot-app that referenced this issue Apr 10, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [ts-jest](https://kulshekhar.github.io/ts-jest) ([source](https://github.com/kulshekhar/ts-jest)) | dependencies | patch | [`29.1.1` -> `29.1.2`](https://renovatebot.com/diffs/npm/ts-jest/29.1.1/29.1.2) |

---

### Release Notes

<details>
<summary>kulshekhar/ts-jest (ts-jest)</summary>

### [`v29.1.2`](https://github.com/kulshekhar/ts-jest/blob/HEAD/CHANGELOG.md#2912-2024-01-22)

[Compare Source](kulshekhar/ts-jest@v29.1.1...v29.1.2)

##### Bug Fixes

-   calculated cache key based on `supportsStaticESM` ([a5d6f2d](kulshekhar/ts-jest@a5d6f2d))
-   correct error handling in `processAsync` ([e7be4bf](kulshekhar/ts-jest@e7be4bf)), closes [#&#8203;4207](kulshekhar/ts-jest#4207)
-   use `Config.ProjectConfig` ([918312b](kulshekhar/ts-jest@918312b)), closes [#&#8203;4028](kulshekhar/ts-jest#4028)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/400
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
Vylpes pushed a commit to Vylpes/random-bunny that referenced this issue Apr 10, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [ts-jest](https://kulshekhar.github.io/ts-jest) ([source](https://github.com/kulshekhar/ts-jest)) | devDependencies | patch | [`29.1.1` -> `29.1.2`](https://renovatebot.com/diffs/npm/ts-jest/29.1.1/29.1.2) |

---

### Release Notes

<details>
<summary>kulshekhar/ts-jest (ts-jest)</summary>

### [`v29.1.2`](https://github.com/kulshekhar/ts-jest/blob/HEAD/CHANGELOG.md#2912-2024-01-22)

[Compare Source](kulshekhar/ts-jest@v29.1.1...v29.1.2)

##### Bug Fixes

-   calculated cache key based on `supportsStaticESM` ([a5d6f2d](kulshekhar/ts-jest@a5d6f2d))
-   correct error handling in `processAsync` ([e7be4bf](kulshekhar/ts-jest@e7be4bf)), closes [#&#8203;4207](kulshekhar/ts-jest#4207)
-   use `Config.ProjectConfig` ([918312b](kulshekhar/ts-jest@918312b)), closes [#&#8203;4028](kulshekhar/ts-jest#4028)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/random-bunny/pulls/143
Reviewed-by: Vylpes <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants