Typescript Needs Types Save

TypeScript please give us types.

Project README

TypeScript Needs to Emit Runtime Type Information

Please send a PR to add to this list. Even if it's your own project and it has zero stars, you had to deal with this, so it goes on the list.

The Unfortunate List of Projects Working Around this Issue

Type Mapping Projects
Project Stars
zod GitHub stars
nimbit GitHub stars
io-ts GitHub stars
yup GitHub stars
joi GitHub stars
TypeGraphQL GitHub stars
Deepkit GitHub stars
redux-orm GitHub stars
superstruct GitHub stars
ts-pattern GitHub stars
runtypes GitHub stars
class-transformer GitHub stars
class-validator GitHub stars
ow GitHub stars
reflect-metadata GitHub stars
typebox GitHub stars
myzod GitHub stars
morphic-ts GitHub stars
monocle-ts GitHub stars
ts.validator GitHub stars
tson-schema GitHub stars
json-type-validation GitHub stars
class-transformer-validator GitHub stars
typescript-schema GitHub stars
ts-brand GitHub stars
narrows GitHub stars
cleaners GitHub stars
Gubu GitHub stars
typescript-rtti GitHub stars
unknownutil GitHub stars
cast.ts GitHub stars
json-decoder GitHub stars
data-type-ts GitHub stars
ts-simple-type GitHub stars
assert-combinators GitHub stars
refute GitHub stars
arktype GitHub stars
Code Generation / External Tool Projects
Project Stars
ts-morph GitHub stars
typia GitHub stars
tsc-macro GitHub stars
typescript-json-schema GitHub stars
ts-json-schema-generator GitHub stars
typescript-is GitHub stars
tsnameof GitHub stars
ts-auto-guard GitHub stars
ts-validate-type GitHub stars
tsmirror GitHub stars
typeonly GitHub stars
ts-runtime GitHub stars
ts-di-transformer GitHub stars
typson GitHub stars
ts-type-checked GitHub stars
tst-reflect GitHub stars
ttype-safe GitHub stars
reflec-ts GitHub stars
ts-simple-type GitHub stars
ts-interface-builder GitHub stars
Adapter Projects
Project Stars
typeschema GitHub stars

The Problem

Dear TS team,

I love you. You do amazing work. You are gods among mortals. You have brought JavaScript from the darkness, and given it the warm light of strong typing. Look upon us, the cowering meek masses, and understand that we live in the muck and mire of a world where we are doomed to endlessly crawl on our bellies through the alleys of Github seeking the one true npm. We will forever wander in the dark, until we have a type reflection model.

Serialization and validation without a reflective type system just doesn't work in the real world without endless boilerplate, or shiver, bespoke code generation from a schema file. The best solutions I could find are io-ts, zod, etc. The ever growing list above. The most courageous of us even resort to babel, but only to face the consequences. Someone even wrote a new language extending TypeScript to work around this. We have to declare our types in a round about library-bespoke way that is foreign to the uninitiated, and the libraries aren't even able to support all the wonderful type magic you work so hard to provide.

This is a case, where we urge you to take a step back and holistically look at what TypeScript users have to do to in the majority of modern projects, and list them out in priority order. The decision of how to tackle serialization, and what actually has to be done to have TypeScript still work with it is at the top of the list. Even if you still don't want to support reflection, please write a detailed doc, and put it in the official TypeScript documentation that explains how TypeScript users should tackle this problem or what library you recommend, so we don't have endlessly reinvent the wheel.

There seems to be a conflict between the design goals of TypeScript that is blocking this for some reason. Type erasure is good! It means JavaScript projects can consume TypeScript projects without any knowledge of TypeScript. It's just emitted JavaScript. This does not mean you can't emit the type information in a consumable lookup table that's separate from the code. The lack of this type information means we use esoteric libraries which ultimately pollute the JavaScript with all the convoluted typing workarounds... soo... type erasure has defeated the purpose of type erasure. It's a second order effect, where the design goal defeats the design goal. :(

Side note, please don't solve this with decorators. A lot of us want to use interfaces. Decorators, like C# attributes are so coupling, and we can't add them to types from other libraries. A higher order function that's known to the compiler like: typescript.generateRuntimeType<T>() with options for discriminators etc. means it would even work with external libs. Something like F# Type Providers, or C# Source Generators would also be welcome.

Last thing. If you do this, I will send you cake. If it's in TypeScript 4.3, there will be ice-cream.

Love,
A humble disciple

ATTN: @ahejlsberg

Open Source Agenda is not affiliated with "Typescript Needs Types" Project. README Source: akutruff/typescript-needs-types
Stars
391
Open Issues
2
Last Commit
1 month ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating