DefinitelyTyped / DefinitelyTyped/DefinitelyTyped

[@types/styled-components] tsserver running at 100% CPU

Open
#34,749 16 comments 20 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
51.4k
Forks
30.4k
Avg merge
3d 21h
Merged PRs (30d)
108

Description

If you know how to fix the issue, make a pull request instead.

  • I tried using the @types/xxxx package and had problems.
  • I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • Mention the authors (see Definitions by: in index.d.ts) so they can respond.
    • Authors: @Igorbek @Igmat @lavoaster @Jessidhia
Versions
  • @types/styled-components@4.1.14
  • typescript@3.3.3
Summary

Upon upgrading to the latest version of @types/styled-components and using VS Code, I noticed that editing typescript files was suddenly causing my CPU usage to jump to 100%. My editor's typescript auto-complete features and lint warnings suddenly took multiple seconds to resolve after typing each character.

On further investigation, I could see that tsserver.js was responsible for all of that CPU usage. Downgrading one version at a time, I was able to isolate the performance slowdown to something that changed between @types/styled-components@4.0.3 and @types/styled-components@4.1.0.

It looks like the two commits added in that version are:

https://github.com/DefinitelyTyped/DefinitelyTyped/commit/5c49d4ddc6f5bd06c5cf04d911398f3db05ead54#diff-9726c25d6953300e0670141c0abac3db

https://github.com/DefinitelyTyped/DefinitelyTyped/commit/59ab5b3aef80fa55010f7d8385f785514d2e0b1a#diff-9726c25d6953300e0670141c0abac3db

To reproduce
  1. In a new typescript project:
yarn add typescript@3.3.3 styled-components@4.2.0 @types/styled-components@4.1.0
  1. Import styled-components and begin editing the file.

This issue seems similar, but not exactly the same: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34391

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the slowdown with the listed TypeScript, styled-components, and @types/styled-components versions, then compare the two linked commits that changed the styled-components definitions. Confirm the fix removes the tsserver 100% CPU behavior and restores responsive autocomplete and lint warnings while editing.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.