Guess what, JavaScript is getting types!?

Guess what, JavaScript is getting types!?

Daily short news for you
  • For over a week now, I haven't posted anything, not because I have nothing to write about, but because I'm looking for ways to distribute more valuable content in this rapidly exploding AI era.

    As I shared earlier this year, the number of visitors to my blog is gradually declining. When I looked at the statistics, the number of users in the first six months of 2025 has dropped by 30% compared to the same period last year, and by 15% compared to the last six months of 2024. This indicates a reality that users are gradually leaving. What is the reason for this?

    I think the biggest reason is that user habits have changed. They primarily discover the blog through search engines, with Google being the largest. Almost half of the users return to the blog without going through the search step. This is a positive signal, but it's still not enough to increase the number of new users. Not to mention that now, Google has launched the AI Search Labs feature, which means AI displays summarized content when users search, further reducing the likelihood of users accessing the website. Interestingly, when Search Labs was introduced, English articles have taken over the rankings for the most accessed content.

    My articles are usually very long, sometimes reaching up to 2000 words. Writing such an article takes a lot of time. It's normal for many articles to go unread. I know and accept this because not everyone encounters the issues being discussed. For me, writing is a way to cultivate patience and thoughtfulness. Being able to help someone through my writing is a wonderful thing.

    Therefore, I am thinking of focusing on shorter and medium-length content to be able to write more. Long content will only be used when I want to write in detail or delve deeply into a particular topic. So, I am looking for ways to redesign the blog. Everyone, please stay tuned! 😄

    » Read more
  • CloudFlare has introduced the pay per crawl feature to charge for each time AI "crawls" data from your website. What does that mean 🤔?

    The purpose of SEO is to help search engines see the website. When users search for relevant content, your website appears in the search results. This is almost a win-win situation where Google helps more people discover your site, and in return, Google gets more users.

    Now, the game with AI Agents is different. AI Agents have to actively seek out information sources and conveniently "crawl" your data, then mix it up or do something with it that we can't even know. So this is almost a game that benefits only one side 🤔!?

    CloudFlare's move is to make AI Agents pay for each time they retrieve data from your website. If they don’t pay, then I won’t let them read my data. Something like that. Let’s wait a bit longer and see 🤓.

    » Read more
  • Continuing to update on the lawsuit between the Deno group and Oracle over the name JavaScript: It seems that Deno is at a disadvantage as the court has dismissed the Deno group's complaint. However, in August, they (Oracle) must be held accountable for each reason, acknowledging or denying the allegations presented by the Deno group in the lawsuit.

    JavaScript™ Trademark Update

    » Read more

The problem

One of the things I found impressive when I started working with JavaScript is that it doesn't have types (dynamically typed). That means you don't have to declare data types for everything you create. This makes coding faster and more comfortable. On the other hand, not specifying data types also leads to many bugs in debugging and maintaining the project later on.

In the midst of this, TypeScript was introduced, bringing "statically typed" to JavaScript. This means that now you can declare types for almost everything, avoiding many errors in coding and making the code much more readable. Essentially, TypeScript is a type helper for JavaScript, which then compiles the ts syntax into js for browsers, Node.js, etc. to understand and execute.

Recently, TC39 has been working on a plan called Type Annotations. This is a step towards allowing JavaScript to declare types. Specifically, the type syntax is "borrowed" from TypeScript. So what's going on? Is JavaScript trying to "venture" into becoming a typed language? Does this make the community angry as coding becomes more complex and restrictive? Let's find out in the article below!

TC39 and the process of adding features to JavaScript

First, let's talk about TC39 and how they develop new features for JavaScript.

Ecma TC39 is responsible for developing the ECMAScript programming language (JavaScript) and drafting technical specifications. TC39 operates by consensus and has complete authority to change technical specifications when deemed appropriate. However, there is a common process for making technical changes.

Changes go through several strict stages, starting from the initial idea to the final implementation. There are five stages: the initial idea stage and four subsequent stages. TC39 must pass and evaluate each stage.

Type Annotations is one of the efforts to bring JavaScript closer to being a typed language. It has entered stage 1, which means it has passed the initial round. In this stage, it needs to describe more of what needs to be done and identify potential challenges to move on to the next rounds. This stage may still be lengthy, but let's see what this specification brings us.

How do Type Annotations work?

This proposal aims to allow developers to add type annotations to their JavaScript code, so that type checking tools like TypeScript can still work properly. When running, the JavaScript tool ignores the data types, treating them as just annotations. Type Annotations are not intended to replace TypeScript or other type checking tools. They are intended to answer the question "How should JavaScript behave when types are present?"

Specifically, it allows developers to run programs written in TypeScript, Flow, and other type-checking tools for JavaScript without the need to transpile the code, with the condition that these type-checking languages must be a subset of the supported Type Annotation definitions.

For example:

let str:string = "hello world";
str = 5;

When running in a JavaScript environment, the code will still execute normally because JavaScript doesn't care about the type of str, so it can be assigned a number even though it was initially declared as a string. However, if compiled with TypeScript, an error will occur, warning that assigning a type number to a string is invalid.

Currently, there are many proposed features for Type Annotations. They try to make it as similar to TypeScript as possible, as this is the best way to support typing in JavaScript and remain compatible with TypeScript.

Some examples include:

Variable types:

let x: string;

Type:

type CoolBool = boolean;

Interface:

interface Person {
    name: string;
    age: number;
}

Export:

export interface Person {
    name: string;
    age: number;
}
export type { SomeLocalType };
export type { SomeType as AnotherType } from "some-module";

And many other definitions. For more details, readers can visit the description page of Type Annotations.

If TypeScript is already good, why introduce Type Annotations?

First, it must be said that TypeScript is not JavaScript, so it is not under the control of TC39.

Second, the most requested feature in JavaScript by the community is type support. According to the JavaScript survey in 2020 and 2021, it has always been at the top of the developers' wishlist.

JavaScript survey

However, TypeScript has done a great job with this type system - it has been widely used with many indications that people want to continue using it. If TC39 were to create something completely new, would it cause difficulties for the development community?

Therefore, they may want to find a solution to reconcile the community and type-checking languages based on JavaScript. Since JavaScript is already widely developed, it cannot simply change everything to become a typed language, nor does it want to "reinvent the wheel" on its own.

If that becomes a reality, TypeScript can now run directly in the browser without the need to "build" into JavaScript, significantly optimizing the developer experience.

At the same time, this is also the standard foundation for typing JavaScript. By standardizing data types, it will serve as a basis for all type compilers, making things easier for developers.

Conclusion

TC39 is responsible for developing the JavaScript programming language. New features must go through 5 stages to be implemented in practice. Recently, Type Annotations is an effort to bring data typing to JavaScript, but in a more "relaxed" way rather than being restrictive. What do you think about this issue? Personally, I think it is worth looking forward to. As there are still many changes before Type Annotations are officially introduced, I hope it will be good enough to reduce the complexity of type checking tools.

Premium
Hello

The secret stack of Blog

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!

As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!

View all

Subscribe to receive new article notifications

or
* The summary newsletter is sent every 1-2 weeks, cancel anytime.

Comments (1)

Leave a comment...
Avatar
Trịnh Cường2 years ago

java is da bet@gif [MVDPX3gaKFPuo]

Reply