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]: Latest set methods not supported #4640

Open
manticorp opened this issue Nov 28, 2024 · 0 comments
Open

[Bug]: Latest set methods not supported #4640

manticorp opened this issue Nov 28, 2024 · 0 comments

Comments

@manticorp
Copy link

Version

29.2.5

Steps to reproduce

Do the following:

npm init
npm install --save-dev jest typescript ts-jest @types/jest
npx ts-jest config:init
npx tsc --init

Then change tsconfig to add (leaving all other defaults):

{
  "exclude": ["tests"],
  "compilerOptions": {
    "rootDir": "./src",
    "outDir": "./dist",
    "target": "esnext",
    // all other defaults
  }
}

Then create "src/setTest.ts":

export default function SetTest() {
  const a = new Set([1, 2]);
  const b = new Set([2, 3]);

  return a.intersection(b);
};

and create "tests/setTest.test.ts":

import SetTest from './../src/setTest';

test('Test it works', () => {
  const c = SetTest();
  expect(c).toBeInstanceOf(Set);
});

run:

npx tsc
npx jest

Expected behavior

Passing test

Actual behavior

Failing test:

 FAIL  tests/setTest.test.ts
  × Test it works (1 ms)

  ● Test it works

    TypeError: a.intersection is not a function

      3 |   const b = new Set([2, 3]);
      4 |
    > 5 |   return a.intersection(b);
        |            ^
      6 | };

      at SetTest (src/setTest.ts:5:12)
      at Object.<anonymous> (tests/setTest.test.ts:4:20)

image

However, code compiles fine.

Debug log

N/A

Additional context

Does ts-jest not just use the typescript version used in the project?

Environment

System:
    OS: Windows 11 10.0.26100
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
  Binaries:
    Node: 20.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.12.1 - ~\AppData\Roaming\npm\pnpm.CMD
  npmPackages:
    jest: ^29.7.0 => 29.7.0


Also fails under Ubuntu running in WSL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant