Unconventional Type Casting Techniques in TypeScript
By
Bogdanp
Hot, fresh, and worth queueing round the block for.
Summary
This article explores unconventional methods for type casting in TypeScript, moving beyond the standard 'as' operator. It presents various creative approaches to casting between arbitrary types, including using unknown as an intermediate type, function signatures, and other TypeScript type system features. The content is technical and aimed at TypeScript developers looking to understand the language's type system more deeply and discover alternative casting techniques.
Key quotes
· 3 pulledWe can't just directly do a as B because Typescript is smart enough to warn us about that, at least.
If this was intentional, convert the expression to 'unknown' first.
If we were approaching this from a type theoretic perspective, it's already interesting.
You might also wanna read
Exploring Immutable-by-Default TypeScript: A Technical Experiment
A developer explores whether it's possible to make TypeScript immutable by default without modifying the language itself, similar to Rust's
Why Average LLM Use Is Likely Destroying Value in Software Development
The author argues that, contrary to prevailing hype, the average use of Large Language Models (LLMs) is likely destroying value rather than
How AI Accelerated Prototyping: From Idea to Tangible in Record Time
The author reflects on how AI has transformed their prototyping workflow. Previously, the biggest bottleneck was the time needed to scaffold
GitLab 19.0 launches with Secrets Manager, agentic workflows, and self-hosted AI models
GitLab 19.0 has been released, positioning itself as an intelligent orchestration platform for DevSecOps. The release includes expanded secr
bit.ly·17h agoCentralizing Error Handling in Rust with Custom AppError Enums
This article discusses the importance of centralizing error handling in Rust applications using a custom AppError enum combined with map_err
Zig Devlog: Build System Rework Separates Maker and Configurer Processes
This devlog entry from the Zig programming language project announces a major rework of the build system, separating the maker process from
