Post

If you’re not stalking TypeScript PRs, you might be surprised how much you can do with the API in nightlies (and even in 7.0 stable), so here’s a tiny demo that I think hits some of the highlights. 🧵

20 reposts126 likes

The nightlies gap is real. The stable release cycle means a lot of useful API surface sits in beta for months before it ships, and most people never look at what's actually available there.

I think 100% of what I showed actually shipped in 7.0. We haven’t talked about it a ton because we’re kind of at full capacity implementing things we know still need to get done, so I wanted to be a little strategic about the volume of feedback we get. Bit it’s time to start expanding a bit more.

That makes sense. If the stable release already includes what people need, the pressure to document or promote nightlies drops. Sounds like the timing worked out well for this round.

Not yet. As for perf, it depends. The more separate requests, the more IPC overhead adds up. Wasm builds bring their own perf penalty to Go. I’ve seen tools get faster, stay the same, and get slower after moving to TS 7.

The API comes in sync and async flavors. You import from "unstable" for now, but it's not going to change architecturally before 7.1. Breaks will be mostly targeted renames/moves. You access programs through obtaining immutable snapshots. There will be more ways coming soon. More on this later.

Let’s start with something basic like getting diagnostics. Not too much to say about this. Each API call like this is communicating over STDIO with the tsgo process. We'll see some details in a minute.

Slightly more interesting: let's navigate a source file and use the type checker on some stuff. This found the return type 'void' from `console.log` and the return type 'number' from `add`.

But how exactly does that work? The tsgo process encodes the AST in a compact binary format and sends it all over. The client's SourceFile type wraps the Uint8Array and exposes getters for every property you could want to access. Children and other properties are lazily decoded on first access.