Big projects are ditching TypeScript… why?

Fireship
7 Sept 202303:38

Summary

TLDRこのビデオスクリプトでは、TypeScriptの採用状況とその今後の展望について議論されています。最初はJavaScriptの開発者であったKent C. Doddsも最終的にTypeScriptを受け入れたことが示されていますが、近年ではSvelteやDrizzle、Turboなどの大規模オープンソースプロジェクトがTypeScriptから撤退し、バニラJavaScriptに戻る動きがあることが指摘されています。その理由としては、型ジムナスティクスによるコード汚染や、コンパイルステップの必要性などが挙げられています。一方で、JSDocによる型推論の活用や、将来的にJavaScript自体に型アノテーションが組み込まれることで、TypeScriptの役割が変化する可能性も示唆されています。

Takeaways

  • 😮 2023年、TypeScriptは圧倒的に普及していたが、突如大規模なオープンソースプロジェクトがTypeScriptから離れ始めた。
  • 🤔 svelte、drizzle、turboなどのプロジェクトがTypeScriptを捨て、プレーンなJavaScriptに戻った理由は、TypeScriptが必要以上にコードを複雑化させるためである。
  • 😥 TypeScriptを捨てることで、コンパイルステップが不要になり開発の生産性が上がるという利点がある。
  • 🚀 svelte 5ではJSDocを利用し、コメントによる型の定義とインテリセンスを実現している。これにより、TypeScriptの利点を享受しつつ、コンパイルは不要となる。
  • 🤷‍♂️ アプリケーション開発ではTypeScriptを離れる理由がないが、ライブラリ開発ではTypeScriptを避ける動きがある。
  • 🔮 究極の解決策は、JavaScriptにネイティブに型アノテーションを導入することで、TypeScriptをほぼ無用にすることかもしれない。
  • ⏳ TypeScriptの行く末は不透明だが、開発者はオープンマインドでなければならず、時代の変化に適応することが重要である。
  • 🌐 TypeScriptの是非をめぐる聖戦は長年続いており、まだ終わる気配がない。
  • 💡 開発者は頑なに考えを変えず、新しいツールを受け入れることができれば、世界を変えられるかもしれない。
  • 🤖 結局のところ、開発者は常に生産性の向上と、バグのない品質の高いコードを目指すべきである。

Q & A

  • TypeScriptはいつ誕生しましたか?

    -TypeScriptは2012年にマイクロソフトによって発表されました。最初はあまり注目を浴びませんでしたが、後にAngular 2フレームワークで採用されたことで人気が高まりました。

  • なぜ一部の大規模なオープンソースプロジェクトがTypeScriptを放棄しようとしているのでしょうか?

    -メインの理由は、TypeScriptが必要とする型の指定に関する煩雑さにあります。ライブラリ開発の際に、型の指定のための「型の体操」が必要になり、コードが汚くなる傾向があるためです。また、コンパイルステップが生産性を落とすという指摘もあります。

  • SvelteやDrizzle、Turboはどのような代替手段を採用していますか?

    -SvelteはJSDocという標準のコメント形式を使って型とドキュメントを宣言し、Vite上でIntelliSenseを実現しています。一方でTurboはTypeScriptから完全に撤退し、プレーンなJavaScriptに移行しています。

  • ECMAScriptにプロポーザルされている新機能は、TypeScriptの存在意義に影響を与えるでしょうか?

    -はい、現在Stage 1にあるECMAScriptの新しいプロポーザルは、JavaScriptに型アノテーションを導入しようとしています。この機能が実装されれば、TypeScriptの役割が大幅に減少する可能性があります。

  • アプリケーション開発においてTypeScriptを使い続けるメリットは何でしょうか?

    -フレームワークやツールがTypeScriptをシームレスに統合しているため、JSDocを代替手段として使うよりも生産性が高くなります。TypeScriptを使い続けることで、早期のバグ検出や自動補完によるコーディング効率の向上が期待できます。

  • TypeScriptとJSDocの最も大きな違いは何でしょうか?

    -最も大きな違いは、TypeScriptがコンパイル時に型チェックを行うのに対し、JSDocはエディタ上でのみインテリセンスを提供する点です。つまり、JSDocにはコンパイル時の型安全性がありません。

  • TypeScriptの「聖戦」はいつ終わると思われますか?

    -スクリプトからは、JavaScriptにネイティブな型アノテーションが導入された時点で、TypeScriptの存在意義が大きく揺らぐことが示唆されています。しかし、その時期は不明確です。

  • 型指定を避けることで、JavaScriptはフレキシビリティが増すと考えられますか?

    -型指定を避けることで、JavaScriptのダイナミックな性質が生かせるというメリットはあります。しかし、大規模で複雑なプロジェクトでは、型の安全性を確保することが非常に重要になります。用途に応じて適切な選択が必要です。

  • ライブラリ開発とアプリケーション開発では、TypeScriptの採用基準が異なる理由は何でしょうか?

    -ライブラリ開発では、型指定のオーバーヘッドが生産性を落とす可能性があります。一方アプリケーション開発では、フレームワークやツールがTypeScriptをシームレスに統合しているため、生産性への影響が小さくなります。

  • この動画の結論として、TypeScriptの未来について何が言えますか?

    -動画の結論としては、ECMAScriptにネイティブの型アノテーションが導入されれば、TypeScriptの存在意義は大きく揺らぐ可能性があることが示唆されています。しかし、その実現時期は不明確であり、当面の間はユースケースに応じてTypeScriptの採用を判断することが賢明だと言えます。

