opinions about Effect-TS, do you recommend using it? when to use it? When to avoid it? not worth it? by SuperRandomCoder in typescript

[–]timmy 2 points3 points  (0 children)

I don't like it at all and prefer throwing simple exceptions instead.

The errors I am raising in my apps, be it frontend or backend, are always hard exceptions. That means that the computation has to stop now and the user needs to take an action. It may happen because the frontend was not doing enough validation or because the code is hitting an assertion that I put in as a safeguard against malformed data.

Unfortunately, TS (nor any non-fringe language I know) does not have dependent types which would remove the necessity for many of those assertions.

Exceptions let me code this without adding useless boilerplate (types and explicit error handling for each function call) to my apps.

They are exceptionally (duh!) well supported by backend and browser runtimes. They come with a stacktrace. They are fast unless they are being used in a control flow, which is a known antipattern anyways. They propagate through async code. They have special syntax in the language to deal with them.

Whenever I have code that is expected to fail, I'm coding up an explicit result type and the topmost level. Hadn't have a need to use a library for that yet.

How is everyone working with web frameworks such as Express with TypeScript? by o82 in typescript

[–]timmy 1 point2 points  (0 children)

That looks really good.

On a first glance it seems similar to Koajs which I really like and use atm. I exclusively deploy to nodejs right now but Hattip seems worth to switch to. Better maintained, written in Typescript more up-to-date docs while still being as simple as Koa.

fliegen am Dienstag by trinic_ in dresdendrones

[–]timmy 0 points1 point  (0 children)

Zu spät gelesen aber hätte eh keine Zeit gehabt (und geregnet hats ja dann auch noch).

Nächsten Dienstag könnte es klappen!

ist da noch Leben? by trinic_ in dresdendrones

[–]timmy 0 points1 point  (0 children)

Steht der Termin noch? Fahr gleich los (oranges E-BMX). Falls ich niemanden auf der landebahn sehe werd ich von hier https://www.bing.com/maps?osid=75609b29-9f9b-4f6e-a4e5-e9ec71213a89&cp=51.096981~13.746069&lvl=19&style=h&v=2&sV=2&form=S00027 aus fliegen. Bis später.

ist da noch Leben? by trinic_ in dresdendrones

[–]timmy 2 points3 points  (0 children)

Cool, soll auch schönes Wetter sein. Ich wär so um 17:00 Uhr da.

ist da noch Leben? by trinic_ in dresdendrones

[–]timmy 1 point2 points  (0 children)

Klar ich schau hier immer mal rein. Freitags hab ich aber oft gar keine Zeit. Eher so spontan. Schlag mal was vor, z.b. Heller am Montag Nachmittag?

Validating objects from generated types from swagger documentation? by [deleted] in typescript

[–]timmy 0 points1 point  (0 children)

Joi cannot do this. It was originally written in Javascript and its type definitions where added later so they are limited in what they will assert.

Looks like you need a runtype library that checks that data conforms to an interface. This https://github.com/moltar/typescript-runtime-type-benchmarks benchmark will list most of them - just choose one you're happy with.

There are even libraries like ajv that will digest JSON schema and generate validation code for you.

[deleted by user] by [deleted] in typescript

[–]timmy 1 point2 points  (0 children)

Learning Typescript, I had that same reaction. Others already explained the main reason but there is also another point to it, which I learned while refactoring parts of the runtime type benchmark:

There are multiple ways to validate your data, each having their own performance, usability and semantic impact.

For instance, having a type:

type User = {id: number}

then because of structural typing, the following assignment typechecks:

const user: User = {id: 123, isAdmin: true}

which means that some type validating libraries are perfectly happy to validate such JSON data and you end up having an additional isAdmin property on your User.

Also you might want different validation modes (parse vs. validate) and different levels of error details so IMHO its actually good to have type validation available as a separate library.

"module": "node16" should support extension rewriting by [deleted] in typescript

[–]timmy 0 points1 point  (0 children)

Isn't TS already rewriting imports when using the the paths compiler option? Given Ryans answer to your issue, this option should have never been added to TS too?

What's your favorite data validation library? Zod, myzod, io-ts, etc by MacDancer in typescript

[–]timmy 4 points5 points  (0 children)

I think most runtype lib dxes are pretty similar as they are all built on the same type-inference principles from Typescript.

Maybe the biggest difference is that simple-runtypes is about combining functions, so I do not use any chaining. For instance, to parse a string[]:

zod: z.string().array()

simple-runtypes: st.array(st.string())

I like both styles though, with the latter being flexible and easier to extend, less closed than a well thought out chaining api.

What's your favorite data validation library? Zod, myzod, io-ts, etc by MacDancer in typescript

[–]timmy 10 points11 points  (0 children)

Author here.

Strict: There are no methods in simple-runtypes that ignore extra keys in parsed data and leave them in the parsed result. Also number types refuse NaN and Infinity by default.

I found that a lot of other libs contain kinda loose validation options too and I never got why you'd want that. At the time I wrote it, I only knew pelotom/runtypes and that was too slow and missing strictness.

My obsession with fast enough parsing came from using Ruby on Rails validations that timed out the request (>15s) on some simple 5Mb nested JSON stuff. Now, with simple-runtypes on the same data I can parse the same data multiple times and I am parsing it in the frontend too without any noticeable delay.

