From 9c58135410a4fb9fcf3af9fd175f47c106b3e710 Mon Sep 17 00:00:00 2001 From: Jack DeVries Date: Fri, 1 Mar 2024 13:02:31 -0500 Subject: [PATCH 1/3] Callout performance characteristics of ts-server While reading the guide with an eye for improving the editor experience, I was not sure how ts-server behaves, or how fixing hotspots I view during tracing would change the editing experience. I ended up jumping into Discord for clarity, and this is a summary of what I learned. --- Performance.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Performance.md b/Performance.md index 5c47046..bc8fcc9 100644 --- a/Performance.md +++ b/Performance.md @@ -492,6 +492,16 @@ Isolated file emit can be leveraged by using the following tools: * [ts-jest](https://kulshekhar.github.io/ts-jest/) can use be configured with the [`isolatedModules` flag set to `true`]isolatedModules: true(. * [ts-node](https://www.npmjs.com/package/ts-node) can detect [the `"transpileOnly"` option in the `"ts-node"` field of a `tsconfig.json`, and also has a `--transpile-only` flag](https://www.npmjs.com/package/ts-node#cli-and-programmatic-options). +# Optimizing Editing Experience; Performance of `ts-server` + +`ts-server`'s performance characteristics will always be related to the +performance of type-checking your entire project using `tsc`, so the other +performance optimization guidance here also applies to improving the editing +experience. As you type, the checker is completely starting from scratch, but it +only requests information about what you're typing. This means that the editing +experience can vary based on how much work TypeScript needs to do to check the +type of what you are actively editing. + # Investigating Issues There are certain ways to get hints of what might be going wrong. From 1dd00afb2402ae78be118ae164f190561ac7e466 Mon Sep 17 00:00:00 2001 From: Jack DeVries Date: Sun, 17 Mar 2024 22:16:33 -0400 Subject: [PATCH 2/3] chore: format one sentence per line --- Performance.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Performance.md b/Performance.md index bc8fcc9..d641925 100644 --- a/Performance.md +++ b/Performance.md @@ -494,13 +494,9 @@ Isolated file emit can be leveraged by using the following tools: # Optimizing Editing Experience; Performance of `ts-server` -`ts-server`'s performance characteristics will always be related to the -performance of type-checking your entire project using `tsc`, so the other -performance optimization guidance here also applies to improving the editing -experience. As you type, the checker is completely starting from scratch, but it -only requests information about what you're typing. This means that the editing -experience can vary based on how much work TypeScript needs to do to check the -type of what you are actively editing. +In-editor diagnostics are typically fetched a few seconds after typing stops. +`ts-server`'s performance characteristics will always be related to the performance of type-checking your entire project using `tsc`, so the other performance optimization guidance here also applies to improving the editing experience. +As you type, the checker is completely starting from scratch, but it only requests information about what you're typing. # Investigating Issues From 29848d28e22e620805f315c00862c12e005dd6ed Mon Sep 17 00:00:00 2001 From: Jack DeVries Date: Sun, 17 Mar 2024 22:16:45 -0400 Subject: [PATCH 3/3] feat: add details re diagnostics --- Performance.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Performance.md b/Performance.md index d641925..7bf4dbe 100644 --- a/Performance.md +++ b/Performance.md @@ -497,6 +497,9 @@ Isolated file emit can be leveraged by using the following tools: In-editor diagnostics are typically fetched a few seconds after typing stops. `ts-server`'s performance characteristics will always be related to the performance of type-checking your entire project using `tsc`, so the other performance optimization guidance here also applies to improving the editing experience. As you type, the checker is completely starting from scratch, but it only requests information about what you're typing. +This means that the editing experience can vary based on how much work TypeScript needs to do to check the type of what you are actively editing. +In most editors, like VS Code, diagnostics are requested for all open files, not the entire project. +Accordingly, diagnostics will appear faster compared to checking the entire project with `tsc`, but slower than viewing a type with hover, since viewing a type with hover _only_ asks TypeScript to compute and check that specific type. # Investigating Issues