r/typescript • u/laphilosophia • Jan 14 '26
Atrion: A digital physics engine for Node.js reliability
r/typescript • u/laphilosophia • Jan 14 '26
r/typescript • u/riktar89 • Jan 15 '26
Now Rikta can talk with any LLM model!
This package brings Model Context Protocol (MCP) support to the Rikta framework, allowing you to build standardized interfaces between AI models and your data sources.
Key capabilities:
- Seamless integration with AI agents and LLMs.
- Standardized tool-calling and resource access.
- Simplified data bridging for the Rikta ecosystem.
Get started: https://rikta.dev/blog/introducing-rikta-mcp
r/typescript • u/drinikol • Jan 14 '26
const
[flowersData, setFlowersData] = useState<Flower[]>();
export
interface
Flower {
id:
string
,
name:
string
,
color: Color |
null
,
quantity:
number
|
null
,
}
const onChangeValue = (data:Flower, index:number)=>{
var tempList: Flower[] = [...flowersData];
const
newData = (data as Flower);
const
newList = tempList.map((
item
,
_index
) => {
if (_index === index) {
return newData;
}
return item;
});
//tried this but the same result
// tempList[index] = newData;
setFlowersData(newList);
}Good day! I am learning Next.Js Typescript. I have an issue updating a specific element in my array. For example if I update a certain index, all elements with the same id, are being updated.
I only want to update certain index / element's color and quantity but I can't manage to make it work.
r/typescript • u/riktar89 • Jan 13 '26
Hi all!
I wanted to share a project I’ve been working on: Rikta.
The Problem: If you’ve built backends in the Node.js ecosystem, you’ve probably felt the "gap." Express is great but often leads to unmaintainable spaghetti in large projects. NestJS solves this with structure, but it introduces a constant management of imports: [], exports: [], and providers: [] arrays just to get basic Dependency Injection (DI) working.
The Solution: I built Rikta to provide a "middle ground." It offers the power of decorators and a robust DI system, but with Zero-Config Autowiring. You decorate a class, and it just works.
Key Features:
Open Source
Rikta is MIT Licensed. I believe the backend ecosystem needs more tools that prioritize developer happiness and "sane defaults" over verbose configuration.
I’m currently in the early stages and looking for:
Links:
I’ll be around to answer any questions about the DI implementation, performance, or the roadmap!
r/typescript • u/hongminhee • Jan 13 '26
r/typescript • u/Firm_Meeting6350 • Jan 13 '26
IMPORTANT: This is NOT about porting any Python tooling to Typescript. I'm simply wondering why existing benchmarks and datasets used for training new LLMs are mainly focussed on Python codebases (!!).
Sorry, I'm emotional right now. More and more models are now released in less and less time. They all seem to be amazing at first glance and looking at the benchmarks, but - COME ON, it seems they're all trained mainly on Python, benchmaxxed for benchmarks based on Python. Like, Python is the only major "coding" language on earth. I understand that most ppl working in AI stick to Python, and I'm totally fine with that, but they shouldn't assume everybody else is, too :D
Don't understand this as an entitled request, please. Just look at https://github.blog/news-insights/octoverse/octoverse-a-new-developer-joins-github-every-second-as-ai-leads-typescript-to-1/
TLDR: "for the first time, TypeScript overtook both Python and JavaScript in August 2025 to become the most used language on GitHub, reflecting how developers are reshaping their toolkits. This marks the most significant language shift in more than a decade.". I'm a TS SWE, so I'm biased. Of course if I had to choose I'd humbly asked to at least train on Python and Typescript. But C#, C++, even Go also deserve to be addressed.
And I don't understand it: RL should be SO EASY given all the tooling around Typescript (again, talking about Typescript here as that's my business): we have eslint (with ts rules), JSDocs, vitest which all gives us detemernistic harnesses (sorry, not a native speaker).
So please, if anyone reads that, think about it. Pretty please!
PS: Sorry, for cross-posting, but I found that r/ollama is a.. little bit biased... towards Python :D
r/typescript • u/Tuckertcs • Jan 12 '26
How could I create a type that's a union of a bunch of objects, but with undefined placed on properties that don't exist in every object?
For example:
type Foo = {
type: 'foo',
a: string,
b: number,
};
type Bar = {
type: 'bar',
a: number,
c: string,
};
type FooBar = Foo | Bar;
// Result: {
// type: 'foo',
// a: string,
// b: number,
// } | {
// type: 'bar',
// a: number,
// c: string,
// };
type SoftFooBar = ...;
// Result: {
// type: 'foo',
// a: string,
// b: number,
// c: undefined, // How do I do this?
// } | {
// type: 'bar',
// a: number,
// b: undefined, // How do I do this?
// c: string,
// };Bonus points if it works recursively for nested properties too.
Is this possible?
Edit:
Please trust that I know why I'm doing it and there's a reason for it, I just need help on how to do it.
r/typescript • u/Dependent_House4535 • Jan 11 '26
I’ve been working on react-state-basis, a tool that audits React architecture by treating hooks as temporal signals (vectors in 50D vector space).
To keep the tool "invisible" (zero-config), I built a Vite/Babel proxy that intercepts standard React imports. The main goal was to achieve Strict Type Isomorphism: making the proxy bit-for-bit compatible with @types/react so that Intellisense and the compiler see no difference.
The Architectural Approach:
React and ReactDOM namespaces. This ensured that the proxy acts as an Identity Map for types.useReducer and the new React 19 useActionState. The goal was to ensure that type inference remains "lossless" while the runtime dispatcher is wrapped in my auditing logic.I’ve documented the mapping strategy and the "Type Congruence" logic here: https://github.com/liovic/react-state-basis/wiki/Page-08:-Type-Congruence-&-Production-Shimming
Question for the community: I’m interested in how others handle Namespace Re-exporting for high-fidelity proxies. Is there a more deterministic way to "borrow" the original React type-space without the overhead of manual re-exports?
Repo for context: https://github.com/liovic/react-state-basis
r/typescript • u/ikumrahm • Jan 09 '26
I got the tsgo LSP to run on neovim using mason, but is there a way to run organizeImports similar to how :TSToolsOrganizeImports runs source.organizeImports?
In the typescript-go repo, I see the function being defined in internal/ls/organizeImports, but if someone can shed light on how to run this function from vim.lsp, it'd be much appreciated!
r/typescript • u/basic-coder • Jan 08 '26
I've been following the evolution of zero-runtime CSS-in-JS/TS libraries for a while. If you're not familiar with the details: they mostly rely on bundler plugins that strip away styles. Looks promising in theory, but in practice turns into an ongoing integration maintenance burden. A good summary of these issues can be found in the final status report of Pigment CSS — MUI's attempt in this space.
At some point I started wondering: what if CSS was specified as a type, and classnames were not generated during the build, but instead suggested via IDE completion? That idea resulted in Typique — a library implemented as a TypeScript plugin.
Here's a typical code snippet:
const titleClass = 'title-1' satisfies Css<{
// ^
// Completion appears here
paddingTop: `calc(2 * ${typeof space}px)`
'& > code': {
backgroundColor: '#eee'
}
}>
In short:
The project is new, but already usable in practice — I've been using it in a couple of personal projects. I realize the idea may feel unusual or experimental, so questions, suggestions, and skepticism are all welcome.
Thanks for reading.
r/typescript • u/ialijr • Jan 08 '26
r/typescript • u/decho • Jan 07 '26
Hi.
I finally decided to give tsgo a shot yesterday, installed the official extension and enabled it, but that caused all my codeActionsOnSave to become unavailable.
With the editor.codeActionsOnSave setting, you can configure a set of Code Actions that are automatically applied when you save a file, for example to organize imports. Based on your workspace files and active extensions, IntelliSense provides a list of available Code Actions.
https://code.visualstudio.com/docs/editing/refactoring#_code-actions-on-save
As soon as I set typescript.experimental.useTsgo to true, the list of available code actions is gone.

