preactjs / enzyme-adapter-preact-pure

Preact adapter for the Enzyme UI testing library
MIT License
67 stars 17 forks source link

Module '"enzyme"' has no exported ... #259

Open cieniawska opened 1 year ago

cieniawska commented 1 year ago

Hello,

after upgrading to typescript v5.2.2 I'm facing some issues with your package.

Screenshot 2023-09-25 at 11 49 57

I'm using:

Can you please assist?

robertknight commented 1 year ago

I can reproduce with examples/typescript/ in this repository by upgrading the typescript dependency to a 5.x release. It looks like the extensions to the Enzyme types in https://github.com/preactjs/enzyme-adapter-preact-pure/blob/master/index.d.ts, which are included in the package, are not being seen by TS any more.

For examples/typescript/ I was able to work around this by manually copying the types into the local project:

cd examples/typescript/
npm install typescript@latest
cp node_modules/enzyme-adapter-preact-pure/index.d.ts enzyme-extensions.d.ts
npm test

I am not sure of the proper fix for this in TS 5.0 offhand. If anyone knows, feel free to chime in.

cieniawska commented 11 months ago

hello, is there anything else we could do about it? 🤔

janek-j-survicate commented 10 months ago

Also waiting for update

acelaya commented 8 months ago

A possible workaround for this is to reference "enzyme-adapter-preact-pure/index.d.ts" in your tsconfig.json compilerOptions.types setting.

{
  "compilerOptions": {
    // ...
    "types": ["enzyme-adapter-preact-pure/index.d.ts"],
  },
  // ...
}

I would have assumed that adding a reference as /// <reference types="enzyme-adapter-preact-pure/index.d.ts" /> should also work, but it doesn't.

The good thing about referencing the types from within the tsconfig file, is that you no longer need to add /// <reference types="enzyme-adapter-preact-pure" /> anywhere.