Typescript, it sucks but i use it anyway

2 Comments

Typescript, it sucks but i use it anyway

Typescript, the holygrail language for us soy-devs. It's quirky, weird and outright confusing sometimes. And yet... we use it. A lot.

insane performance

Typescript is as fast as IE. Big project? Typescript will make sure you feel the weight of your own codebase.

You're basically trading RAM for autocompletion that takes 5 seconds to load. Dev experience? More like dev patience test.

library author wannabe

At some point, you will write type, so incomprehensible, so deeply nested in generics, that you start questioning your entire career.

All you wanted was autocomplete. Now you’re knee-deep in conditional types and existential dread.

type WhatEvenIsThis< T, U extends keyof T = keyof T, V = { [K in U]: T[K] extends infer R ? R extends string | number ? R : never : never; }, W extends keyof V = keyof V, X = { [K in W]: V[K] extends string ? `${K & string}__&__${V[K] & string}` : never; }, Y = X & { extra?: "Because why not add more layers?" }, Z = keyof Y, > = Z extends keyof Y ? Y[Z] : never; // TL;DR: This type does something. // Nobody knows exactly what...

why not just use jsdoc?

Sure, we all love writing comments, right?

“Oh, I want to type this object” -- better start with a comment block!

Great! Now you can spend more time writing comments just to avoid spending time compiling typescript.

it works

Despite all those imperfections, typescript does work, it helps. For my projects and maybe many of yours too.

A lot of the time, performance isn't really much of a problem, well unless you have a gigantic monorepo codebase. In that case, i wish you luck 😅

finale

In the end of the day, languages are just tools. And tools are well... just tools.

Use the right one for the job. Use the one you can afford to use.

Nothing is perfect. And definitely not Typescript!

LILAY
LILAY is commenting

TypeScript is a superset of JavaScript that adds static typing to the language, allowing developers to specify types for variables, function parameters, and object properties. Unlike JavaScript, which is loosely typed and errors often occur at runtime, TypeScript performs compile-time type checking, catching type-related errors before the code runs.

Key features of TypeScript include:

Static Type Annotations: You can explicitly declare the expected types, such as number or string, which helps prevent bugs and improves code clarity.

Type Inference: TypeScript can automatically infer types based on the values assigned, reducing the need for excessive type declarations.

Structural Typing: TypeScript uses a "duck typing" or structural type system, where objects are considered the same type if they have the same shape (properties and types), regardless of explicit declarations.

Compile to JavaScript: TypeScript code is transpiled into regular JavaScript that runs everywhere JavaScript runs—browsers, Node.js, Deno, etc..

Tooling and Editor Support: Popular editors like Visual Studio Code have built-in support, offering error checking and auto-completion as you write your code.

Support for Large Applications: It helps in managing and scaling large codebases by making the codebase more maintainable and easier to understand.

TypeScript is open-source and developed by Microsoft, with its compiler itself written in TypeScript.

In short, TypeScript brings the benefits of static typing and powerful tooling to JavaScript development, making your code safer and more scalable without losing compatibility with existing JavaScript.

Visal .In
Visal .In is commenting

Yeah, it's kinda funny how some folks avoid TypeScript but then write JSDoc, which ends up being longer and more annoying to type than just using TS in the first place.