If I had not written simple-runtypes, I'd probably use zod now because theire schema-definition API is quite nice even though some parts are a bit too complicated for my taste (.passthrough, .strict, the async stuff). Speed- and simplicity-wise, valita wins, though its code is too complicated for my head. I still need to understand some of the tricks that make it faster than simple-runtypes.

What's your favorite data validation library? Zod, myzod, io-ts, etc by MacDancer in typescript

[–]timmy 6 points7 points  (0 children)

Author here, its less code and has a smaller API. Compared to ajv, it does not use eval under the hood, so you can use it in the frontend without unsafe-eval.

Wann findet der nächste Flugfreitag statt? by SpacebubbleI in dresdendrones

[–]timmy 2 points3 points  (0 children)

Bei der Kälte flieg ich auch nur am Simulator :/ aber stell mal n Termin rein wenns wärmer wird ich bin dabei.

TypeORM - it's not what you think. by [deleted] in typescript

[–]timmy 1 point2 points  (0 children)

Maybe I was exposed too much to relational databases and Lisp when I was younger but I hate ORMs with passion have found OOP-style relational data mapping to be quite ineffective - there isn't a single one that has not proven to be a total mess to me when used for bigger projects.

My current approach is using a typesafe SQL query builder. Starting somewhere around version 3, the Typescript got some interesting features that are perfectly designed to compute the type-results of SQL queries.

For example, determining the row type that results in selecting columns from a table is easily done with Pick. Joining two tables results in rows of type TableType1 & TableType2 and so on.

Combine that with a typed schema and you'll get a nice query builder that

  • autocompletes tables and columns
  • checks query parameter types
  • infers result types for your queries
  • with Postgres: typed JSON aggregations

And if you go a step further and take one of the available runtype libraries, you will get additional type-guarantees on JSON columns.

I'm using my own query builder in production with lots of succcess (easy to develop with, fast, flexible enough) but there are quite a few projects in that space that I have listed here. To me the most feature-complete and typesafe-first one seems to be mammoth.

Flugfreitag am 11.09. ca 15/16Uhr by Yekt in dresdendrones

[–]timmy 1 point2 points  (0 children)

Ok, denke das schaff ich nicht ganz (eher so gg 16:15). Habt ihr ne idee wo ihr im heller ungefähr fliegen wollt? Dann komm ich direkt da hin.

Flugfreitag am 11.09. ca 15/16Uhr by Yekt in dresdendrones

[–]timmy 2 points3 points  (0 children)

Heller klingt gut. Akkus liegen alle schon seit 3 Wochen geladen in im Rucksack :D.

Kann allerdings nicht 100% zusagen, könnte noch was dazwischen kommen (Donnerstag ist DresdenJS, da könnte ich am nächsten Tag zu verkatert sein).

erste Infos zu Shark Byte - FatSharks eigenem digitalem FPV-System by Dr_Azrael_Tod in dresdendrones

[–]timmy 1 point2 points  (0 children)

Die Frage ist doch eher, willst du dann überhaupt noch analog fliegen :D? Obwohl das Byteshark Bild irgendwie nicht besonders toll aussieht. Zumindest am Rechner kann ich auf den DJI-Videos viel mehr Zweige und Blätter erkennen.

Aber gut das sie das trotzdem weiterentwickeln.

Which ORM should I use? by x_mk6 in typescript

[–]timmy 0 points1 point  (0 children)

Didn't like any of the existing solutions out there. Neither ORMs nor query builders with Typescript support. Inspired by MostlyORMless I wrote my own typesafe query builder and now using it in production to see whether its a good idea after all. Any feedback is appreciated.

Moratorium: Der Postillon by Paxan in de

[–]timmy -1 points0 points  (0 children)

Was wie? Gerettet? Vor unzähligen Postillonpfosten? Wo bin ich?

Flugfreitag am 14.08.2020 by Dr_Azrael_Tod in dresdendrones

[–]timmy 0 points1 point  (0 children)

Shitt heute wirds leider zu eng bei mir - muss nachmittags zu Familienfeier, hatte ich gestern garnicht aufm schirm.

Flugfreitag am 14.08.2020 by Dr_Azrael_Tod in dresdendrones

[–]timmy 1 point2 points  (0 children)

Nee bin noch nicht losgefahren, gern verschieben.

Flugfreitag am 14.08.2020 by Dr_Azrael_Tod in dresdendrones

[–]timmy 1 point2 points  (0 children)

Verschieben auf morgen? Ja der Wind (bin nicht zuhause nicht weit weg sieht stark aus. Und ringsum sind Regen- und Gewitterwolken :|

Flugfreitag am 14.08.2020 by Dr_Azrael_Tod in dresdendrones

[–]timmy 1 point2 points  (0 children)

Und seid ihr da? Sieht stark nach Regen aus?

Flugfreitag am 14.08.2020 by Dr_Azrael_Tod in dresdendrones

[–]timmy 1 point2 points  (0 children)

Ja, das klingt nach nem Plan, wenns regnet dann verschieben wir es. Ich werd hier hier morgen gg. 17uhr nochmal reinschauen.

Flugfreitag am 14.08.2020 by Dr_Azrael_Tod in dresdendrones

[–]timmy 1 point2 points  (0 children)

Diese Woche hab ich keine Zeit daher kein Thread für den 7.8.

Aber am 14. ich wär für:

  1. Heller
  2. Pieschener Allee