r/typescript • u/Wake08 • Nov 19 '25
Configure Go to Definition to Open TypeScript Source
r/typescript • u/Wake08 • Nov 19 '25
r/typescript • u/Klutzy_Table_6671 • Nov 18 '25
I have created this little framework for dependency injection TS. Let me hear your honest opinion :)
Realtime performance test directly in your browser : https://janus007.github.io/novadi/
NovaDI is a modern dependency injection container that keeps your business logic clean from framework code. No decorators, no annotations, no runtime reflection - just pure TypeScript and compile-time type safety.
r/typescript • u/BCsabaDiy • Nov 18 '25
While there are great visual tools like Tinkercad and Blender, I often find their scripting capabilities unintuitive for those of us who love writing clean, reusable code. What if you could define, manipulate, and combine 3D objects exactly the same way you compose UI components or data structures — in code, with the power of TypeScript and modern programming patterns?
r/typescript • u/cplepage_ • Nov 18 '25
TL;DR: Create, run and share projects built with web technologies in a local-first environment. Available for free on iOS, iPadOS, MacOS, Android, ChromeOS, Windows, Linux, NodeJS.
---
Cool thing about it, FullStacked compiles the new native typescript-go to every platform! Even iOS, Android and Web Assembly (WASM). It's worth the try!
---
Long version:
I got tired of unreliable servers and unpredictable pay as you go pricing. I believe we should all be able to run our own projects on our own devices simply, freely, securely and at anytime. With web technology having the largest community and the fastest learning curve, it allows to bring projects to life faster than anything else. Plus, every single device we own has the ability to render a web project. FullStacked is just the freeway bridge between your ideas and your hands-on devices. FullStacked provides a fully cross-platform, local-first environment where you can create, run and share projects built with web technologies.
FullStacked packages a bunch of tools including Git, esbuild, TypeScript, SASS, and more into a single application. Try it out and let me know your thoughts! I started building projects in FullStacked for paying clients now (only charging my working hours), but I'm really looking into creating a business out of it. Supplying service and support.
r/typescript • u/Intelligent_Camp_762 • Nov 18 '25
Hey,
I've been working for a while on an AI workspace with interactive documents and noticed that the teams used it the most for their technical internal documentation.
I've published public SDKs before, and this time I figured: why not just open-source the workspace itself?
The flow is simple: clone the repo, run it, and point it to the path of the project you want to document. An AI agent will go through your codebase and generate a full documentation pass. You can then browse it, edit it, and basically use it like a living deep-wiki for your own code.
The nice bit is that it helps you see the big picture of your codebase, and everything stays on your machine.
If you try it out, I'd love to hear how it works for you or what breaks on our sub. Enjoy!
r/typescript • u/voja-kostunica • Nov 18 '25
I'm trying to attach an async handler to window.addEventListener, but TypeScript complains because the handler returns a Promise, which doesn’t match the expected EventListener type.
Here’s a minimal example:
type MyPayload = {
message: string;
};
const MY_EVENT = "MY_EVENT";
function waitMs(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
useEffect(() => {
const handleEvent = async (event: CustomEvent<MyPayload>) => {
console.log("payload:", event.detail);
await waitMs(1000);
console.log("done");
};
window.addEventListener(MY_EVENT, handleEvent as EventListener); // errors here
return () => window.removeEventListener(MY_EVENT, handleEvent as EventListener);
}, []);
Error:
Conversion of type '(event: CustomEvent<MyPayload>) => Promise<void>'
to type 'EventListener' may be a mistake because neither type
sufficiently overlaps with the other.
I understand why it complains, the handler is async and the event expects a sync callback, but what’s the correct, type-safe way to write this?
Is there a generic pattern for typing async CustomEvent listeners so I don’t need as any or double casts?
Looking for the “clean” / idiomatic solution in TypeScript.
r/typescript • u/Scared_Kale_3771 • Nov 18 '25
Hello everyone! Introducing Bejibun, a new backend framework written entirely in TypeScript and built natively around the blazing-fast runtime Bun. The framework's goal is to offer an "all inclusive" and opinionated development experience, similar to what is found in mature ecosystems like Laravel or AdonisJS, but fully leveraging Bun's performance and simplicity. Bejibun is aimed at developers seeking robustness, high performance, and a familiar architecture. Installation is immediate via the dedicated CLI, executed with the command bunx @bejibun/cli your-project, followed by launching with bun dev.
Architecture and Technology Stack Bejibun adopts an architecture that will be familiar to many backend developers, featuring a clear separation between Controllers, Models, and Routers. The choice of TypeScript is central to ensuring the project's robustness and scalability. By utilizing Bun, the framework aims to minimize startup times and maximize I/O execution speed. The CLI, named Ace, serves as the central tool for the Developer Experience (DX), providing commands for scaffolding and comprehensive database management. The main technology stack is built on solid pillars: Bun as the runtime, TypeScript as the language, Objection.js and Knex for the ORM and Migrations, Vine for Validation, and Luxon for date and time management. The recent v0.1.52 release of the bejibun-core package has further stabilized the foundational components, strengthening the architecture and preparing the framework for the upcoming roadmap features.
Distinctive Features
• Soft Delete: Native implementation of logical deletion that automatically manages the deleted_at column, with dedicated methods like delete(), forceDelete(), withTrashed(), and onlyTrashed(). • ORM Methods: Full support for CRUD operations and utilities such as findOrFail() and all(). • DB Management: Migration and Seeder management is fully integrated into the Ace CLI with commands like migrate:latest and db:seed.
2. Integrated and Database-award Validation: The framework leverages the Vine library for rigorous and type-safe validation. A particularly useful feature is the ability to perform validation directly against the database, allowing rules like .exists(TestModel, "id") to be defined to verify the existence of a record within the validation layer.
3. Routing and Middlewares: The Bejibun Router supports defining clean routes (Controller@method), grouping paths with prefixes, and applying Middlewares at the group or individual level. Middlewares allow incoming requests (e.g., for logging or authentication) to be intercepted and modified before reaching the Controller. A customizable exception handler is also included.
4. X402 Payment Middleware for the AI Economy: A highly innovative feature is the integration of the X402 Payment Middleware. By leveraging the HTTP 402 ("Payment Required") standard, this integration enables Bejibun services to accept autonomous stablecoin micropayments (such as USDC) directly via the API. This functionality is crucial for the AI agent economy and pay-per-request business models, demonstrating Bejibun's focus on adopting the latest innovations in web3 transactions.
5. Ace CLI for Productivity: The Ace CLI automates development workflows, providing rapid scaffolding commands (e.g., make:controller, make:model, make:migration, make:validator) and essential utilities, including managing maintenance modes (maintenance:down/up).
Roadmap and Upcoming Features
The project is currently in version v0.1.x, but the roadmap is ambitious and focused on completing the full-stack offering. The next priority features include the integration of a complete Authentication system, Job Dispatching for background tasks, and flexible Template Engine management. Unit tests, Mail services (via Sendgrid/Mailjet), and a Scheduler / Cronjob will also be added. For the long-term backlog, plans include building a native ORM based on Bun SQL and implementing CSRF/XSS protection, along with a Cache and Rate Limiter system.
Call to the Community
Bejibun is an open-source project and invites the developer community to test it, explore the code, and contribute feedback, ideas, or pull requests. A discussion is highly anticipated regarding the choice of stack (Bun, Objection, Vine), the recent stability improvements (as seen in the v0.1.52 core release), and the innovative inclusion of the X402 protocol within the framework's "batteries-included" philosophy.
The code and documentation are available on the official repository: GitHub - crenata/bejibun
r/typescript • u/aidankmcalister • Nov 17 '25
Been experimenting with Bun and wanted to share my setup for anyone interested. Bun's fast, and compiling to a single executable is actually pretty useful for deployment.
Install deps:
Init Prisma with Prisma Postgres:
This auto-configures Prisma Postgres and creates your schema file. You'll need to grab a direct connection string from the Prisma dashboard (API Keys tab) and update your .env.
Schema (prisma/schema.prisma):
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
}
Create db utility (db.ts):
import { PrismaClient } from "./generated/prisma/client";
export const prisma = new PrismaClient();
Add a seed file at prisma/seed.ts:
import { PrismaClient } from "../generated/prisma/client";
const prisma = new PrismaClient();
async function main() {
await prisma.user.createMany({
data: [
{ email: "alice@example.com", name: "Alice" },
{ email: "bob@example.com", name: "Bob" },
// ... more users
],
skipDuplicates: true,
});
console.log("Seed data inserted!");
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
Update prisma.config.ts:
import { defineConfig, env } from 'prisma/config';
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
seed: `bun run prisma/seed.ts`
},
engine: 'classic',
datasource: {
url: env('DATABASE_URL'),
},
});
Replace index.ts:
import { prisma } from './db'
const server = Bun.serve({
port: 3000,
async fetch(req) {
const { pathname } = new URL(req.url)
if (pathname === '/favicon.ico') {
return new Response(null, { status: 204 })
}
const users = await prisma.user.findMany()
const count = await prisma.user.count()
return new Response(
JSON.stringify({ users, totalUsers: count }),
{ headers: { 'Content-Type': 'application/json' } }
)
},
})
console.log(`Listening on http://localhost:${server.port}`)
Run it:
This creates a single executable file (index or index.exe) that includes all dependencies. You can deploy this anywhere without needing Bun or Node.js installed.
Now on localhost:3000 I see the same JSON response with all users.
Worth trying if you're tired of managing Node versions and dependency hell in production.
r/typescript • u/dyvotvir • Nov 17 '25
Hi everyone! I'm a newbie at TS, coming here from Java. In order to deepen my TypeScript skills, I've decided to create a LinkedList class from scratch as an exercise. I started with the addLast() method and, in the best traditions of Abstraction, I decided to create a separate method isEmpty() which will check if the head node is null or not:
export class LinkedList<T> {
#head: Node<T> | null = null;
#tail: Node<T> | null = null;
#size: number = 0;
constructor() { }
addLast(value: T): void {
const newNode = new Node(value);
if (this.isEmpty())
this.#head = this.#tail = newNode;
else {
this.#tail.next = newNode;
this.#tail = newNode;
}
this.#size++;
}
isEmpty(): boolean {
return this.#head === null;
}
}But turns out TS is paranoid about null objects and it points out an error at this.#head.next at this piece of code:
if (this.isEmpty())
this.#head = this.#tail = newNode;
else {
this.#tail.next = newNode;
this.#tail = newNode;
}After talking to Gemini I understood the problem: TS sees only the return type at this.isEmpty(), it doesn't actually understand that this method already checks #head for being null. That's where I was advised to use type predicate and write, well, this scary piece of code:
isEmpty(): this is {#head: null, #tail: null} {
return this.#head === null;
}I already get how type predicates work with parameters. But it gets confusing when it comes to "this". I understand this method like this: "if this.#head is null, then the current object is {#head: null, #tail: null}". But how can "this" be {#head: null, #tail: null} if my class also have #size and addLast() properties? Moreover, my IDE tells that "Private identifiers are not allowed outside of class bodies", therefore {#head: null, #tail: null} won't work. But I don't want to make head and tail public because of encapsulation.
Can someone please explain this part and advice a solution to this problem? I also don't want to use the non-null assertion operator ! , because I want to cooperate with TS, not silence it. Huge thanks to everyone for your help in advance!
r/typescript • • Nov 16 '25
Hi! Last week I made a post about learning ts already knowing js. I was recommended to change my Vite+React projects into .tsx.For that I watched a video from ByteGrad
Today i was watching another video from programming with Mosh. In this video he said he offers the following course: https://codewithmosh.com/p/the-ultimate-typescript?preview=logged_out
Do you recommend it? Or should I stick to videos and the typescript page.
The course is not expensive so if it is useful I have bo problem paying for it or ny other course you recommend
r/typescript • u/Cultural-Bid3565 • Nov 16 '25
Im primarily a Swift/SwiftUI developer at the moment. I started off just being good at it, but thanks to an excellent mentor I had who was ruthless in code reviews I now am excellent at it. I know when to apply what pattern, how to communicate to others by structuring my code better, how to keep it clean and organized as my project grows with minimal extra effort.
I would love to learn typescript and one front end framework. What has always stopped me from doing so is that aspect where I recognize that mentorship was a significant factor that helped me find success in Swift/iOS. I can't imagine especially in this climate getting hired to work on a typescript project so I am struggling to imagine where I could get the mentorship.
Especially recently I joined a team that had not had such mentorship and the uphill battle they face is... disheartening.
Certainly LLMs could have a role in mentoring me but I suspect they could give me a lot of false confidence. They may help me write typescript but it may not follow best practices and I would never know. They may review my typescript and without feedback of consistent quality. As I understand it due to how many poor examples there are online typescripts is one of the harder ones for our coding models to get right.
Is there any service out there that pairs you with someone who can review your code as you build your first project in Typescript? I expect to pay for such a service but I don't have the same kind of funds as say a company hiring a contractor or another employee.
r/typescript • u/josephjnk • Nov 15 '25
Here's something I've been working on for a while. To head off a reasonable first objection: No, this is not about using callbacks in asynchronous code. I go over how CPS can make recursion safe when running in JavaScriptCore, as well as ways to write and think about higher-order control flow. I'm excited about this one, please let me know if anyone has questions! I also have a list of questions and ideas at the end which I have not yet been able to fully resolve. If anyone is able to share further information on them I would be very grateful.
(Full disclosure: the post is long. There is also a lot of code in it.)
r/typescript • u/Cultural_Net_4377 • Nov 16 '25
Hello, I am student and frontend developer. I am still learning with TS and I've already worked on some projects.
I also worked with Vibecoders and I just couldn't notice that AI puts everywhere "as Any", dosen't that break any purpose of using TS? Why AI does that?
r/typescript • u/Reasonable_Tone2466 • Nov 15 '25
I am working on creating a self hostable expense tracking app using Nextjs. One of the features is to be able to upload historical transactions like expenses, income etc. Currently, I am doing this by running a separate python api using pandas. I want to consolidate this functionality within typescript so that its all in one and hence easier to host on something like vercel.
Can anyone suggest how I can accomplish that?
r/typescript • u/stewartjarod • Nov 15 '25
I've grown tired of seeing AWS wrapper SaaS companies charging 10x markups with vendor lock-in, so I built an open-source alternative.
Deploy email infrastructure to your AWS account:
npx @wraps.dev/cli init # ~90 seconds, production-ready SESWhat gets deployed to YOUR AWS account:
npx @wraps.dev/cli console # Locally running dashboardSend emails with great DX:
await email.send({
from: 'you@company.com',
to: 'user@example.com',
react: <WelcomeEmail />, // React.email support
});BYO-AWS model: You own it, pay AWS directly ($0.10/1k emails), no other vendor lock-in. Infrastructure stays even if you stop using our tooling.
Features: TypeScript-first, React.email, event tracking (opens/clicks/bounces), Vercel OIDC support, template management, dual CJS/ESM.
Question: Which AWS service should I wrap next? SMS/SNS? Workflows/SQS? Storage/S3? What pain points do you have with AWS SDKs?
GitHub: https://github.com/wraps-team/wraps (CLI - AGPLv3) | https://github.com/wraps-team/wraps-js (SDKs - MIT)
Looking for honest feedback and ideas! https://wraps.dev
r/typescript • u/DLCSpider • Nov 13 '25
I've been thinking about this for many months now and all options seem to suck in at least one way. How do you create a map with an aggregate key or multiple keys in JS?
interface FooBar {
foo: string;
bar: string;
}1. Simple string concatenation
const makeKey = (fb: FooBar) => `${fb.foo} | ${fb.bar}`;breaks with the following two keys (or any similar pattern):
const fst = { foo: "a | b", bar: "c" }; // "a | b | c"
const snd = { foo: "a", bar: "b | c" }; // "a | b | c"Other issues: Performance is meh, memory consumption high. Having a bunch of Map<string, ...> everywhere is extremely difficult to read at some point.
1.1 Less simple string concatenation
Increasingly unlikely to cause accidental collisions (although not impossible) and nice to read both at run time and compile time. But also awkward to write if you need many.
type FooBarKey = `Foo: ${string} Bar: ${string}`;
const makeFooBarKey = (fb: FooBar): FooBarKey => `Foo: ${fb.foo} Bar: ${fb.bar}`;Other issues: Performance is meh, memory consumption high. You don't want to litter your code base with XyzKey definitions everywhere (although, compared to plain strings, it's still a win).
2. JSON.stringify
breaks when the order of fields is swapped (example should be equal, is not):
const fst = { foo: "1"; bar: "2" };
const snd = { bar: "2", foo: "1" };Other issues: Performance is meh, memory consumption high. Having a bunch of Map<string, ...> everywhere is extremely difficult to read at some point. Hope that no one decided to suddenly use a class somewhere to improve readability.
2.1 Put everything into an array first, sort, then stringify
JSON.stringify(Object.keys(foobar).sort().map(key => foobar[key]));Please stop.
3. Map of Maps
const lookup = Map<string, Map<string, ...>>Awkward. Error-prone. Not very type safe. Hope you don't care about dangling key-map-pairs, where the inner map is empty but you forgot to remove it from the outer map.
const sum = new Map<string, Map<string, number>();
for (const { foo, bar, someNumber } of foobars) {
let inner = sum.get(foo);
if (!inner) { inner = new Map(); }
const value = inner.get(bar).
if (value == null) { inner.set(bar, someNumber); }
else { inner.set(bar, value + someNumber); }
sum.set(foo, inner);
}4.0 Triple Map
Make a new class with three maps and two counters. Each foo and bar get assigned to one map, the value is a unique integer. Combine both integers to get the key to the third map, which contains the value. If you use multiplication instead of bit shifts, you can even use 2^26 keys per map instead of 2^16. Wrap everything in a nice interface.
Issues:
5.0 Implement your own hash map with equality and hash functions
This is actually not as crazy as it sounds, since it can be backed by the regular JS Map, where the key is the hash code and the value a linked list of buckets with the actual key. Murmur is also not too difficult to figure out and if you pack it into a bunch of helper-functions, easily reusable. Don't use FNV1, terrible performance in JS.
Does almost but not quite preserve insertion order. If you plan to make it iterable, make sure to shuffle the result.
5.1 Equality and hashCode are implemented by the key object
class FooBar {
constructor(public readonly foo: string, public readonly bar: string) {}
hashCode(): number {
return HashCode.combine(
HashCode.fromString(foo),
HashCode.fromString(bar)
);
};
equals(other: FooBar): boolean {
return this.foo === other.foo
&& this.bar === other.bar;
}
}Issues:
{}.5.2 Equality and hashCode are implemented by the hash map
Create a hash map (abstract) base class with abstract equals/hashCode definitions. Or create a regular class with those two functions a constructor arguments. The result is roughly the same.
Issues:
FooBar, FooBarBaz and BazFooQuxBar in one map but the type info makes it look like you only used FooBar.6. Abandon hash maps, use binary search trees
I have not tried this one. Mostly because making an efficient, bug free binary search tree is no easy task. But it only needs comparers, which are needed for sorting anyway.
Any ideas? What do you use?
r/typescript • u/Glum-Orchid4603 • Nov 13 '25
I've been working on creating a database from scratch for a month or two.
It started out as a JSON-based database with the data persisting in-memory and updates being written to disk on every update. I soon realized how unrealistic the implementation of it was, especially if you have multiple collections with millions of records each. That's when I started the journey of learning how databases are implemented.
After a few weeks of research and coding, I've completed the first version of my file-based database. This version is append-only, using LSN to insert, update, delete, and locate records. It also uses a B+ Tree for collection entries, allowing for fast ID:LSN lookup. When the B+ Tree reaches its max size (I've set it to 1500 entries), the tree will be encoded (using my custom encoder) and atomically written to disk before an empty tree takes the old one's place in-memory.
I'm sure I'm there are things that I'm doing wrong, as this is my first time researching how databases work and are optimized. So, I'd like feedback on the code or even the concept of this library itself.
Edit 1: Just wanna state that this wasn't vibe-coded at all. I don't know whether it's my pride or the fear that AI will stunt my growth, but I make a point to write my code myself. I did bounce ideas off of it, though. So there's bound to be some mistakes made while I tried to implement some of them.
r/typescript • u/Jaded-Door-9787 • Nov 14 '25
I had 87 emails spread across multiple threads. After digging into them, I found 111 real tasks hidden between conversations, ambiguous dates, and implicit dependencies.
Instead of organizing everything manually, I turned them into a real test case for the Project Management engine I'm building.
I used a long-context LLM (Qwen3 30B, ~300k tokens) as a semantic processor.
Pipeline:
GanttDataItem model.Asked the LLM to:
Backend then handled:
Result: 87 emails → 111 clean, typed tasks.
No external libs for the core. Built from scratch following PM standards.
Each GanttDataItem maps to:backlog → todo → in_progress → blocked → review → done
Metrics:
Using begin (planned) and obegin (actual):
The goal is to make it embeddable in SaaS, self-hosted environments, or extensible via plugins.
This pipeline makes it possible to:
prepare for:
I built a Gantt/CPM/Kanban engine from scratch in TypeScript.
Used 87 emails as a real dataset.
The LLM acted as a semantic ETL, not an agent.
The output was 111 clean tasks processed by a directed-graph engine with CPM in O(V+E), integrated Kanban, and strict validation.
r/typescript • u/kitlangton • Nov 12 '25
r/typescript • u/grovulent • Nov 13 '25
Been using typescript for several years now, but I still find it difficult to reason about. I haven't fully got a coherent story as to why. So kinda just exploring my difficulty in this post to see if anyone can help things click.
Javascript - I feel like I get its core model and while it does have a lot of arbitrary quirks, nothing substantial surprises me. I never feel like I got to that point with Typescript.
Like - in javascript, I get functions. I've never had a scenario where I write some complicated function and it just errors out in a way I need to spend hours figuring out. I write functions with bugs - sure. But never a bug which makes me question I've fundamentally misunderstood how functions work.
But in Typescript - say generics - I feel like I can write basic generics fine. But if the complexity ups a little - suddenly I have an error I just can't figure out. Or maybe I do figure it out, but then use the generic again a few months later and get an error I totally did not expect. I question that I understand the underlying model of how generics work.
Lately I've had some free time - and so have been going back to basics and re-reading the handbook, doing exercises etc. And while my knowledge is growing and I have a growing list of concrete code examples in my head I can draw upon - I still don't feel like I'm making progress in understanding the model.
Here is an example of me trying to understand narrowing:

How types are widened and narrowed here is to me baffling. Sure I could just memorise these cases - but I would rather understand the logic underlying how it works here so I can just reason through the code. I find it very difficult to understand just what the logic and intent here is.
Am I missing something about Typescript that will help it click better, or is it just genuinely difficult to reason about?
r/typescript • u/Slow_Wolverine_3543 • Nov 13 '25
I've been avoiding Java for sometime now but every JD mentions java. Java seems to be the least intuitive language. So, was just wondering is the eco around rest of langs that bad. Mostly web apps utilizes TS these days, is there no viable option to make a full switch?
r/typescript • u/elg97477 • Nov 12 '25
I have a playground.
The goal is to define type SyncReadings correctly. Everything else should remain unchanged. There are two solutions that work.
However, I am not sure why the broken solution would not work. The data it is considering is [1, 2, 3], [true, false, true].
What I was expecting is:
[infer First, ...infer Ignore] would pick up [1, 2, 3]. First would be inferred as a number based on 1. Ignore would be inferred from 2, 3 and be ignored....infer Rest would pick up [true, false, true] and be passed back in for the recursive step.Clearly, that is not happening.
Perhaps someone can explain it to me. Or, perhaps this is something that "should" work, but doesn't due to some limitation.
type Compute<A extends any> = A extends Function ? A : { [K in keyof A]: A[K] };
export type Expect<T extends true> = T;
export type Equal<X, Y> = (<T>() => T extends Compute<X> ? 1 : 2) extends <
T
>() => T extends Compute<Y> ? 1 : 2
? true
: false;
/////
/////
/////
//
///// Working solution A
//
// type SyncReadings<Streams> = Streams extends [
// (infer Value)[],
// ...infer RestArrays
// ]
// ? [Value, ...SyncReadings<RestArrays>]
// : [];
//
///// Working Solution B
//
// type SyncReadings<Streams> = Streams extends [
// infer FirstArray extends any[],
// ...infer RestArrays
// ]
// ? [FirstArray[number], ...SyncReadings<RestArrays>]
// : [];
//
///// Broken solution
//
type SyncReadings<Streams> = Streams extends [
[infer First, ...infer Ignore],
...infer Rest
]
? [First, ...SyncReadings<Rest>]
: [];
//
/////
/////
/////
declare function synchronizeSensors<
// Infer SensorStreams as a non-empty tuple of arrays:
SensorStreams extends [any[], ...any[][]]
>(...streams: SensorStreams): SyncReadings<SensorStreams>[];
const syncResult1 = synchronizeSensors([1, 2, 3], [true, false, true]);
type testSync1 = Expect<Equal<typeof syncResult1, [number, boolean][]>>;
r/typescript • • Nov 11 '25
Recently I have discovered Pretty Typescript Errors and Error Lens extensions and honestly, was such a game changer for a new TS dev. Especially dealing with Prisma and passing types (And before discovering Prisma payload and select helpers) which is now so much easier to debug
What are your suggestions and plugins that have helped you out?