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

@types/jest v28 introduces circularly reference #3619

Closed
mmuller88 opened this issue Jun 26, 2022 · 6 comments
Closed

@types/jest v28 introduces circularly reference #3619

mmuller88 opened this issue Jun 26, 2022 · 6 comments
Labels
bug This issue is a bug. effort/large Large work item – several weeks of effort p1

Comments

@mmuller88
Copy link

mmuller88 commented Jun 26, 2022

Describe the bug

When using dependency "@types/jest": "28.1.3" a circular reference error is thrown:

:space_invader: build » compile | jsii --silence-warnings=reserved-word [2022-06-26T08:37:09.762] [ERROR] jsii/compiler - Compilation errors prevented the JSII assembly from being created node_modules/@sinclair/typebox/typebox.d.ts:237:21 - error TS2456: Type alias 'StaticIntersectReduce' circularly references itself. 237 export declare type StaticIntersectReduce<I extends unknown, T extends readonly any[]> = T extends [infer A, ...infer B] ? StaticIntersectReduce<I & A, B> : I;

using yarn why @sinclair/typebox revealed that @sinclair/typebox is used by @types/jest .

Expected Behavior

no circular reference error thrown

Current Behavior

circular reference error thrown

Reproduction Steps

  1. Create new / update CDK construct library with projen (that should update the mentioned package to > 28
  2. run yarn build

Possible Solution

Fix version to 27.4.1 fixed the issue for me

Additional Information/Context

No response

SDK version used

1.61.0

Environment details (OS name and version, etc.)

MacOS

@mmuller88 mmuller88 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 26, 2022
@mmuller88
Copy link
Author

mmuller88 commented Jun 28, 2022

Looks like related to #3609

@RomainMuller
Copy link
Contributor

Yeah - we are in this situation largely because we're still on TypeScript 3.9, and most of the ecosystem around us is gradually adopting TypeScript 4.3 to 4.5 minimum targets (for obvious reasons).

There is also aws/aws-cdk-rfcs#373 where I propose to have jsii and jsii-rosetta follow TypeScript compiler versions, so we can easily follow the "current" TypeScript release train in the future...


In the meantime - the next release of jsii will include #3623, which also introduces the ability to specify types in the jsii.tsc stanza in package.json so you can manually pick what @types/* packages are loaded in the global namespace, so you do not hit this problem when running jsii (you would need to exclude tests from the jsii compilation scope, and either use ts-jest or compile them separately with a "recent" typescript compiler -- that is definitely more work than pinning jest to an older release 😭).

@agdimech
Copy link
Contributor

Would setting skipLibCheck to true prevent jsii from looking in node_modules to begin with?

@peterwoodworth peterwoodworth added effort/large Large work item – several weeks of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jul 21, 2022
@RomainMuller
Copy link
Contributor

Would setting skipLibCheck to true prevent jsii from looking in node_modules to begin with?

I'm not sure... it could have other consequences on the TypeChecker AST we obtain during parsing, so I'm reluctant to resort to this...

@mrgrain
Copy link
Contributor

mrgrain commented Apr 18, 2024

Fixed by supporting modern TS versions.

@mrgrain mrgrain closed this as completed Apr 18, 2024
Copy link
Contributor

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/large Large work item – several weeks of effort p1
Projects
None yet
Development

No branches or pull requests

5 participants