Outlines

00:00

😮 TypeScriptの広がりと見直しの波

この映画は、JavaScriptの世界においてTypeScriptの使用がどのように広まり、そして批判を受けるようになったかを描いています。2017年にはKent C. Doddsがその使用を嫌っていましたが、2023年にはTypeScriptが主流となりました。しかし最近では、SvelteやDrizzle、TurboなどのビッグプロジェクトがTypeScriptから離れ始め、その理由として、コードの複雑さや非効率性が指摘されています。一方で、SpelltやNextJSなどの主要フレームワークではTypeScriptの利用が継続されており、今後のJavaScript言語の標準化によってはTypeScriptの役割が変わる可能性もあります。

Mindmap

Keywords

💡TypeScript

TypeScriptは、Microsoft社が開発したJavaScriptのスーパーセットで、静的型付けの機能を追加したプログラミング言語です。この動画では、TypeScriptの採用と、その後の一部のプロジェクトがTypeScriptから離れていく動きが説明されています。例えば、「nobody really cared at first, but then a few years later it was adopted by the angular 2 framework」のように、当初は無視されていたTypeScriptが、Angular 2で採用されたことで注目を集めるようになった経緯が語られています。

💡ビッグプロジェクト

この動画では、svelte、drizzle、turboなどのビッグなオープンソースプロジェクトがTypeScriptを捨てて、プレーンなJavaScriptに戻ることについて言及されています。例えば、「you've got big libraries like svelte, drizzle and turbo deciding to ditch typescript from their code bases」のように、これらのプロジェクトがTypeScriptの使用を止める決定を下したことが説明されています。これらの大規模なプロジェクトの動向が、TypeScriptの行方に大きな影響を与えることが示唆されています。

💡ランタイムエラー

ランタイムエラーとは、プログラムを実行した際に発生するエラーのことを指します。この動画では、TypeScriptを使うことで、このようなエラーを事前に防ぐことができると述べられています。具体例として「cannot read properties of undefined」のようなエラーが挙げられており、TypeScriptのような静的型付けの仕組みがあれば、そのようなエラーを未然に防ぐことができると説明されています。

💡リファクタリング

リファクタリングとは、プログラムの外部動作を変えずにソースコードの内部構造を整理・改善することを指します。この動画では、TypeScriptを使うと大規模なプロジェクトでのリファクタリングが容易になると述べられています。具体的には「where you have no idea what anything is」のように、型情報がないと変数や関数の役割を把握しづらくなり、リファクタリングが困難になることが示唆されています。

💡型ジムナスティクス

型ジムナスティクスとは、TypeScriptの型システムを扱う際に発生する、複雑で分かりづらいコードのことを指します。この動画では、turboプロジェクトがTypeScriptを排除した理由の一つとして、「because it pollutes the code with quote type gymnastics」と述べられています。つまり、TypeScriptの型システムを使うと、コードが複雑になり過ぎてしまうという問題点があると指摘されています。

💡JSDoc

JSDocとは、JavaScriptのコード内にドキュメンテーションコメントを記述する慣習的な方法のことを指します。この動画では、svelteプロジェクトがJSDocを使ってTypeScriptに代わる型の仕組みを実装していることが説明されています。「they're actually still getting most of the benefits of typescript but doing so with JS talk」という部分が、この話を指しています。JSDocを用いることで、型情報を付与しつつ、TypeScriptのようなコンパイル工程を必要としないという利点があると言及されています。

💡オプショナル型アノテーション

