And, you know, the version of TypeScript that runs in the TypeChecker is going to constrain itself to fit within the scope of this proposal. And the folks that really want full syntactical freedom, they still have the capabilities to do that via the .ts files. But they're going to be like more of an edge case within the world of JavaScript, in my opinion.
The next one is that like they want to separate out type features versus runtime features in order to really specify that, you know, a type the type extensions can't really edit the code that's running. And, like, within the context of TypeScript, there are features that the TypeScript team sort of regret but still support forever. And it just happens to be that when you look at the Venn diagram of these two things, they actually are the exact same things. You know, the features that TypeScript doesn't want to support necessarily are all features that are expression level features.
So, this neat little meme that I made at some point, which is like a way of saying, like, at some point, you know, TypeScript decided that, like, enums and namespaces and these features that like affect the runtime, they're not really the types of things that TypeScript wants to be involved in and that's like a responsibility for 2.6.39. And this types of comments style system really helps enforce the, like, the line between those two responsibilities.
So, where are we now? We're a bit further down the line. You know, it was March 2022 when this proposal first came out. You know, the proposal said, hey, we're really trying to find a way to, like, do this types of comments conceptual thing. And they sort of got to a stage zero, which effectively means, hey, this might, this is a thing. No one's gonna rip it apart. It's actually gonna be implemented as this. But it got to a point where it was, when talking with the rest of the TC39 teams, people concluded there's a few good questions to look at to start thinking for stage one, and they came back a year later and started, you know, answering some of the, answering some of those problems.
The first one was trying to figure out, hey, if we build a type system like this, should it be able to interact with the runtime at all? Like, you know, TypeScript's general gist nowadays is you can go from a TypeScript file to a JavaScript file just by pressing delete. That's the goal. And that means that anything you do in types cannot have an effect of the runtime. Otherwise, you can't just press delete. That's not the same thing. And so, the proposal, you know, kind of codifies this. And, you know, after going back and talking to a bunch of folks, there's a lot of people that say, like, this is just not browsers would just absolutely block this if it required them to build a type checker in order to correctly know whether something should be the right type or not at different times. And so, if that's a blocker, then that's great. Because that frees up types as comments to be types as comments rather than types as performance hints, maybe.
This the next one is trying to avoid this problem of token soup. The rough gist is that, like, it's hard right now to be able to specify actually what can live in a type and what cannot. The rough heuristic right now is if it's an open brace, there needs to be a closed brace. And you can look from left to right and count your braces this way and count your closes this way. And once they're finished, then you could be finished with the type if you see say an equal sign.
Comments