惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
D
DataBreaches.Net
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
Netflix TechBlog - Medium
Microsoft Azure Blog
Microsoft Azure Blog
Microsoft Security Blog
Microsoft Security Blog
B
Blog
U
Unit 42
有赞技术团队
有赞技术团队
博客园 - 聂微东
GbyAI
GbyAI
宝玉的分享
宝玉的分享
F
Full Disclosure
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MyScale Blog
MyScale Blog
Jina AI
Jina AI
Martin Fowler
Martin Fowler
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Docker
P
Proofpoint News Feed
A
About on SuperTechFans
I
InfoQ
博客园 - 【当耐特】
C
Check Point Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog
Project Zero
Project Zero
WordPress大学
WordPress大学
小众软件
小众软件
AWS News Blog
AWS News Blog
博客园 - 司徒正美
T
The Exploit Database - CXSecurity.com
L
LINUX DO - 热门话题
I
Intezer
Engineering at Meta
Engineering at Meta
C
CXSECURITY Database RSS Feed - CXSecurity.com
J
Java Code Geeks
T
Tenable Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes

oida.dev | TypeScript, Rust

TypeScript's `erasableSyntaxOnly` Flag Unsafe for work Tokio: Macros Tokio: Channels Tokio: Getting Started Network Applications on the Tokio Stack Remake, Remodel, Reduce. The `never` type and error handling in TypeScript 5 Inconvenient Truths about TypeScript Refactoring in Rust: Introducing Traits Refactoring in Rust: Abstraction with the Newtype Pattern Announcing the TypeScript Cookbook TypeScript: Iterating over objects The road to universal JavaScript 10 years of oida.dev Rust: Tiny little traits The TypeScript converging point How not to learn TypeScript Getting started with Rust Introducing Slides and Coverage TypeScript: The humble function overload TypeScript + React: Children types are broken TypeScript: In defense of any Rust: Enums to wrap multiple errors Dissecting Deno Error handling in Rust TypeScript: Unexpected intersections Upgrading Node.js dependencies after a yarn audit TypeScript: Array.includes on narrow types TypeScript + React: Typing Generic forwardRefs shared, util, core: Schroedinger's module names Learning Rust and Go TypeScript: Narrow types in catch clauses TypeScript: Low maintenance types Tidy TypeScript: Name your generics Tidy TypeScript: Avoid traditional OOP patterns Tidy TypeScript: Prefer type aliases over interfaces Tidy TypeScript: Prefer union types over enums My new book: TypeScript in 50 Lessons Go Preact! ❤️ this in JavaScript and TypeScript TypeScript and ECMAScript Modules TypeScript + React: Why I don't use React.FC TypeScript + React: Component patterns TypeScript: Augmenting global and lib.dom.d.ts Vite with Preact and TypeScript TypeScript: Union to intersection type 11ty: Generate Twitter cards automatically Are large node module dependencies an issue? TypeScript: Variadic Tuple Types Preview TypeScript: Improving Object.keys Remake, Remodel. Part 4. TypeScript + React: Typing custom hooks with tuple types TypeScript: Assertion signatures and Object.defineProperty TypeScript: Check for object properties and narrow down type Boolean in JavaScript and TypeScript void in JavaScript and TypeScript Symbols in JavaScript and TypeScript TypeScript + React: Extending JSX Elements TypeScript: Validate mapped types and const context TypeScript: Match the exact object shape TypeScript: The constructor interface pattern Streaming your Meetup - Part 4: Directing and Streaming with OBS Streaming your Meetup - Part 3: Speaker audio Streaming your Meetup - Part 2: Speaker video Streaming your Meetup - Part 1: Basics and Projector TypeScript and React Guide: Added a new styles chapter TypeScript and React Guide: Added a new render props chapter TypeScript and React: Styles and CSS TypeScript and React TypeScript and React Guide: Added a new prop types chapter TypeScript without TypeScript -- JSDoc superpowers TypeScript: Mapped types for type maps JAMStack vs serverless web apps The Unsung Benefits of JAMStack Sites TypeScript: Ambient modules for Webpack loaders My most favourite talks in 2018 TypeScript and React Guide: Added a new context chapter TypeScript: Built-in generic types TypeScript: Type predicates JSX is syntactic sugar TypeScript and React Guide: Added a new hooks chapter Getting your CfP application right FAQ on our Angular Connect Talk: Automating UI development TypeScript and Substitutability Debugging Node.js apps in TypeScript with Visual Studio Code From Medium: Deconfusing Pre- and Post-processing From Medium: PostCSS misconceptions Saving and scraping a website with Puppeteer Cutting the mustard - 2018 edition Wordpress as CMS for your JAMStack sites My most favourite podcast episodes in 2017 My most favourite talks in 2017 My most favourite books in 2017 The Best Request Is No Request, Revisited Not so hidden figures - Organizing ScriptConf My podcast journey to ScriptCast Grid layout, grid layout everywhere! #scriptconf and #devone Object streams in Node.js
Why I use TypeScript
2019-08-28 · via oida.dev | TypeScript, Rust

