-
Notifications
You must be signed in to change notification settings - Fork 465
Open
Labels
Description
Version
29.1.2
Steps to reproduce
To be honest, I am not sure where to start searching for that bug, it's so strange. So I'm starting here with ts-jest
, as a best guess 🤷
- Create a
tsts.js
file exporting a functionsomeFunc
:
// src/tsts.js
const someFunc = (t) => t;
export { someFunc };
and its corresponding types tsts.d.ts
:
// src/tsts.d.ts
export declare const someFunc: (t: number) => number;
- Create another file
blo.ts
which imports the function fromtsts
and uses it :
// src/blo.ts
import { someFunc } from './tsts'
export const useSomeFunc = (a: number) => someFunc(a) + 1
Create a test that uses :
// src/blo.test.ts
import assert from 'assert'
import { useSomeFunc } from './blo'
describe('blo', () => {
it('should work', () => {
assert.strictEqual(useSomeFunc(1), 2)
})
})
Expected behavior
I expect the test to run and output :
PASS src/blo.test.ts
blo
✓ should work (1 ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 2.75 s
Ran all test suites.
Actual behavior
FAIL src/blo.test.ts
● Test suite failed to run
src/tsts.js:1:19 - error TS7006: Parameter 't' implicitly has an 'any' type.
1 const someFunc = (t) => t;
~
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 2.712 s
Ran all test suites.
Debug log
Additional context
Now's the interesting part : if I rename (and update imports) :
tsts.js -> bla.js
tsts.d.ts -> bla.d.ts
Everything works as expected.
On the other hand, I get the same bug if I rename like so :
tsts.js -> exports.js
tsts.d.ts -> exports.d.ts
Environment
System:
OS: Linux 6.5 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (8) x64 AMD Ryzen 5 PRO 3500U w/ Radeon Vega Mobile Gfx
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
npmPackages:
jest: ^29.4.3 => 29.7.0