Big projects are ditching TypeScript… why?
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
😮 TypeScriptの広がりと見直しの波
この映画は、JavaScriptの世界においてTypeScriptの使用がどのように広まり、そして批判を受けるようになったかを描いています。2017年にはKent C. Doddsがその使用を嫌っていましたが、2023年にはTypeScriptが主流となりました。しかし最近では、SvelteやDrizzle、TurboなどのビッグプロジェクトがTypeScriptから離れ始め、その理由として、コードの複雑さや非効率性が指摘されています。一方で、SpelltやNextJSなどの主要フレームワークではTypeScriptの利用が継続されており、今後のJavaScript言語の標準化によってはTypeScriptの役割が変わる可能性もあります。
Mindmap
Keywords
💡TypeScript
💡ビッグプロジェクト
💡ランタイムエラー
💡リファクタリング
💡型ジムナスティクス
💡JSDoc
💡オプショナル型アノテーション
💡holy war
💡コンパイルステップ
💡IntelliSense
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
it is September 7th 2023 and you are
watching the code report it many years
ago in 2017 legendary JavaScript user
Kent C Dodds said I don't use typescript
so I don't ever plan on supporting it in
2019 he goes on to say you are
impassioned love of typescript is sort
of freaking me out and finally in 2023
comes capitulation typescript is one and
it's only a matter of time you're using
it whether you like it or not but this
is the sign of a good developer you have
to be open-minded and willing to adapt
to new tools and sometimes tools you
don't even like but the big question
here is did typescript really win
because recently the turns have started
to table a bunch of big open source
projects have decided to ditch
typescript in favor of vanilla
JavaScript to understand the shocking
turn of events we'll need to go back to
the very beginning in 2012 when
typescript was first released by
Microsoft nobody really cared at first
but then a few years later it was
adopted by the angular 2 framework which
everybody thought was crazy but here's
the thing first they think you're crazy
then they fight you then you change the
world or you go to jail by the early
2020s typescript was everywhere where at
which point most of its haters had been
converted into True Believers but now
right as we're about to reach the
Glorious climax of typescript saturation
you've got big libraries like svelte
drizzle and turbo deciding to ditch
typescript from their code bases to be
clear that just means that they're not
going to use typescript When developing
these libraries but as an end user in a
framework like svelt for example you're
still able to use typescript just like
normal but how could anyone possibly go
back to vanilla JS after using
typescript did they not remember runtime
errors like cannot read properties of
undefined did they not remember how hard
it is to refactor a code base where you
have no idea what anything is well these
people are a lot smarter than I am so
let's first look at this article from
dhh that creator of Ruby on Rails who's
getting rid of typescript and turbo
version 8. the main reason they're
getting rid of it is not because of the
compile step but rather because it
pollutes the code with quote type
gymnastics and there's a lot of Truth to
that especially when developing a
library I'm working on a library myself
called svelt fire and as you can see in
the code here I have to do my own type
gymnastics with typescript just to get
rid of some red squiggly lines in the
IDE now I could simply place this type
with any and not get any type inference
but then my boss would yell at me he's a
total who will abuse me emotionally and
physically if I don't code up to his
standards it's not easy being
self-employed furthermore I have the
compiler in strict mode which means I
have to use any anytime I don't want to
use an explicit type and that results in
code that's anything but beautiful let's
head over to turbo on GitHub and see how
people are reacting to this change well
it's an absolute dumpster fire and a lot
of developers are upset that their ts
contributions are now Dead on Arrival
but another huge project moving away
from typescript is spelled and the
reasoning is a bit different it's purely
practical and I recommend you read this
post by Rich Harris spelled 5 which may
come out later this year no longer uses
typescript and spelled kit is already
written in plain vanilla.js and the main
benefit is no compile step which is a
huge boost in productivity for a large
framework like this that may sound like
total chaos for a large complex project
but they're actually still getting most
of the benefits of typescript but doing
so with JS talk which is a standard
comment format where you declare types
and documentation with regular
JavaScript comments that can then be
used to generate rate types like a d.ts
file and most importantly provide
intellisense in your editor so you know
what the hell everything does and can
catch bugs early just like you can with
typescript that's the main reason I use
typescript in the first place so is it
time to just ditch it all together well
when it comes to building actual
applications with a tool like spell kit
or next JS I don't see myself leaving
typescript anytime soon those tools
integrate TS seamlessly and trying to
get the same results with JS doc would
be a total nightmare but one day I hope
we see the end of this holy war there's
currently a stage 1 ecmascript proposal
that would add optional type annotations
to JavaScript natively thus making
typescripts nearly obsolete this has
been the code report thanks for watching
and I will see you in the next one
Ver Más Videos Relacionados
5.0 / 5 (0 votes)