unist-util-visit: Causes tsc to stall indefinitely

Initial checklist

Affected packages and versions

4.1.0

Link to runnable example

No response

Steps to reproduce

clone https://github.com/cjroebuck/next-build-stalled

npm i
npx tsc

typescript version 4.5.2

(typescript version 4.4.3 does build ok)

Expected behavior

build shouldn’t stall

Actual behavior

build stalls indefinitely

In order to get the build to pass, comment out this line

I suspect it’s an issue with the unist-util-visit types?

Runtime

Node v16

Package manager

npm v7

OS

macOS

Build and bundle tools

Next.js

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Alternative to pinning typescript version - you can pin unist-util-visit to 4.0.0 and also avoid the tsc hang.

This has been resolved in TypeScript 4.6 https://devblogs.microsoft.com/typescript/announcing-typescript-4-6/#improved-recursion-depth-checks The fix has also been backported to 4.5

You may already have this change because it was cherry-picked into TypeScript 4.5.3

I think this could be a temporary solution。 The idea is to solve the problem by switching versions of typescript。 Modify the default typescript mode of vscode as shown in the documentation below: using-the-workspace-version-of-typescript

steps:

  1. open vscode settings.json
  2. add typescript.tsdk filed
  3. specify the typescript path you want to use

I installed the specified version of the current project:

yarn add typescript@4.4.4

Modified the vscode configuration file:

       ... other fields here ....
"typescript.tsdk": "./node_modules/typescript/lib"

problem off for me now.

Thanks for reaching out @cjroebuck and @benatkin! Sorry you ran into a spot of trouble. This is indeed an issue in TypeScript, @stefanprobst also caught it in https://github.com/unifiedjs/unified/discussions/175 and narrowed it down to being a bug which was reported in TypeScript microsoft/TypeScript#46900 (which you’ve noted as well). We’re all waiting for a fix in TypeScript. Pinning the TypeScript version to 4.4.3 is the work around for now.