question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tsserver and intellisense hang indefinitely on "loading intellisense status" and "loading..." when using assertion function and complex conditional type

See original GitHub issue

Bug Report

🔎 Search Terms

tsserver typescript langauge server loading intellisense status indefinite error forever asserts assertion function vscode conditional type

🕗 Version & Regression Information

  • This changed between versions 4.7.4 and 4.8.0-beta and happens in all versions up to 4.9.0-dev.20221015

⏯ Playground Link

Unfortunately, painstakingly copy-pasting all the types from the various packages into the playground doesn’t allow me to reproduce the issue. So instead, I’ve created a minimal example repository that demonstrates the issue: https://github.com/Xunnamius/mre-typescript-issue-51188

💻 Code

import { visit, SKIP, type Visitor } from 'unist-util-visit';

import type { Content as MdastContent } from 'mdast';

function assertNonNullable<T>(
  value: T,
  err: string
): asserts value is NonNullable<T> {
  if (value === null) {
    throw new Error(err);
  }
}

export function visitAndReveal<Tree extends MdastContent>(
  tree: Tree,
  visitor?: Visitor,
  reverse?: boolean
) {
  visit(
    tree,
    'hidden',
    (node, index, parent) => {
      // UNCOMMENTING THIS WILL KILL INTELLISENSE
      // assertNonNullable(
      //   index,
      //   'error while revealing hidden node: node index is missing'
      // );

      // UNCOMMENTING THIS WILL KILL INTELLISENSE
      // assertNonNullable(
      //  parent,
      //  'error while revealing hidden node: node parent is missing'
      //);

      return visitor?.(node, index, parent) ?? [SKIP, index];
    },
    reverse
  );
}

🙁 Actual behavior

Tsserver and intellisense in vscode (latest version) hang when using a TypeScript version >=4.8.0-beta. See video example below.

🙂 Expected behavior

Tsserver/intellisense does not hang in latest versions of vscode and TypeScript.


https://user-images.githubusercontent.com/656017/195998496-e83d5c99-dc27-4867-8bcc-aa3d6a54ff55.mp4

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ahejlsbergcommented, Oct 27, 2022

For example, sometimes TS would give me “Type instantiation is excessively deep and possibly infinite” seemingly at random

That error is caused by our type instantiation governor when a single source element gives rise to >5M type instantiations. Any code that triggers this is definitely highly suspect. It looks like you were barely managing to squeeze under the limit in 4.7, so I would strongly recommend simplifying the types. In particular, the InclusiveDescendant<...> type appears expensive. I think it is trying to reduce the set of possible descendant types. I don’t know how important that added precision is, but it clearly comes at a very high cost.

1reaction
Xunnamiuscommented, Oct 27, 2022

For example, checking the visitAndReveal function in the example causes ~5.8M type instantiations in 4.7 when compiled with tsc. This shrinks to ~1.2M type instantiations in 4.8 and later. Those numbers are big warning flags that the types are too complex.

Thanks for taking a look! I had a suspicion complexity was a problem after some other small issues with the types coming from the unist-util-visit package. For example, sometimes TS would give me “Type instantiation is excessively deep and possibly infinite” seemingly at random, then I’d restart the language server, and it would return the expected type.

cc unified team: @wooorm

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix Visual Studio Code IntelliSense Loading Infinitely
In this short article, I'm sharing the reason of this issue and my way of fixing it. How VS Code Infinite IntelliSense Loading...
Read more >
IntelliJ IDEA 2019.2 EAP (192.4205.1 build) Release Notes
Feature IDEA‑210929 Provide ability to copy a TBX link to a settings Feature IDEA‑210961 Implement action for Slow Startup Profiling Feature IDEA‑111333 Provide Sublime Text...
Read more >
visual studio code - Intellisense stuck on loading with typescript
I've also to check if "TypeScript and JavaScript Language Features" was enable. Here is my tsconfig.json { "compilerOptions": { "noImplicitAny": ...
Read more >
NixOS - DistroWatch.com
In NixOS, the entire operating system, including the kernel, applications, system packages and configuration files, are built by the Nix package manager. Nix ......
Read more >
Untitled
... .experts-exchange.com/questions/26298885/rst-MoveLast-taking-forever.html ... -remove-the-table-from-set-integrity-pending-state-in-db2-after-load.html ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found