ts-sql

Languages and libraries

type-level programming demo

SHOW HN2020

Legend

ts-sql

A SQL database implemented purely in TypeScript type annotations

github.com

#typescript#sql#template literal types#type system

426points
191comments
#74of 3,028 in 2020
Top 3%of 2020 by points

How HN took it

MixedNo clear lean

19 positive, 26 neutral or asking, 1 mixed, 7 critical, out of 53 comments about the project. Thread score +0.18.

Idea: 17 for, 4 againstExecution: 2 for, 1 againstDesign: 0 for, 1 againstPerformance: 0 for, 1 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Impressive demonstration of TypeScript's type system and template literal types

    From 3 comments
    • The implementation isn't even that horrible. Ignoring the integer list. That workaround is still hillarious to me. Anyway, it seems both impressive that someone did this and that…
      Tarean on HN
    • This is a great demonstration of typescript's flexibility
      amitport on HN
    • This is terrible, I love it
      tobyhinloopen on HN
  • Useful for learning advanced TypeScript generics

    From 1 comment
    • Very interesting project. If you want a deep dive into TypeScript generics, this project's code is truly a must-read! This project really shows how powerful TypeScript has become…
      kamilafsar on HN

Objections

  • Parsing is fragile and lacks escaping and whitespace handling

    From 2 comments
    • it's a bit fragile only due to my laziness, it could be done properly if this were a serious project.
      phpnode on HN
    • same mechanism, just deal with more edge cases. e.g. whitespace isn't really trimmed correctly at the moment, it doesn't handle escaping quotes in strings and so on. I did think…
      phpnode on HN
  • Complex types hurt readability and maintainability

    From 1 comment
    • This shows how complex TypeSript has become. It may be fun to write complicated Type annotations such as this, but imagine having to read and maintain the code!
      flowerlad on HN
  • No practical real-world use cases

    From 1 comment
    • oh let's be clear there's no sensible real world use cases of this thing. it's a demonstration of what TS's type system can do
      phpnode on HN

Requests

  • Compute types from JavaScript functions rather than type-level code

    From 1 comment
    • That's pretty neat. What I really want is this: ``` function fn(query:string){ const stuff = // do some stuff with `query` variable return createType(stuff); } type MyType =…
      bartq on HN
  • Type-safe GraphQL queries without a code generation step

    From 1 comment
    • Great project, really expands what feels possible with the new improvements in TS 4.1. I wonder if this strategy could also be used to have strongly-typed GraphQL queries without…
      alangpierce on HN

Questions

  • Is it actually useful beyond being a demo?

    From 2 comments
    • Genuinely curious: is this actually useful or just a cool thing that is useful simply for the fact that it can be done?
      blitz_skull on HN
    • I'm viewing this on my phone, so maybe I'm missing something, but isn't this getting all of its typing information from you explicitly declaring a result set `as const`, and then…
      ralusek on HN
  • Why is this functionality in the language

    From 1 comment
    • I’m impressed/fascinated/horrified by the way it parses a string into a type with a variant of template literal syntax—though it looks like the parsing is probably very fragile.…
      chrismorgan on HN

Alternatives named

  • Zod and io-ts for runtime validation

    From 2 comments
  • myzod for runtime type validation

    From 1 comment

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/24615185)