Hello,
I just updated my project dependencies today on a VueJS project. It resulted in following jest dependencies update in my package.json: "ts-jest": "^25.0.0" (previously ^24.1.0) and @types/jest": "^24.9.1"(previously ^24.0.21).
Now, when I run yarn serve and yarn build I get the following typing error:
ERROR in .../node_modules/jest-haste-map/build/index.d.ts(125,32):
125:32 Type 'typeof EventEmitter' is not a constructor function type.
123 | *
124 | */
> 125 | declare class HasteMap extends EventEmitter {
| ^
126 | private _buildPromise;
127 | private _cachePath;
128 | private _changeInterval?;
Version: typescript 3.7.5
Time: 13756ms
App running at:
- Local: http://localhost:3000/
- Network: http://192.168.11.62:3000/
Note that the development build is not optimized.
To create a production build, run yarn build.
Update "ts-jest" and "@types/jest" to the latest version.
Application builds normally as it did with previous versions of those packages.
It is a class: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/2a7deeea29c4806f6e77a6bbfff9a2801152aecf/types/node/events.d.ts#L41
Which version of @types/node do you have installed?
Facing same issue here. My @types/node is 13.5 - i.e. latest available.
鈹溾攢 @types/[email protected]
鈹斺攢 [email protected]
Did you update jest at all? Neither ts-jest or @types/jest are maintained in this repo, so if you only updated those deps you should open up an issue with them.
Regardless, this needs a reproduction
Yes, I did. After downgrading jest packages, including types/node from 13.5 to 13.1.8, it seems that something with @types/node made jest error.
According to https://www.npmjs.com/package/@types/node, time difference is just ~ 1 Week.
History of nodejs commits:
https://github.com/DefinitelyTyped/DefinitelyTyped/commits/master/types/node
Maybe relevant commits:
https://github.com/DefinitelyTyped/DefinitelyTyped/commit/19826ba267c2203e61d28b87f56ca28eac23a994#diff-320a69421ec88a833298a68535bea54a
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/41353
I don't get this error.
$ yarn init -y
$ yarn add @types/node typescript jest-haste-map
$ yarn tsc --init
$ vim index.ts
$ yarn tsc -b .
contents of index.ts:
import { EventEmitter } from 'events';
import HasteMap = require('jest-haste-map');
export default class OurEventEmitter extends EventEmitter {}
export { HasteMap };
I get no errors. Can you provide a reproduction?
@naimkhalifa and @dmpe It's a package conflict with @vue/cli-plugin-unit-jest
That package still uses jest 24.9.0, which breaks with @types/node 13.5.0
What worked for me (for now, at least) :
After yarn upgrade --latest, I did yarn add @types/[email protected] , forcing that downgraded version of @types/node to also be available
Right, so this is an issue with jest 24. We won't be releasing a patch for 24, so if you're impacted please upgrade to Jest 25
Thx @snelg, that worked for me too :)
Shouldn't the jest-haste-map line read declare class HasteMap extends EventEmitter.EventEmitter?
or the import be import {EventEmitter} from 'events';
Most helpful comment
@naimkhalifa and @dmpe It's a package conflict with
@vue/cli-plugin-unit-jestThat package still uses jest 24.9.0, which breaks with @types/node 13.5.0
What worked for me (for now, at least) :
After
yarn upgrade --latest, I didyarn add @types/[email protected], forcing that downgraded version of @types/node to also be available