TypeScript: TS hangs up entire computer, type of variables stuck at "Loading..."
🔎 Search Terms
TS intellisense not working, TS hangs up entire PC, Type inference not working
🕗 Version & Regression Information
- This is a crash using version 5.4.5
- I tried versions 5.4.3, 5.4.5, and 5.5
- This issue sprung up out of nowhere, I have no idea about the origin
⏯ Reproduction steps
To reproduce this issue please clone the following repository - https://github.com/slyofzero/TONBuyBot
Install the packages using pnpm - pnpm i
Visit the file - ./src/bot/commands/index.ts
💻 Code
The file code in question is very tame -
import { teleBot } from "@/index";
import { startBot } from "./start";
import { log, errorHandler } from "@/utils/handlers";
import { settings } from "./settings";
import { setEmojiCommand } from "./setEmoji";
import { stopBot } from "./stop";
import { setGifCommand } from "./setGif";
export function initiateBotCommands() {
teleBot.api
.setMyCommands([
{ command: "start", description: "Start the bot" },
{ command: "stop", description: "Stop the bot" },
{ command: "settings", description: "To customize the bot" },
{ command: "setemoji", description: "To set an emoji" },
{ command: "setgif", description: "To set a GIF" },
])
.catch((e) => errorHandler(e));
teleBot.command("start", (ctx) => startBot(ctx));
teleBot.command("stop", (ctx) => stopBot(ctx));
teleBot.command("settings", (ctx) => settings(ctx));
teleBot.command("setemoji", (ctx) => setEmojiCommand(ctx));
teleBot.hears(/\/setgif/, (ctx) => setGifCommand(ctx, true));
// @ts-expect-error CTX type invalid
teleBot.on(":animation", (ctx) => setGifCommand(ctx));
log("Bot commands up");
}
The above code is used to setup a telegram bot’s commands using grammy.js
🙁 Actual behavior
Update - The issue only occurs when I open the ./src/bot/commands/index.ts file of the repository I share above in reproduction steps.
Uptil yesterday night VSCode and Typescript Intellisense worked fine but now types of variables upon hovering are indefinitely stuck at “Loading…”
This is followed by a high spike in CPU and RAM usage
The icon to the bottom right showing TS server status keeps spinning followed followed by the spike in CPU and RAM usage mentioned above.
Because of all these issues, using the computer with the project on is next to impossible. Typescript syntax errors, Intellisense, or Type inference, nothing works. I first tried uninstalling and reinstalling VSCode but that didn’t fix it. I formatted by hard drive and reinstalled my OS but the problem still persists. I have gone through the below two issues that sounds similar to my problem but haven’t found a fix yet.
https://github.com/microsoft/TypeScript/issues/35512 https://github.com/microsoft/vscode/issues/87870
🙂 Expected behavior
The expected behaviour would be smooth Intellisense, type inference, and an average usage of CPU and RAM not affecting other functionalities of my PC.
Additional information about the issue
I have tried this issue on two different devices and two different OS and been able to reproduce on both.
First device was an i3, 8GB RAM Dell Inspiron 5482 with Windows 10 Second device is an AMD Ryzen 7 6800, 32GB RAM, 8GB RTX 3070, Lenovo Legion 5 Pro with Windows 11
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 21 (16 by maintainers)
and there go my weekend plans… 😭
I tracked down the problem, it was because of the file
backend/app/validators/field.ts. I wasted so much time on tracking it down!I didn’t see any errors, but the Typescript server hanged every time. The issue didn’t happen anywhere else, and its effect was in the frontend. It makes me think there may be a bug.
I’m still working on minimizing this further but I want to share a single-file repro created based on the code from grammy. Some parts of this probably no longer make sense (I remove bits that make sense for what their types want to achieve but which are not relevant for the repro):
repro
I will continue working on this - so far, what I was able to notice is that
AliasPropsbeing a renaming mapped type impacts this.I see I forgot to report back here. My conclusion was this example is “simply” extreme.
getReducedTypeincurs some extra work here and it adds up. Unfortunately, I don’t know how to improve this.See https://github.com/grammyjs/grammY/pull/553. Looks like this is a known issue that was fixed by in the latest
grammy. I’d still be interested in knowing why #57345 slowed down the old types, but appears there’s a simple workaround.Ok, I can reproduce with your repo. The difference is you’re using an older version of
grammy, 1.20.3. Current version on NPM is 1.22.4 and it doesn’t have a problem.Bisects to #57345