Skip to content

Commit

Permalink
fix(test): don't fail build when jest typings can't be resolved (#5031)
Browse files Browse the repository at this point in the history
patch `getJestPreset` in the jest-stencil connector to return `any`
instead of an inferred type for the function. prior to this fix,
building a stencil project with jest 29 installed could lead to an error
such as:
```
TypeScript: node_modules/@stencil/core/testing/jest/jest-stencil-connector.d.ts:81:31
       Could not find a declaration file for module '@jest/types/build/Config'.
       '/PROJECT_DIRECTORY/node_modules/@jest/types/build/Config.js' implicitly
       has an 'any' type.If the '@jest/types' package actually exposes this module, try adding a new declaration
       (.d.ts) file containing `declare module '@jest/types/build/Config';`
```
Explicitly setting this return type to `any` is a temporary measure to
unblock adopters. A TODO for STENCIL-1003 has been added to resolve
this fully.

STENCIL-1002: bug: Stencil 4.7.x & Jest 29.5.7 TypeScript error
fixes: #5030
  • Loading branch information
rwaskiewicz committed Nov 8, 2023
1 parent 3426206 commit 5df16e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/testing/jest/jest-stencil-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ export const getJestSetupTestFramework = () => {
return getJestFacade().getJestSetupTestFramework();
};

// TODO(STENCIL-1003): Fix typing resolution bug where dynamic type imports would result in build failures for Jest 28/29
/**
* Retrieve Stencil's Jest presets for the detected version of Jest
*
* @returns an object representing a Jest preset
*/
export const getJestPreset = () => {
export const getJestPreset = (): any => {
return getJestFacade().getJestPreset();
};

0 comments on commit 5df16e6

Please sign in to comment.