オプショナル型アノテーションとは、JavaScriptの次期バージョンであるECMAScript提案の中で検討されている機能のことを指します。この機能が実現すれば、JavaScriptに型アノテーションを付与できるようになり、TypeScriptが不要になる可能性があると動画内で言及されています。具体的には「there's currently a stage 1 ecmascript proposal that would add optional type annotations to JavaScript natively thus making typescript nearly obsolete」という部分で説明されています。

💡holy war

「holy war」とは、TypeScriptとJavaScriptをめぐる論争や対立のことを比喩的に表した言葉です。動画の最後の部分で、「one day I hope we see the end of this holy war」と述べられており、作者はこの対立が終結することを願っていることが分かります。TypeScriptとJavaScriptのどちらを使うべきかについて、開発者コミュニティの中で激しい議論が行われていることが示唆されています。

💡コンパイルステップ

コンパイルステップとは、TypeScriptのようなトランスパイル言語を使う際に必要となるコード変換の工程のことを指します。この動画では、svelteがコンパイルステップを排除することで生産性を向上させたと説明されています。具体的には「the main benefit is no compile step which is a huge boost in productivity」という部分でその旨が述べられています。コンパイルステップが不要になることで、開発時の待ち時間が減り、作業効率が上がるというメリットがあることが示唆されています。

💡IntelliSense

IntelliSenseとは、主にIDE(統合開発環境)において、コード補完やドキュメンテーション表示などの支援機能の総称を指します。この動画では、JSDocを使うことでTypeScriptと同様のIntelliSense機能が得られると述べられています。「can then be used to generate rate types like a d.ts file and most importantly provide intellisense in your editor」の部分が、その旨を説明しています。型情報があれば、エディタ上でコード補完やエラー検知ができるため、生産性が向上するというメリットがあるということです。

Highlights

Kent C. Dodds, a legendary JavaScript user, initially opposed TypeScript but later embraced it in 2023, saying, "TypeScript is one and it's only a matter of time you're using it whether you like it or not."

Despite TypeScript's widespread adoption, recently, some big open-source projects like Svelte, Drizzle, and Turbo have decided to ditch TypeScript in favor of vanilla JavaScript.

DHH, the creator of Ruby on Rails, is removing TypeScript from Turbo version 8, citing that it "pollutes the code with type gymnastics."

The speaker is working on a library called "Svelt Fire" and has to perform "type gymnastics" with TypeScript to get rid of red squiggly lines in the IDE.

Svelte 5, which may come out later in 2023, no longer uses TypeScript, and Svelte Kit is already written in plain vanilla JavaScript.

Svelte is using JSDoc, a standard comment format, to declare types and documentation with regular JavaScript comments, which can then be used to generate type definitions and provide IntelliSense.

For building actual applications with tools like Svelte Kit or Next.js, the speaker doesn't see themselves leaving TypeScript anytime soon, as trying to get the same results with JSDoc would be a "total nightmare."

There is a Stage 1 ECMAScript proposal that would add optional type annotations to JavaScript natively, potentially making TypeScript nearly obsolete.

The speaker suggests that there is currently a "holy war" between TypeScript and vanilla JavaScript, and hopes to see an end to this conflict.

The turnaround of big open-source projects ditching TypeScript after its widespread adoption is described as a "shocking turn of events."

The speaker acknowledges that the people behind the decision to ditch TypeScript are "a lot smarter" than them.

The reaction to Turbo's decision to remove TypeScript is described as an "absolute dumpster fire," with many developers upset that their TypeScript contributions are now "Dead on Arrival."

The speaker uses TypeScript with strict mode, which means they have to use "any" anytime they don't want to use an explicit type, resulting in code that's "anything but beautiful."

The main benefit of Svelte Kit's move away from TypeScript is the removal of the compile step, which is described as a "huge boost in productivity for a large framework like this."

The speaker hopes that the "holy war" between TypeScript and vanilla JavaScript will come to an end one day.

Transcripts

play00:00

it is September 7th 2023 and you are

play00:03

watching the code report it many years

play00:04

ago in 2017 legendary JavaScript user

play00:07

Kent C Dodds said I don't use typescript

play00:09

so I don't ever plan on supporting it in

play00:11

2019 he goes on to say you are

play00:13

impassioned love of typescript is sort

play00:15

of freaking me out and finally in 2023

play00:17

comes capitulation typescript is one and

play00:19

it's only a matter of time you're using

play00:21

it whether you like it or not but this

play00:23

is the sign of a good developer you have

play00:24

to be open-minded and willing to adapt

play00:26

to new tools and sometimes tools you

play00:28

don't even like but the big question

play00:29

here is did typescript really win

play00:31

because recently the turns have started

play00:33

to table a bunch of big open source

play00:35

