Earlier quoted context omitted.
That's a good point. I just realized that I am working around this problem by explicitly setting a `z.Schema ` type: [link redacted]. The reason was to retain JSDoc comments on the types, but I guess this was another positive side effect. In any case, I agree with you that there is room for improvement.
Ah ok. However, typescript is mostly smart enough to propagate comments [1] from zod schema properties to inferred types on its own. Thanks for maintaining kanel btw. We used to use this in a previous role alongside knex. It was very useful. [1] https://lorefnon.me/2022/06/25/generating-api-docs-for-zod-t...
TypeScript please give us reflection/runtime types
261–270 of 287 posts
Re: TypeScript please give us reflection/runtime types
#262Since it's not explicitly listed there, I feel I should shout out David Blass and his incredibly cool ArkType project[1]. It's typescript wizardry. He sometimes (used to?) streams himself working on twitch and it's a really comfy place to hang out.[2] [1] https://github.com/arktypeio/arktype [2] https://www.twitch.tv/arktypeio
Re: TypeScript please give us reflection/runtime types
#263Hey all, TypeScript PM here. I understand the desire here. Runtime type checking is often necessary for data validation, and we can see lots of libraries developed to help fill the gap here. But I think the fact that there are so many libraries with different design decisions is pretty indicative that this is not a solved problem with an obvious solution. We knew this going into the early design of TypeScript, and it…
Re: TypeScript please give us reflection/runtime types
#2641. A way to get a value that represents the type of any statically known type (i.e. known at compile time). 2. A way to compare two typereps for equality. 3. A way to convert between types if the typereps are equal.
This is basically the equivalent of the `Typeable` class in Haskell and PureScript (https://hackage.haskell.org/package/base/docs/Data-Typeable....). Both Haskell and PureScript erase types at runtime, so it is possible to do without adding a runtime to TypeScript as well.
Re: TypeScript please give us reflection/runtime types
#265Since it's not explicitly listed there, I feel I should shout out David Blass and his incredibly cool ArkType project[1]. It's typescript wizardry. He sometimes (used to?) streams himself working on twitch and it's a really comfy place to hang out.[2] [1] https://github.com/arktypeio/arktype [2] https://www.twitch.tv/arktypeio
How complete is arktype actually? The README says a lot of the syntax is yet to be developed, and don't even get me started on the horror of the docs site.
Right now a lot of work seems to be going into getting a 1.0 release out of the door (the current one is still marked alpha).
Re: TypeScript please give us reflection/runtime types
#266Earlier quoted context omitted.
I'm relatively new to programming and had a question about TypeScript's functionality. Is there any specific reason why TypeScript doesn't allow for the creation of custom and intricate data types? For example, I'm unable to define a number type within a specific range, or a string that adheres to a certain pattern (like a postal code). I'm imagining a language where I could define a custom data type with a regular f…
This is a feature some (experimental) programming languages have - look into dependent types. The long-and-short of it is that it adds a lot of power, but comes at an ergonomic cost - the more your types say about your code, the more the type checker needs to be able to understand and reason about your code, and you start to run up against some fundamental limits of computation unless you start making trade-offs: giv…
Re: TypeScript please give us reflection/runtime types
#267Earlier quoted context omitted.
The solution is to pile features onto typescript that were never intended to be there, the same way we have done with Javascript, HTML, CSS, and HTTP. None of these things are pure, and all of them have been ravaged by competing interests and committees who were all making financially driven decisions when writing the standards. It would be best to abandon javascript and typescript as backend languages. I don't mind…
I, on the other hand, would pick TS over .NET or Java any day. But I am sure you will conclude that it can only be because I am no good at my job.
Re: TypeScript please give us reflection/runtime types
#268Re: TypeScript please give us reflection/runtime types
#269Earlier quoted context omitted.
What's next? An official TypeScript UI framework, will it be Vue, React, Next.js or Svelte? An official TypeScript date library?
This is the curse of guest languages, after the initial adoption pain everyone wants idiomatic libraries and pretends the underlying platform doesn't exist. Until they hit a roadblock caused by a leaky abstraction, that proves them otherwise.
And I think that's actually the reason why it won the competition against Googles Dart. They even used Microsofts TypeScript for Angular instead of their own language Dart.
Re: TypeScript please give us reflection/runtime types
#270Earlier quoted context omitted.
There is currently no good way to automatically validate the object input to a typescript API. In the way that you can simply specify the class of a POST body to a spring boot controller or Asp.Net controller, every class in typescript requires you write the type information twice: once for the typescript compiler, and once again for the runtime deserializer, in the form of decorators. Having to write extra code to m…
My experience is the opposite of yours. With typescript I use an openapi spec to validate and generate types. For other entry points I use typebox to create validators and generate types. It requires a bit of work, but it adds a lot of capability even beyond basic deserialization. With c# I've seen openapi interface generators that don't validate properly, only basic deserialization. I've seen dto's that are deserial…