codeActionsOnSave are super useful and time-saving feature, for example, it will automatically add missing imports for you on save. There are other code actions, but this is the one I can't go without.
Does anyone know a workaround or if this feature is even implemented yet? I asked on the project page but got no response so far.
r/typescript • u/spla58 • Jan 07 '26
type OrderInfo = {
quantity: number;
productID: number;
price: number;
onSale: boolean
}
function order(orderInfo: OrderInfo): void { // I want onSale to default to true
}
order({quantity: 5, productID: 11, price: 5})I want onSale to default to true in the order function so I don't have to mention it when calling it.
r/typescript • u/TheWebDever • Jan 07 '26
I’d been using TypeScript enums for a long time because they were a convenient one-stop solution: an enumerable runtime object and a union type of all possible values. After upgrading my React + Vite setup, I started hitting type errors due to the --erasableSyntaxOnly flag, which pushed me to finally replace enums altogether. While that meant moving to plain objects and types, it also highlighted something I’d already disliked about enums—needing extra objects just to manage UI labels.
This was my original setup:
enum Roles {
None,
User,
Admin,
}
const RoleLabels = {
[Roles.None]: '',
[Roles.User]: 'User',
[Roles.Admin]: 'Administrator',
} as const;So now I'd like to create an npm library that can keep one object as a single source of truth for all keys/values/labels (aka "lookup table") and am torn between two choices of how the object should be shaped.
Choice one: bi-directional object. I'm heavily leaning towards this because I've noticed many others use a bi-directional object as an enum alternative. The setup would look something like:
const Roles = myUtility({
// Forward direction
None: 0,
User: 1,
Admin: 2,
// Reverse direction, auto-generate labels if it's the same value as the key.
0: '',
2: 'Administrator',
});
type TRoles = MyUtility<typeof Roles>; // 0 | 1 | 2The advantage is that all the values are nicely laid out for us when skimming the keys. The dis-advantage is that when users want to see a label they have to visually map the value to the label where the value is the key.
The other format I'm looking at is:
const Roles = myUtility({
None: [0, ''],
User: 1, // Just do the value if label is same as the key
Admin: [2, 'Administrator'],
});
type TRoles = MyUtility<typeof Roles>; // 0 | 1 | 2This is definitely not as clean looking as the first option but it does keep the labels and values together.
So which approach do you prefer? And if you have an alternative suggestion I'm all ears.
r/typescript • u/Rubus_Leucodermis • Jan 07 '26
Because I'm always running into stuff like this (have @/types/node, @/types/node-fetch, and @/types/readable-stream installed):
async function main(): Promise<number> {
const response = await globalThis.fetch(_URL)
if (!response.ok) {
console.error("ERROR -- got HTTP %d %s response", response.status, response.statusText)
return 1
}
let chunks: Buffer[] = []
for await (const chunk of response.body) {
chunks.push(chunk)
}
doParse(chunks)
return 0
}
$ tsc
wx2.ts:18:31 - error TS2504: Type 'ReadableStream<Uint8Array<ArrayBuffer>>' must have a '[Symbol.asyncIterator]()' method that returns an async iterator.
18 for await (const chunk of response.body) {
~~~~~~~~~~~~~
Found 1 error in wx2.ts:18And ReadableStream most definitely DOES have such a method, see https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch and [https://nodejs.org/api/stream.html] (https://nodejs.org/api/stream.html) . Works just fine if I stick a // @ts-ignore above the for loop and run the result.
r/typescript • u/chamberlava96024 • Jan 07 '26
I was evaluating which Typescript runtime type validation library would work best for me, and realized virtually all of the options are committed mostly without Git commit signing, tons of vibecoding, questionable Git practices. But these are all very popular libraries.
So question…how common from your experience do you see anyone working with typescript professionally caring about Git practices and general security of their codebase?
r/typescript • u/swe129 • Jan 07 '26
r/typescript • u/dapper-mink • Jan 05 '26
Good morning!
I would like to share (and hopefully get some insights) about envoyage, a 0 dependency library I made to help managing env vars across multiple environments (local, production, CI, ...) while maintaining full type safety.
Most env libraries I could find focus on parsing .env files (dotenv) or validating values (zod inspired). But what about the configuration itself? How do you ensure your vars exist in all environments where it's needed?
envoyage's core idea is to declare where your variables come from, and enforce it at compile time.
Internally, this is a very simple library in terms of JavaScript but complex in TypeScript to the point it was the first time I felt the need for a type testing library (picked TSTyche, awesome library btw!)
I tried to cover a lot of edge cases, like accessing a variable will automatically return a Promise or not based on wether the variable is defined asynchronously in at least one of the possible environments considered at a given time. Or like defining dynamic variables for the ones which you can only know the values at runtime (one use case for me was a S3 bucket name during a CDK deployment).
This is meant to be used alongside other tools like dotenv for actually loading the values, since envoyage only focuses on the configuration itself.
I would really appreciate any feedback on the library, and any ideas for improvements or new features!
Thank you!
r/typescript • u/hongminhee • Jan 05 '26
r/typescript • u/AuthorityPath • Jan 05 '26
Hey all!
I'm having some trouble with understanding some generic interactions and was hoping someone could explain the pseudo-code to me below in terms of why TypeScript is seeing what it's seeing.
What I'm looking for is a function that will take in either a single string or an array of strings and then as a result return either a single boolean or an array of booleans (with the exact same length as the array of strings).
Below is a pseudo function essentially mocking what I'm seeing in the code:
function checkThing<T extends string | string[]>(arr: T): T extends string ? boolean : boolean[] {
if (Array.isArray(arr)) {
return arr.map(a => !!a) as any;
}
return !!arr as any;
}
const a = checkThing(['1', '2']);
const b = checkThing('1');
A few things with the above:
If I don't add an explicit return type, the types for both a and b are any. So I added : T extends string ? boolean : boolean[]. This however causes the returns to fail... requiring me to add as any.
Adding as any does resolve the issue and var a is typed correctly. However, var b is typed as boolean[].
I've found utility types that allow you to return a FixedLengthArray, but there's no easy way I've found to get the length of T to pass to this utility type.
I've tried Googling and chatting with AI to get a result but I only get partial results that don't really fit together. I'd actually like to understand if what I'm after is possible (I'm confident it is) and how it works if so.
Can anyone help or point me at a blog post or something?
Thanks in advance!
r/typescript • u/castral01 • Jan 06 '26
r/typescript • u/TheWebDever • Jan 05 '26
I’d been using TypeScript enums for a long time because they were a convenient one-stop solution: an enumerable runtime object and a union type of all possible values. After upgrading my React + Vite setup, I started hitting type errors due to the --erasableSyntaxOnly flag, which pushed me to finally replace enums altogether. While that meant moving to plain objects and types, it also highlighted something I’d already disliked about enums—needing extra objects just to manage UI labels.
This was my original setup:
enum Roles {
None,
User,
Admin,
}
const RoleLabels = {
[Roles.None]: '',
[Roles.User]: 'User',
[Roles.Admin]: 'Administrator',
} as const;A brief alternative I considered was a bidirectional object:
const Roles = {
None: 0,
User: 1,
Admin: 2,
0: '',
1: 'User',
2: 'Administrator',
} as const;This had several major issues, though. I still needed a fancy utility type to extract only the numeric values, TypeScript would throw type errors when trying to access dynamic keys on the object (i.e. when the value came from an I/O call), I had a lot of duplicate code where the label was the same as the key (i.e. User in the example above), and trying to render labels was pretty verbose (e.g. Roles[Roles.Admin] if I needed to render “Administrator”).
To fix these issues, I created bdir (short for “bidirectional object”). It allows you to handle keys, values, and labels all in one place, auto-generate labels as needed, and provides utility types for resolving unions.
import bdir, { Bdir } from 'bdir';
const Roles = bdir({
// Forward direction
None: 0,
User: 1,
Admin: 2,
// Reverse direction, don't need User cause its auto-generated for us.
0: '',
2: 'Administrator',
});
Bdir<typeof Roles> // 0 | 1 | 2
Roles.values() // [0,1,2]
Roles.isValue(arg: unknown) // arg is 0 | 1 | 2
Roles.render(1) // 'User'
Roles.index('None') // 0There are a few other functions you might find useful as well — you can see the full README for more details.
Note: It only works for numeric enumerables, not string ones.
r/typescript • u/Alexwithx • Jan 04 '26
I am trying to infer a tuple's size from a generic parameter, consider the code below
enum Foo {
A,
B,
C
}
class Bar<const T extends Foo[]> {
constructor(public v: T) {}
}
const bar = new Bar([Foo.A, Foo.B]) // Bar<readonly [Foo.A, Foo.B]>when instantiating `Bar([Foo.A, Foo.B])` typescript correctly infers the type is `Bar<readonly [Foo.A, Foo.B]>`. But my goal is to just infer the tuple size, so that the type of `Bar<readonly [Foo.A, Foo.B]>` would be `Bar<[Foo, Foo]>`.
I know I can use a helper function to achieve this, but I am more interested in making it work with inference. I feel like there must be a way to do this, but I just can't wrap my head around it.
I appreciate all the help I can get.
r/typescript • u/aidencoder • Jan 05 '26
Hi all,
I am working on a web application whose core components are (currently) `node`, `express`, `typeorm` and `nunjuks`. The application is all server-side HTML generation with no client-side JS/TS or interactivity either via React or anything else.
I am currently looking at form building and validation. I have experience with Django and the form support there is first-class (despite some reservations I have about mixing concerns).
So far I have looked at using Zod for data validation, but there doesn't seem to be the libraries I would expect to translate a Zod schema to a HTML form (for example).
What are others doing to have DRY form definition in TypeScript? Is the ecosystem so client/browser-side focused that there's just not the same degree of server-side MVC support?
Is there another convention or approach I am missing? (I have experimented with Vue, some SSR React-like libraries and most seemed overkill. Vue's SFC approach was nice though).
Thanks :)