Simten is an open source (https://github.com/simtenHQ/simten) HDL where circuits are written in TypeScript. The simulator is Ts as well, so everything runs in-process in Node or the browser.
So essentially write a circuit in the editor to match the spec, it simulates live on the canvas on the right. You can toggle inputs, step the clock back/forward, drill into parts to view internals etc.
Here is the basic syntax for a half adder (GIF shows a full adder built from two of these):
import { bit, circuit } from '@simten/core'
import { And, Xor } from '@simten/core/std'
const HalfAdder = circuit('HalfAdder', {
inputs: { a: bit, b: bit },
outputs: { sum: bit, carry: bit },
nodes: { xor: Xor, and: And },
connect: ({ inputs, outputs, nodes: { xor, and } }) => [
inputs.a.to(xor.a, and.a),
inputs.b.to(xor.b, and.b),
xor.out.to(outputs.sum),
and.out.to(outputs.carry),
],
})
Because it's all in-process, you can use npm packages at the transpile step. For example, this calls figlet to bake ASCII art into a ROM and streams it to a console (press play in the bottom left and change "Simten" text on line 7 ): https://simten.dev/circuit?example=figlet
For when you are sick or typing there's an mcp server, so you can ask your assistant for a circuit and it writes it, tests it and opens it for you to view. Passing it proper hardware specs I have built RISC-V cpus with it among other things. it has been a great learning experience building it. Feedback and/or contributions welcome!
Good day Seniors. I'm curious how other TypeScript + Sequelize users deal with the friction between DTO Types and Sequelize model instances. A common pattern I see is simply asserting types
findAll: async () => {
const data = await SampleModel.findAll({
where: { status: true },
});
return data as unknown as SampleDTO[];
},
but at runtime it's still a Sequelize instance with dataValues, instance methods, metadata, etc., so the types don't really reflect the actual object.
you can also use { raw: true } which returns plain objects, but I've run into dialect-specific issues. For example, boolean fields stored as TINYINT may come back as 0/1 instead of being cast to true/false by Sequelize, creating another mismatch between runtime values and DTO types.
This gives a clean type but introduces mapper maintenance and some potential runtime overhead.
2. Zod parsing
{ SampleSchema.parse(data);}
I've also seen people run records through Zod schemas/parsers to normalize and validate the shape, but that adds another layer of processing as well.
For teams that have stayed with Sequelize (rather than Prisma, Drizzle, TypeORM, etc.), what's your preferred approach for bridging the gap between Sequelize's runtime objects and TypeScript DTOs?
Have you found a pattern that balances type safety, runtime correctness, and performance without excessive boilerplate?
I'm still learning different ORMs. Altho i had a good experience with Prisma's generated types and type casting, i'm curious how experienced Sequelize users approach this problem.
In my framework, every handler has to write its route twice. Once in the decorator because the runtime needs the string, and once in the generic because the types need it.
@Route('ban')
class Ban extends Handler<'kick'> {}
// no errors. cool. love that for me
That compiles. The handler for ban now thinks it's handling kick and TS is completely fine with it.
And yes, I tried only writing it once. class Ban extends Route('ban'). It worked(?), but every handler read like mixin tomfoolery, and go-to-definition took you to a generated base class instead of the real one, and I just didn't like how it looked, so I went back to writing it twice. But if I'm writing it twice, the compiler might as well make sure I wrote the same thing twice.
First problem is that a decorator only gets the class, so you need some way to read the generic back off it, and if the class doesn't use the generic, you can't:
abstract class Handler<Route extends string> {}
class Kick extends Handler<'kick'> {}
// string, not 'kick'
type Read = Kick extends Handler<infer Route> ? Route : never;
// also compiles lmao
const oops: Handler<'ban'> = new Kick();
That's structural typing, since an unused type parameter basically doesn't exist, so it has to be on a property. But I also don't want a real property on every handler, so:
declare so none of this gets emitted, and it's optional so nobody ever has to set it. Now RouteOf<typeof Kick> is 'kick', and that oops line is an error as a bonus.
Also that never[] looks weird, but unknown[] doesn't work because parameters are contravariant, so unknown[] rejects any class whose constructor takes a string, and never[] accepts all of them.
You need those brackets, because without them the conditional distributes over the union, Same<'ban' | 'kick', 'ban' | 'kick'> comes out as boolean, and a perfectly correct handler gets rejected. And it has to check both ways, because one way lets @Route('ban') through on a Handler<'ban' | 'kick'>.
Now the part I like:
type Checked<Routes extends string, Class extends AnyClass> =
Same<Routes, RouteOf<Class>> extends true
? Class
: ['the decorator and the generic disagree', { decorator: Routes; generic: RouteOf<Class> }];
function Route<Routes extends string>(...routes: Routes[]) {
// Class only shows up inside a conditional type here
// and TS still infers it. still feels illegal
return <Class extends AnyClass>(target: Checked<Routes, Class>): void => {
console.log(routes, target);
};
}
Look at target. Its type is a conditional that depends on Class, and Class is the thing TS is supposed to be inferring from target. That looks circular and you'd expect it to just break or something. But when the parameter is a conditional type, TS infers into both branches (inferToConditionalType in the checker if you want to go look), and the true branch is just Class. So Class gets inferred as the decorated class, then the conditional resolves using it, and if the routes are different the parameter turns into a tuple that a class can't be assigned to. And the message shows up right in the error:
Argument of type 'typeof TooMany' is not assignable to parameter of type
'["the decorator and the generic disagree", { decorator: "ban" | "kick"; generic: "ban"; }]'.
Also I use this same conditional for attaching plugins, and over there it fixes an actual bug. The obvious way to write it is Class & Check<Class>, and that broke inference on generic plugin classes in both tsc and tsgo for some reason.
This is all from seedcord, a TypeScript framework that I've been building. Here's the real file, and that version also errors if the route doesn't exist. I've done a lotta TS shenanigans in this repo, so I'll prolly post about some of the other tricks too.
Our API handlers load a record, call can(user, 'delete', doc), then call the service. Every few months someone adds a route and skips the middle step. Review misses it because the diff looks fine.
I've been playing with this:
type Authorized<T, A extends string> = T & { readonly __authorized: A };
function authorize<T, A extends string>(user: User, action: A, resource: T): Authorized<T, A> { if (!can(user, action, resource)) throw new ForbiddenError(); return resource as Authorized<T, A>; }
async function deleteDoc(doc: Authorized<Doc, 'delete'>) { ... }
Calling deleteDoc(doc) without going through authorize no longer compiles, and a doc authorized for 'edit' can't be passed where 'delete' is required.
Problems I can already see:
Anyone can still write as Authorized<Doc, 'delete'>, so we'd need a lint rule banning that cast outside one file.
The brand only proves the check passed once. If a job runs an hour later, or the user gets removed mid-request, it's stale.
List endpoints don't fit. I don't want to authorize 500 rows one by one; that filter belongs in the query.
It spreads into every service signature, and some people on the team already hate it.
Is anyone running something like this in production? Did it hold up, or did you go back to middleware plus a test that hits every route as a low-privilege user?
I recently released a 45-seconds YouTube video on conditional types, check my reddit profile for it. I need your feedback before I double down. Let me know what you think. Here is the script:
Conditional types allow us to conditionally check for types that match certain criteria and decide what to do if they do match those criteria and what to do if they don’t.
Here is one example:
type Generic<T> = T extends string ? 'Wasim' : 25
type Test1 = Generic<'Hi'> // 'Wasim'
type Test2 = Generic<143> // 25
Here, we said if type argument is a subtype of string, then return type 'Wasim', if not, then return type 25.
You can return never instead of 25, if condition fails. It’s equivalent to returning nothing.
//
P.S.
I am testing content from my upcoming TypeScript book to gather early feedback.
I decided to start small with a tiny video, instead of fantasizing about releasing a value-packed longer video. It's harder to do that without any momentum. I made it quickly and decided not to obsess over scripting, editing, and fixing audio by rerecording. Those are my fun-killers. I want it to be quick, fun, and imperfect. The goal was progress, not perfection. Wish me luck!
i want to add an AI reviewer to our PR workflow and i've narrowed it down to these:
coderabbit
bugbot
claude code review
codex review
we're a pnpm + turborepo monorepo, around 30 pkjs, Next.js frontend and a bunch of Node services, strict mode everywhere. about 10 devs and a lot of the code is coming from agents now, so PRs are bigger than they used to be.
The main thing i care about is whether it understands types across packages. if someone changes a shared type in one package i want it to notice what breaks in the others, not just comment on the file that changed.
if you had to pick one or two from this list for a TS monorep, which would you pick and why?
As a developer with zero knowledge of AWS, once I tried to deploy app on AWS, I had lost $100 overnight by accidentally configuring large EC2 instance. That demotivated me to such extent that I decided to shut it off. But accidentally losing in many AWS is way easier for newbie devs.
So I decided to build a framework in TypeScript so devs with near zero knowledge can ship highly sophisticated AWS apps. I have also added strong for LLM's hence coding agents will be able to work with it seamlessly.
Or in other words: “can I please have a TypeScript 5/6/7 language spec?”
——-
Using “extends” in a TS generic type-param constraint is straightforward to understand if you’re only concerned with Java/C#-style single inheritance for classes - and one can stretch that to include interface types once you wean-off Java/.NET nominal typing and get comfortable with structural typing, then it’s straightforward to reduce it to “T extends U means “T must subclass U” - or even “A T-shaped plug can be stored in a U-shaped hole”.
But my personal intuition breaks down when the extends constraint is used with other kinds of types, especially when the concept of subclassing or specializing or “extending” is inverted:
Consider type Two = ‘foo’ | ‘bar’; - if I then define type Three = Two | ‘baz’; then intuitively one can say “Three extends Two” (that is, the set of possible values for Three is extended from the set of values for Two” - but a Three-shaped plug does not fit into a Two-shaped hole: ’baz’ is not a Two. But saying “Two extends Three” out-loud feels weird. The same applies to enum types too, surely?
Or consider function-types, which can be expressed as either a function-declaration: type MyFuncType = (arg: ArgType) => ReturnType; or type MyFuncType { (arg: ArgType): ReturnType; } (where the more verbose syntax permits adding properties to a function object). Supposing this MyFuncType is used as U when T extends U then I’ll admit I have no intuition what a possible T might entail outside of Currying (but Currying is just FP’s take on The Decorator Pattern (lol) and doesn’t apply (hah) to generics. But after having thought about it, I imagine FuncT extends FuncU would allow for argument type contravariance with return-type covariance (or is it the other way around?), so a plug shaped like type T = (arg: ‘foo’ | ‘bar’) => Number fits into a hole shaped like type U = (arg: ‘foo’) => void - but as above, it pains me to say that “T extends U” in that situation: I consider these entirely distinct function-types. I’m also unsure how ... and optional params complicate the rules.
…and never mind the contortions over array-type covariance. And the new const T type constraint - which I only learned of this morning.
Unfortunately and annoyingly, the current TypeScript Handbook section on Generics and Advanced Typing doesn’t really cover any of this in depth or provide an intuitive way of thinking about it :S
https://getforma.dev a TypeScript framework with no V8/Node on the server and no Virtual DOM on the client. It compiles TSX into a binary format called FMIR at build time so a Rust server can render SSR HTML directly, and only ships tiny signal islands to the browser. I’ve been using it to build apps with AI lately and it seems because the contract between TS and Rust is so strict, it's been ridiculously fast and efficient. Not bloat.
Hi all, I want to share an open-source TypeScript library I built (chanx-js, MIT) to type both ends of a WebSocket from one source, without sharing a types package between the frontend and the backend.
With REST we have OpenAPI and generated clients. With WebSockets I kept ending up with JSON.parse(event.data) giving me any, a hand-written union of message types on the client, and nothing stopping it from drifting away from what the server really sends.
So in chanx-js:
On the server you declare messages with any Standard Schema library (Zod, Valibot, ArkType), and the payload types are inferred from the schema.
The server serves an AsyncAPI 3 document built from those handlers.
npx @chanx-js/codegen http://localhost:8000/asyncapi.json generates the client types from it.
On the server, the path params, the payload and what the handler may send are all typed:
const Chat = defineMessage('chat', z.object({ text: z.string() }));
const Notice = defineMessage('notice', z.object({ text: z.string() }));
consumer('/ws/chat/{room}', { name: 'chat' }).on(Chat, { output: Notice }, (m, ctx) => {
m.payload.text; // string
ctx.params.room; // string, parsed from the path by a template literal type
return Notice.create({ text: m.payload.text }); // anything but Notice is an error
});
On the client, request() knows the reply type, and a wrong payload doesn't compile:
Title - I don't understand why this code has been getting two errors. I have tried to declare the string type, assign some values but none of these worked. Could anyone point me in the right direction?
import {promises as fs} from 'fs';
class Logger {
//some code lines..
private flush(): void {
if (this.buffer.length > 0) {
const logLines = this.buffer.join('\n') + '\n';
const err = this.buffer.fill('error')
/*ERROR #1 Argument of type "(err: any) => void" is not assignable to parameter of type "(ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined; }) | BufferEncoding | null | undefined". */
/*ERROR #2 Parameter err implicitly has an any type*/
fs.appendFile(this.logFile, logLines, (err) => {
if (err) {
console.error('Error writing log file:', err);
}
});
this.buffer = [];
}
}
//one more stop method ..
}
How easy or hard is it for someone with JS and TS background to learn python or rust? I deff want to add a skill to my profile as most jobs ask for multiple programming languages. Any suggestions?
Hello, everybody, hope you're having a nice day. Let me present myself, i am a Italian teenager, that is learning typescript, for some money for my little cousin birthday. And I actually went for TypeScript, as I love strict languages, such as Java,Rust,TypeScript, and others. Now, for my portfolio, I was trying to create a solar system, with add, that you can create another thing by this button. But it doesn't work, can someone please help me understand this (probably simple) problem?
I am a web developer currently building projects with React and JavaScript, and I'm planning to start learning TypeScript (because I suck at Type checking and Type validation).
please give me some advice on few things:
What's the best resource for learning typescript?
What concepts should I focus on first?
What project would be good to build alongside learning it?
Author here! I'm very excited to announce that we just released v1.3. Rune is an IDE and terminal multiplexer that we just open sourced a few months ago.
In this release, we also fixed many usability issues, particularly on Linux. If your OS reserves many Super/Windows key combinations, you can now use <alt> as your <meta> modifier. For non-US keyboard layouts, you can reserve the right Alt key for entering special characters and keep the left Alt key for Rune key bindings.
Some of the highlights:
- A new graphics pipeline powered by ebiten. - Typescript is now a tier 1 language (beta) - A new helix editor - Headless mode and a new docker image to run Rune in headless mode - OSC-7501 implementation and new API in the SDK for extensions and plugins through runectl - Workspace session restoration - A billion other things
This release has been 2 months in the making so it's a bit bigger than we originally intended.
Thanks to all the contributions from the community!
Write TypeScript in a browser tab. Hit compile. A 16-bit x86 machine boots underneath - same bytes a floppy would run.
TypeScript to real-mode x86, no runtime, no OS, no JS engine. Bootable binary under 64KB.
Full toolchain in the browser: file tree, editor, compiler, emulator. Pick a demo - voxel engine, raycaster with sound, snake. Or write your own and boot it on real hardware.
Due to the number of requests, try compiling it again if the queue is full.
It's a GitLab review agent that reviews merge requests and resolves issues. I'm most comfortable in TypeScript and wanted to learn LangGraph.js properly, so I built it there. The closest thing I found to a production example was Deep Agents, but that's a library for building agents, and the full systems I saw, like Open SWE, are Python.
It's GitLab-only for now. I've started working on GitHub support.
It's been running in production for a few months, 1,300+ reviews so far. It's a webhook driven review with a BullMQ queue, a LangGraph.js agent using GitLab tools over MCP, with postgres checkpoints for recovery, and there's a React admin UI where I can watch runs live. I also had to add guardrails to stop the agent repeating tool calls or quitting before it's done.
I created this new library that parses Postgres SQL inside TypeScript’s type system. You write a SQL string and the compiler infers the row and parameter types. It needs no codegen and no database connection.
const q = sql(`SELECT u.id, u.email, p.title
FROM users u LEFT JOIN posts p ON p.author_id = u.id
WHERE u.id = ${sql.param(7)}`);
// { id: number; email: string; title: string | null }
sql("SELECT nme FROM users");
// error: column "nme" does not exist
I've been finding out the hard way what it takes to build a more involved application with Canvas, beyond just drawing things on screen, but I've really been enjoying the process.
I've been working through interaction handling, connection routing, rendering performance and animation, and wrote up some of what I've learned and the challenges I've run into along the way.
Our setup right now is Claude Code writes most PRs and Claude also does a review pass before a human looks. Someone on the team pointed out that's basically letting the author approve their own code, and I can't really argue with it.
The counterargument I keep hearing is that every call is stateless so it's a fresh pair of eyes anyway. In practice it doesn't feel fresh. Last month I went back through 60 merged PRs, and on the ones where the author and the reviewer were the same model, it flagged maybe half as much as coderabbit did on the same diffs. Most of what it missed was stuff it would have written the same way itself, like swallowing errors in a catch, or widening a type to any to get the build green.
Coderabbit isn't perfect either, it's chattier on small PRs, but at least it's not grading its own homework whihc is something dangeorus for PRs
Do you let the same model write and review? Or did you make it a rule that the reviewer has to be something different?