You might well see that my blog starts to center around TypeScript a lot recently. This might look like a strong deviation from what I usually blog and advocate: Performant, accessible and resilient web sites.

A lot of people ask me why I do so much with TypeScript, and why I see it as such a central piece of my day to day work. Let me explain by looking at the three encounters I had with TypeScript.

1. November 2012 - TypeScript at our local meetup #

Just a month after TypeScript got released, some people showed their features at one of our local meetups. I even blogged about it. I could see benefits back then, but was sceptical. Especially when I saw friends of mine using it. They usually came from the back-end side of things. Mostly Java and C#. That’s why they strongly relied on things like “abstract classes” and “interface hierachies” and “factories” and “static classes” and … yuck! All this POOOP (patterns of object oriented programming) and SHIT (somehow hierachical interface trees) in my JavaScript?

That’s not JavaScript. And I like JavaScript!

So I dismissed TypeScript.

2. Around 2015 - Giving Angular a try #

Staying curious, I tried out the upcoming version of Angular. Don’t pin me on the date. It was a release candidate of Angular 2. A framework that pushed TypeScript to more popularity. And the first steps I made needed to be very strongly typed. So much annotations and decorators Angular needs to understand your code. any was my best friend. But I got lost, and I gave up. I remember me saying: “TypeScript wants to know the type of my backend results. How do I know? I haven’t even console logged it, yet!”

And… that wasn’t JavaScript. And I like JavaScript!

So… I decided to stay off of TypeScript for a while. To be fair, back then my Angular knowledge was very limited. And I think so was my willigness to change that.

3. Paternity leave 2018. Learning #

I was on paternity leave in 2018 for three months, and had the chance to learn a lot while my baby child was sleeping. I also learned new programming languages. And I thought I should give TypeScript and React a try. Just to better know what I’m talking about. And being able to judge without looking at mere aesthetics.

When working with TypeScript, I found out that I can just write JavaScript like I’m used to. No complaining from a compiler. No extra annotations. No fuss.

But then came the revelation: TypeScript analyses my code constantly. And can give great information on my code without me needing to do anything. Information my editor shows to me every time I write.

The truth is, if you are using VSCode and write JavaScript, you most likely are using TypeScript without your knowledge. The TypeScript language server runs in the background, analyses your code and gives you as much information as it can. This allows you to get a better development experience without the need to do anything.

TypeScript becomes an extra brain that knows my code much better than I do. And where it doesn’t, I can give TypeScript a little bit of extra type information to make it understand. And since you can do so much with JavaScript, TypeScript strives for being as complete as possible to type all the constructs your JavaScript code can have.

This goes well with TypeScript’s design goals

  • It’s gradual. Which means you can adopt TypeScript features whenever you feel the need to.
  • Extensive type inference. TypeScript wants to know your JavaScript
  • Control flow analysis. Everytime TypeScript can help you narrowing down possible types, it does.
  • It closely tracks the ECMAScript standard. Nowadays you don’t get extra language features that haven’t reached stage 3 in ECMAScript
  • Innovations happen in the type system. TypeScript wants to give better ways to express your JavaScript
  • Tooling, tooling, tooling. TypeScript’s not here to restrict you. TypeScript is here to provide you with tools that make you more productive.

I also watched a ton of YouTube back then, checked out old JSConf videos of historical introductions. That’s how I stumpled upon the introduction of TypeScript at JSConf.EU 2012. The way Anders describes the design goals of TypeScript hasn’t changed that much. Being a type layer on top of JavaScript has been TypeScript’s goal since the very beginning. Language features were a side effect. A side effect based on lots of tries from previous standardisation efforts like ES4.

So TypeScript… is JavaScript. JavaScript with benefits. And I like Javascript! And I like benefits.

My approach:

  1. Write JavaScript. Be happy when something isn’t any
  2. Every time you want to have better types, add type annotations
  3. Enjoy this as some extra documentation when you revisit a project
  4. Stay away from any extra language stuff that mixes type annotations with stage 3 JavaScript. They are a relict of old times.

And when you work like that, it’s easy to like TypeScript. And that’s why I use it so much and why I want to write about it. It helps me, my co-workers, and my future self to actually know what I’ve been thinking. Can’t go wrong without that.

Btw. If you want the benefits, but stay away from the compile step, check out how to write TypeScript without TypeScript. This is actually useful. Libraries like Preact manage to give you full TypeScript support and tooling, but still stay in JavaScript land for contributions and coding.

Related Articles