r/typescript • u/cekrem • Feb 20 '26
SOLID in FP: Open-Closed, or Why I Love When Code Won't Compile
r/typescript • u/cekrem • Feb 20 '26
r/typescript • u/theodordiaconu • Feb 20 '26
https://runner.bluelibs.com/guide
Just launched 5.5.0
- functional DI with no decorators/runtime reflection (dynamic dependencies, optional dependencies, resource forking, overriding support)
- works on all platforms (including cjs and mjs) (some features like async context / tunnels / durable workflows are only available on node/bun/deno/edge, rest works everywhere)
- SOLID arhictecture with a lot of knobs for initialisation/isolation/etc (lazy, parallel inits, ability to isolate sub-graph via exports())
- complete/absolute type-safety with no exceptions. (sci fi typesafety, it even allows middleware or tags to enforce input/output contracts on tasks/resources, at 'compile' time)
- you can visualise your app's guts with runner-dev explorer, you'll see everything, including the live logs (connected via websocket), ability to call tasks/emit events, everything put in a tidy fashion for you to explore the app. transforms the app into a query-able GraphQL graph allowing runner-dev to operate and also AIs to quickly draw insights about structure without browsing mindlessly your ever-growing codebase.
- while you are working, you can see live logs in a beautiful UI, filterable, with correlation ids, explorable data, instead of the terminal.
- reliability toolkit included for your tasks (retries, timeouts, circuitBreaker, ratelimit, fallback, concurrency, cache), done with absolute care.
- good error pattern with type-safety emission, remediation solutions, etc
- serializer that supports circular references and self-references + custom types. supersets JSON.
- tunnels: make your monolith distributed via configuration, while keeping everything central (errors, async contexts get propagated without you having to worry + the strong serializer has your back), supports full-duplex comms, files, streams, everything naturally without having to change your code, you just change your config how you want to distribute them.
- durable workflows (beta): persistance with customizable persistence layers (first class support for redis/rabbitmq)
--
still young lib, unused, bus factor (me), high risk of adoption, reinvents some wheels, but, everything has a beginning so looking for some risk takers to try it out. (can be incrementally adopted)
we have 1 production app with runner as backend for a mobile app (uses fastify+postgres) (since December 2025), it has been a very good experience, while boilerplate-y, AIs understand it really well if you provide the AI.md file (token efficient guide 5k tokens) and we can finally have 'explicit' code while still being lazy.
code is 100% code covered (ever since v3) (ci fails when cov <100% or if performance degrades), with meaningful tests with lots of edge-cases, we have a lot of tests...
--
I think right now I have set in place a system that is first-class to ME only and I'm looking to see if anyone else is resonating.
Let me know your thoughts, should I continue iterating on a fission reactor engine or maybe an universe emulator as an additional feature? :)) Cheers!
r/typescript • u/laphilosophia • Feb 19 '26
Hi everyone! I just released API Tape, a zero-config CLI proxy designed to solve the "flaky API" problem during development and testing.
What is it? It acts as a transparent bridge between your client and your API. It records everything to local "tapes" (JSON files) and allows you to replay them instantly. Think VCR for HTTP, but with high-integrity matching.
GitHub: https://github.com/laphilosophia/api-tape
NPM: npm install -g @laphilosophia/api-tape
I'd love to hear your thoughts or support your use cases if you decide to try it out!
r/typescript • u/antonygiomarx • Feb 20 '26
I released angular-doctor, an open source TypeScript CLI (and Node.js API) that diagnoses Angular codebases and produces a 0–100 health score.
Quick start:
npx -y angular-doctor@latest .
Node.js API:
import { diagnose } from "angular-doctor/api";
const result = await diagnose("./my-angular-app");
console.log(result.score); // { score: 82, label: "Great" }
Each diagnostic has: filePath, plugin, rule, severity, message, help, line, column, category.
What it detects:
• Components — missing suffixes, empty lifecycle hooks, Pipe not implementing PipeTransform
• Performance — missing OnPush change detection
• Architecture — forwardRef usage, non-standalone components (Angular 17+), conflicting hooks
• Dead code — unused files, exports, types (via knip)
Also supports --diff mode for scanning only changed files, --report for Markdown output, and full workspace detection (Angular CLI, Nx, Ionic, AnalogJS, npm/pnpm).
Inspired by react-doctor.
GitHub: https://github.com/antonygiomarxdev/angular-doctor
Stars, feedback and PRs welcome!
r/typescript • u/Former_Assistance208 • Feb 20 '26
So I was coding and learning JavaScript for the last 7 months. Last week I tried Python, Pydantic, and FastAPI, and I got so excited about how convenient they were, so I got excited to jump into TypeScript, and god, it's a different story.
I'm currently reading the handbook, and every chapter is taking me a day just to grasp because the writer assumes tons of implicit common knowledge.
The writing style also assumes readers are native only, which makes it twice as hard.
and this handbook looks like it is not maintained. There are tons of pull requests and issues from years that no one touched. I have finished maybe 40 percent of it, and there are like 20 gotchas, where I'm sure that when I start coding, I'm probably not going to be lucky enough to remember these gotchas, and I will spend hours trying to figure out the types.
r/typescript • u/Cautious_Performer_7 • Feb 19 '26
Hi all, I'm gonna ask a probably rather noob question, but I'm at the point in TS where I know enough to know I know nothing.
I also apologise if this doesn't belong in the TS, might be node? but I'll let you decide if it needs to go elsewhere...
Anyway, so I have a mono repo (using Turbo Repo), pretty much all written in TS/TSX.
in my apps I have:
In my packages I have a few shared packages:
My questions are:
I have the database in the packages as it's used by the api, website (SSR) and automation.
So I followed the instructions on the Prisma website https://www.prisma.io/docs/guides/deployment/turborepo and it works well, but I run into an issue with the api.
tsc it builds but when I run it using node dist/index.js it doesn't transpile the prisma.ts code because it's still a bunch of .ts filesnodemon --transpileOnly ./src/index.ts I get: ReferenceError: exports is not defined at [...]/packages/db/src/generated/prisma/client.ts:48:23tsx ./src/index.ts I get: NoExplicitTypeError: Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit type for 'success' of 'Message' class. This is aparently because es-build doesn't support Typescript decorators, which I need for TypgraphQLMy current solution is to build my database project using tsdown and have the api import fine, but I get a warning like this in both dev and live:
Support for loading ES Module in require() is an experimental feature and might change at any time```
I've tried just about every combination of tsconfig.json settings, and the only thing seems to be adding `.js` to every import, which I really don't want to do (I'm gonna get roasted for being lazy on this one...) but barresly doesn't put file extensions in so a replacement for that may be a solution if there's no other ways.
Here is my api tsconfig:
{
"compilerOptions": {
"target": "es2022",
"module": "commonjs",
"moduleResolution": "node",
"allowJs": true,
"resolveJsonModule": true,
"declaration": false,
"composite": false,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["ES2022"],
"skipLibCheck": true,
"outDir": "./dist",
"rewriteRelativeImportExtensions": true,
"plugins": [
{
"transform": "typescript-transform-paths"
},
{
"transform": "typescript-transform-paths",
"afterDeclarations": true
}
]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "@types/*"]
}
here is the package.json
{
...
"scripts": {
"barrelsby": "barrelsby --delete --config ./barrelsby.json",
"generate:schema": "dotenv -c -- ts-node --transpile-only ./schema.ts",
"generate:codegen": "graphql-codegen",
"generate": "npm run generate:schema && npm run generate:codegen",
"build": "tsc",
"start": "node ./dist/index.js",
"dev": "dotenv -c -v NODE_ENV=development -- nodemon --transpileOnly ./src/index.ts"
},
"dependencies": {
"@graphql-yoga/plugin-persisted-operations": "^3.12.1",
"@parcel/watcher": "^2.5.1",
"@my-package/db": "*",
"@whatwg-node/server-plugin-cookies": "^1.0.4",
"codegen-graphql-scalar-locations": "^1.0.1-0",
"graphql": "^16.10.0",
"graphql-scalars": "^1.24.2",
"graphql-yoga": "^5.12.1",
"reflect-metadata": "^0.2.2",
"type-graphql": "^2.0.0-rc.2"
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/typescript": "^4.0.9",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-codegen/typescript-resolvers": "^4.0.1",
"@graphql-codegen/typescript-type-graphql": "^3.0.0",
"@graphql-codegen/typescript-urql": "^4.0.0",
"@graphql-codegen/urql-introspection": "^3.0.0",
"@swc/core": "^1.15.11",
"nodemon": "^3.1.4",
"ts-node": "^10.9.2",
"typescript-transform-paths": "^3.5.6"
},
"main": "./dist/index.js"
}
this is my prisma tsconfig:
{
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true,
"strictNullChecks": true
},
"include": ["./src/**/*"],
"exclude": ["dist", "node_modules"],
}
this is my prisma package.json:
{
"name": "@my-package/db",
"version": "0.0.1",
"types": "./dist/index.d.cts",
"main": "./dist/index.cjs",
"exports": {
".": "./dist/index.cjs",
"./package.json": "./package.json"
},
"scripts": {
"prisma:format": "prisma format",
"prisma:generate": "prisma generate",
"generate": "npm run prisma:generate",
"build": "tsdown"
},
"devDependencies": {
"@types/pg": "^8.16.0",
"prisma": "^7.3.0"
},
"dependencies": {
"@prisma/adapter-pg": "^7.3.0",
"@prisma/client": "^7.3.0",
"@prisma/client-runtime-utils": "^7.4.0",
"pg": "^8.18.0"
}
}r/typescript • u/tobi-au • Feb 18 '26
I'm currently working on a project that requires wrapping plain data, something like:
function wrap<T extends PlainData>(data: T): Wrapper<T> {...}
Because of the extends constraint TS infers the generic as literal type, which is a problem for wrappers that are supposed to be mutable.
const count = wrap(1); // Type is Wrapper<1>
count.set(2); // Error: Type 2 is not assignable to type 1
I can think of the following approaches:
const count: Wrapper<number> = wrap(1)const count = wrap<number>(1)const wrapNumber: typeof wrap<number> = wrap;type Widen<T> = T extends string ? string : (T extends number ? number : ...)function wrap(data: string): Wrapper<string>;
function wrap(data: number): Wrapper<number>;
...
They all work but seem quite cumbersome for basic type widening. Am I missing any simpler/cleaner way to infer widened types with that kind of generic?
PS: Simplified example for reproduction
function wrap<T extends string | number | boolean>(value: T) {
return {value};
}
const a = wrap(1);
a.value = 2; // Error
r/typescript • u/navierstokes88 • Feb 18 '26
I kept running into the same issue when debugging Stripe/GitHub webhooks:
The SDK validates the signature… but when it fails you just get:
"Invalid signature"
No structured reason.
So I extracted the verification logic into a small zero-dependency TypeScript library that returns discriminated union error results instead of throwing generic errors.
Example (Stripe):
const result = verifyStripe({
rawBodyBytes,
stripeSignatureHeader,
signingSecret,
})
if (!result.ok) {
switch (result.kind) {
case "timestamp_too_old":
console.log(result.ageSec, result.toleranceSec)
break
case "signature_mismatch":
console.log(result.expectedHex)
break
case "missing_header":
console.log("No signature header")
break
}
}
`result.kind` is a discriminant, so TS narrows automatically.
The idea was:
- zero dependencies
- structured failure reasons
- works in Node, Edge, Workers
- <5KB
- no exceptions for normal control flow
Supported so far:
- Stripe
- GitHub
- Shopify
I'm mainly interested in feedback on the API design and type ergonomics.
r/typescript • u/failedbump16 • Feb 17 '26
I have been hearing about Effect for some time and read the docs and actually looks really cool, I haven’t play with it yet (in an actual app at leats) so not sure if its worth the time to implement it in my side project
I’m currently use react, nextjs and convex on my app, do you think is a good idea to add it, mostly for error handling I’m interest on having fully typed errors and making failure cases explicit instead of relying on thrown exceptions
r/typescript • u/Adept-Letterhead-122 • Feb 16 '26
I built this library because I knew how unreliable typical spatial navigation is, especially in web-based smart TV/console app UIs.
I had initially wanted to have my original Rust crate - Kutamun - be used here via WebAssembly, but I'd abandoned that prospect for a more proper JS/TS approach.
With that said, if you're making a web-based UI that needs spatial navigation, have at it.
This is meant to provide the absolute bare minimum to get a complex 3D UI up (and by "3D", I mean, "multi-layout").
You're expected to provide much of the rest, including navigation logic.
Here's the NPM package:
https://www.npmjs.com/package/kutamun?activeTab=readme
If you wish to get the source, it's also available on my GitHub:
r/typescript • u/jhoxray • Feb 17 '26
Most AI agent frameworks are Python-first with JS as an afterthought. We needed something TypeScript-native for production, so we built OneRingAI.
It came out of 2 years of building an enterprise agent platform. The entire codebase is strict TypeScript with full type exports — no any escape hatches, no runtime type surprises.
Why we think the DX is solid:
Connector.create(), Agent.create(), agent.run() — that's a working agentrunDirect() bypasses all context management for quick one-off LLM queriesThe connector system is typed end-to-end. You register a connector with its auth config, and every tool that uses it gets type-checked auth. OAuth token refresh, circuit breakers, retry with backoff — all handled per-connector.
Tools have a typed permission system (allowlist/blocklist, approval caching with once/session/always/never modes, risk levels). Per-tool circuit breakers so one failing external API doesn't take down your agent loop.
12 LLM providers native (OpenAI, Anthropic, Google, Groq, etc.), switchable by changing a connector name. A typed model registry gives you pricing, context windows, and feature flags at runtime. All popular file formats conversion to llm-friendly, node native.
2,285 tests, semver, no breaking changes for fun.
As a side bonus - free desktop Electron app that showcases functionality if you don't want to code :)
npm i @everworker/oneringaiWould love feedback from other TS devs building with LLMs.
r/typescript • u/ivy-apps • Feb 17 '26
For those of you who vibe-code, do you use any AI code janitor tools? I've heard people hiring other people as "code janitors" so they can cleanup and refactor AI-generated code. So I wonder, are there any tools that automate that?
I'm attempting to build such tool as a side-project and I'm trying to understand what features would have real value and not be gimmick. Assume that my code janitor is intended to work on top of the standard linters ESLint/Biome - what features make your company pay for it?
It will be a GitHub Action that does two things:
For example, the MVP roadmap is:
-[x] Parse TS config and replace "../../../lib/util" relative imports with "@/lib/util" aliased ones.
-[x] Auto-translate: you add the copies in "en.json" and the tool auto translates for all supported
-[ ] Enforce architecture (e.g. Dependency boundaries - UI components import from the Data layer or any custom rules, catch CircularDependencies)
-[ ] Detect duplicated code on the semantic level
-[ ] Remove AI slop comments (e.g. // Step 1. Assing a to a // 2. Do y)
-[ ] Auto-fix "as any" casts by finding an existing type that matches the signature or creating a new one
-[ ] Dead code removal
-[ ] Context building: reference a function and the tool will find all of its dependencies (and their dependencies) and build a Markdown prompt that's ready to be consumed as an LLM context.
Deslop (deslop.dev) the tool is still on the fly but the general idea is to auto-fix (or at least detect and report as error) common TypeScript AI slop with the goal of making the codebase more type-safe and maintainable. Since Deslop cleans AI slop, AI usage in the tool will be zero-to-none and when absolutely necessary with temperature=0 and topK=1 to increase determinism and reliability. It'll be good old static analysis and algorithms.
Wdyt? I'm building the tool in Haskell and have ambitions to push the static analysis boundaries. I'm very open to ideas to expand the features list. I don't want to reinvent the wheel so I want to focus my effort on problems that aren't solved or are solved in a shitty way in the TypeScript ecosystem.
r/typescript • u/Low-Schedule996 • Feb 14 '26
hi Family, am planning to start a startup in my home town Uganda in Africa. And i am planning to base all my products on this stack based on Express.js. backend Express.js, postgresql DB / MongoDB where necessary, frontend React.js and Tailwind.css. Same backend for Mobile dev and React native for mobile UI.
All will be in Typescript throughout.
What's your opinion on choosing Express.js.
r/typescript • u/eliadkid • Feb 13 '26
We just shipped trusera-sdk for TypeScript — transparent HTTP interception and Cedar policy enforcement for AI agents.
What it does:
fetch() calls (OpenAI, Anthropic, any LLM API)Transparent HTTP interception:
import { TruseraClient, TruseraInterceptor } from "trusera-sdk";
const client = new TruseraClient({ apiKey: "tsk_..." });
const interceptor = new TruseraInterceptor();
interceptor.install(client, { enforcement: "warn" });
// All fetch() calls are now monitored — no code changes needed
Standalone mode (zero platform dependency):
import { StandaloneInterceptor } from "trusera-sdk";
const interceptor = new StandaloneInterceptor({
policyFile: ".cedar/ai-policy.cedar",
enforcement: "block",
logFile: "agent-events.jsonl",
});
interceptor.install();
// All fetch() calls are now policy-checked and logged locally
Why this matters:
Install:
Part of ai-bom (open source AI Bill of Materials scanner):
Apache 2.0 licensed. Feedback/PRs welcome!
r/typescript • u/DanielRosenwasser • Feb 11 '26
r/typescript
•
u/ivy-apps
•
Feb 13 '26
How do you deal with AI slop? Nowadays, vibe-coding and AI agents seems to become the norm. What strategies or tools do you employ to keep your codebase sane and healthy?
I'm asking because this will become a bigger problem in future. As a hobby I want to build a static analysis tool that tries to detect/fix issues that existing linters like Biome don't. For example:
- Fixing `../../../utils` relative imports to `@/lib/utils` absolute aliased ones
- Fixing `as any` casts that AI loves by finding or creating the appropriate type
- Detecting code duplication on semantic level
- Adding missing translations and auto-removing unused ones
- Detecting and removing AI slop comments
I've already built some of the above and I am looking for more ideas. I want to build Deslop - a deterministic code janitor tool that uses zero-to-none AI to fix common Cursor code smells that existing tooling don't.
r/typescript • u/spla58 • Feb 11 '26
I have an empty object x that I want to add instances of classes to by string. How can I get type enforcement for such a thing?
example:
class A {
}
class B {
}
class C {
}
const x: {[key: string]: A | B} = {};
x["a"] = new A();
x["b"] = new B();
x["c"] = new C(); // should give an errorPlayground:
r/typescript • u/JayDeesus • Feb 10 '26
At work there has been an increasing need for UI web work consisting of TSX, js, scss. Looking at the tsx files I absolutely have no idea what I’m looking at but html and scss I can get by. What would a good starting point be? For a complete beginner? They seem to have tsx files and other tsx files called reducers but honestly I’m just lost
r/typescript • u/LOTURR • Feb 09 '26
Hi all!
I really want to learn TypeScript. I've never learned any languages before complete beginner, a little bit of HTML, but I mean, really, a little. My backend developer friend told me that if you want to learn something, learn Typescript. SO here I am. Are there any recommendations ( Udemy, notebookLLM, YouTube, etc.)? BTW, I am not learning this to build a career; I just want to learn for fun, create some apps, etc.
Thanks a lot!
r/typescript • u/AlternativeSecond983 • Feb 09 '26
Hi guys,
Can you share any site where to learn typescript?
r/typescript • u/Shaz_berries • Feb 07 '26
Hey y'all! I'm excited to share a *highly opinionated* monorepo template I've been working on for the past year or so. The goal is to enable devs to create real-time, online games using TypeScript! Quickly create mmo-style games using React(v19) + Phaser(v4) for rendering, Colyseus(v0.17) for websockets and Electron(v40) for desktop app builds! Vite(v7) for builds and testing, all orchestrated via turborepo(v2).
https://github.com/asteinheiser/ts-online-game-template
My goals with this template:
- Create a desktop app (the game client), game server, and marketing site (with developer log, download button and auth)
- Do it all in a monorepo so you can easily share UI, game logic, or anything really across "apps"
- Create a more robust Phaser + Colyseus starter, which includes a "Client Side Prediction and Server Reconciliation" demo. All game logic is run on the server, so clients simply send their input (basic anit-cheat setup).
- Clean slate to make whatever kind of game; which means you will need to BYOS (bring your own systems), such as `miniplex` (ECS), etc. Make a classic mmorpg or maybe a card game! Whatever you want!
- Complete CI/CD flow that allows you to deploy and test your game live from day 1, with instructions on how to setup it all up
- Keep the hosting costs low, especially at the start
- Test suites setup for each "app" and "package" in the monorepo
- Ensure fewer UI/visual bugs by leaning on Electron; all game clients will be running Chromium and built for Windows, macOS and Linux
- Ensure a consistent auth experience for users across the marketing site and desktop app (including deep links). Currently, I use Supabase, but you could easily swap it out in the `client-auth` package.
Check out the demo marketing site, which is fully-functional, including client download and auth! Once you start the desktop client and sign in, you can join a game with up to 10 people. Server is hosted in US West currently, so your ping (top right corner) may suffer if you live far away.
Also, if it helps, you can see how I've used this template so far in my first online game project. I barely started, but at least I updated the theme and dev log:
I'm stoked to hear your feedback and would love it if anyone is interested in helping me maintain this template (package updates, improvements, etc.). Thanks for taking the time to read, I hope this is helpful for some of you!
r/typescript • u/StickyStapler • Feb 05 '26
I've been playing around with React Query and writing some fetcher functions. I have Contact[] in two places - the return type and the .get() generic. I was wondering if I need both, or is one enough?
const fetchContacts = async (): Promise<Contact[]> => {
const { data } = await axios.get<Contact[]>('/contacts');
return data;
};
// Or is return type enough?
const fetchContacts = async (): Promise<Contact[]> => {
const { data } = await axios.get('/contacts');
return data;
};I know the return type annotation is often enough, but without the generic, data is any inside the function, and I was thinking it could be useful when interacting with the data inside the function like this:
const fetchActiveContacts = async (): Promise<Contact[]> => {
const { data } = await axios.get<Contact[]>('/contacts');
return data.filter(c => c.isActive); // type safety helps here
};
// Using in React Query
useQuery({
queryKey: ['activeContacts'],
queryFn: fetchActiveContacts,
});r/typescript • u/cekrem • Feb 05 '26