projects have decided to ditch

play00:36

typescript in favor of vanilla

play00:38

JavaScript to understand the shocking

play00:40

turn of events we'll need to go back to

play00:42

the very beginning in 2012 when

play00:44

typescript was first released by

play00:45

Microsoft nobody really cared at first

play00:47

but then a few years later it was

play00:49

adopted by the angular 2 framework which

play00:51

everybody thought was crazy but here's

play00:53

the thing first they think you're crazy

play00:54

then they fight you then you change the

play00:56

world or you go to jail by the early

play00:58

2020s typescript was everywhere where at

play01:00

which point most of its haters had been

play01:02

converted into True Believers but now

play01:03

right as we're about to reach the

play01:05

Glorious climax of typescript saturation

play01:07

you've got big libraries like svelte

play01:09

drizzle and turbo deciding to ditch

play01:11

typescript from their code bases to be

play01:13

clear that just means that they're not

play01:14

going to use typescript When developing

play01:16

these libraries but as an end user in a

play01:18

framework like svelt for example you're

play01:19

still able to use typescript just like

play01:21

normal but how could anyone possibly go

play01:23

back to vanilla JS after using

play01:24

typescript did they not remember runtime

play01:26

errors like cannot read properties of

play01:28

undefined did they not remember how hard

play01:29

it is to refactor a code base where you

play01:31

have no idea what anything is well these

play01:33

people are a lot smarter than I am so

play01:34

let's first look at this article from

play01:36

dhh that creator of Ruby on Rails who's

play01:38

getting rid of typescript and turbo

play01:40

version 8. the main reason they're

play01:41

getting rid of it is not because of the

play01:42

compile step but rather because it

play01:44

pollutes the code with quote type

play01:46

gymnastics and there's a lot of Truth to

play01:48

that especially when developing a

play01:49

library I'm working on a library myself

play01:51

called svelt fire and as you can see in

play01:53

the code here I have to do my own type

play01:55

gymnastics with typescript just to get

play01:57

rid of some red squiggly lines in the

play01:58

IDE now I could simply place this type

play02:00

with any and not get any type inference

play02:02

but then my boss would yell at me he's a

play02:04

total who will abuse me emotionally and

play02:06

physically if I don't code up to his

play02:07

standards it's not easy being

play02:09

self-employed furthermore I have the

play02:10

compiler in strict mode which means I

play02:12

have to use any anytime I don't want to

play02:14

use an explicit type and that results in

play02:16

code that's anything but beautiful let's

play02:17

head over to turbo on GitHub and see how

play02:19

people are reacting to this change well

play02:21

it's an absolute dumpster fire and a lot

play02:23

of developers are upset that their ts

play02:24

contributions are now Dead on Arrival

play02:26

but another huge project moving away

play02:28

from typescript is spelled and the

play02:30

reasoning is a bit different it's purely

play02:31

practical and I recommend you read this

play02:33

post by Rich Harris spelled 5 which may

play02:35

come out later this year no longer uses

play02:37

typescript and spelled kit is already

play02:38

written in plain vanilla.js and the main

play02:41

benefit is no compile step which is a

play02:43

huge boost in productivity for a large

play02:44

framework like this that may sound like

play02:46

total chaos for a large complex project

play02:48

but they're actually still getting most

play02:50

of the benefits of typescript but doing

play02:52

so with JS talk which is a standard

play02:54

comment format where you declare types

play02:56

and documentation with regular

play02:57

JavaScript comments that can then be

play02:59

used to generate rate types like a d.ts

play03:01

file and most importantly provide

play03:03

intellisense in your editor so you know

play03:05

what the hell everything does and can

play03:06

catch bugs early just like you can with

play03:08

typescript that's the main reason I use

play03:09

typescript in the first place so is it

play03:11

time to just ditch it all together well

play03:13

when it comes to building actual

play03:14

applications with a tool like spell kit

play03:16

or next JS I don't see myself leaving

play03:18

typescript anytime soon those tools

play03:19

integrate TS seamlessly and trying to

play03:21

get the same results with JS doc would

play03:23

be a total nightmare but one day I hope

play03:25

we see the end of this holy war there's

play03:27

currently a stage 1 ecmascript proposal

play03:29

that would add optional type annotations

play03:30

to JavaScript natively thus making

play03:32

typescripts nearly obsolete this has

play03:34

been the code report thanks for watching

play03:36

and I will see you in the next one

Rate This

5.0 / 5 (0 votes)

Related Tags
プログラミング言語オープンソース開発者生産性将来展望論争設計テクノロジートレンドパフォーマンス
Do you need a summary in English?