The Craziest TypeScript Types Video You Will Ever See - The Pinnacle of Advanced Type Wizardry!

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ก.ย. 2024

ความคิดเห็น • 45

  • @Typed-Rocks
    @Typed-Rocks  18 วันที่ผ่านมา +3

    Just found an issue with the code. We need to use „false“ instead of „never“ in the „CorrectStart“ type because never extends all types. Thanks for pointing that out. Also we need to add the "(" in the AllowedStarts. Checkout my github repository for the newest code and feel free to send a pull request when you find other errors: github.com/typed-rocks/typescript/blob/main/calculator.ts
    The

  • @abdul-hameedmaree881
    @abdul-hameedmaree881 19 วันที่ผ่านมา +8

    finally, someone did a good programming video that is not useless or clickbait.
    Awesome work 🎉

    • @Typed-Rocks
      @Typed-Rocks  19 วันที่ผ่านมา

      Thank you. I try my best to fulfill whats on the thumbnail 😁

  • @TianYuanEX
    @TianYuanEX 19 วันที่ผ่านมา +6

    This is actually peak, great job dude!

    • @Typed-Rocks
      @Typed-Rocks  19 วันที่ผ่านมา

      Thank you, appreciate it 😁

  • @a.i.8480
    @a.i.8480 17 วันที่ผ่านมา +2

    I'm impressed. Next crazy thing is to create a type to validate a whole TypeScript syntax. Let's make a full circle!

    • @Typed-Rocks
      @Typed-Rocks  17 วันที่ผ่านมา

      That would be next level 😁

  • @balaclava351
    @balaclava351 17 วันที่ผ่านมา +1

    I feel like I've just leveled up my TypeScript skills. You're a great teacher. Thanks!

    • @Typed-Rocks
      @Typed-Rocks  17 วันที่ผ่านมา

      Many thanks. That is really kind of you. Glad you like my presentation style :)

  • @MrJettann
    @MrJettann 19 วันที่ผ่านมา +5

    That was nuts! Extremely unusable, but extremely enjoyable! Let's follow it by something real life usable!:)

    • @Typed-Rocks
      @Typed-Rocks  19 วันที่ผ่านมา

      I will. Thanks 🙏

  • @praktycznewskazowki6733
    @praktycznewskazowki6733 19 วันที่ผ่านมา

    It's so difficult, but so powerful, great!

  • @notkamui9749
    @notkamui9749 17 วันที่ผ่านมา +3

    This won't accept unary prefix operators (such as -, as in -1), which is fine.
    However, what's not fine is that it will also accept such expression: 3 3 + 2

    • @Typed-Rocks
      @Typed-Rocks  17 วันที่ผ่านมา

      Right, we would need to check for spaces between numbers. I will update my github later today

  • @IlkkaHarmanen
    @IlkkaHarmanen 18 วันที่ผ่านมา

    "Hope you learned something useful today". Not sure about the useful bit, but otherwise I did learn something 🤣

  • @The14Some1
    @The14Some1 วันที่ผ่านมา

    The parentheses check is overengineered. I don't think you should have the stack of parentheses, because in fact the only value you store is "(". And what you are actually checking is if the amount of opening parentheses equals to amount of closing.
    What you could do instead, is to recursively extract "()" from parentheses string while possible and then check whether the leftover is empty or not.

  • @tngerik14
    @tngerik14 18 วันที่ผ่านมา

    Mindblowing stuff again :)
    I noticed an issue: although operators weren't set as allowed starts (although minus should be as a sign of a number) the expression '/5+3' is valid but it clewarly shouldn't be the case.
    My solution was this:
    type CorrectStart =
    T extends ...
    ? First ...
    ? true
    : never
    : false // was 'never' before
    The last word was the only change. I don't know why this works but it does

    • @tngerik14
      @tngerik14 18 วันที่ผ่านมา

      it is hard for me to wrap my head around the decision, when to return a boolean or the type itself/never

    • @Typed-Rocks
      @Typed-Rocks  18 วันที่ผ่านมา

      You are right. We should not use „never“ because it extends everything. Just both never in CorrectStart with false. Thank you for pointing that out 🙏

    • @tngerik14
      @tngerik14 18 วันที่ผ่านมา

      @@Typed-Rocks but both never to false leads to expressions starting with "((" to be invalid

    • @Typed-Rocks
      @Typed-Rocks  18 วันที่ผ่านมา

      @@tngerik14 Yes, absolutely, I've updated the code on github. We need to also allow a "(" at the values of AllowedStarts: github.com/typed-rocks/typescript/blob/main/calculator.ts

  • @muchis
    @muchis 19 วันที่ผ่านมา +2

    my head 🤯

    • @Typed-Rocks
      @Typed-Rocks  19 วันที่ผ่านมา

      So was mine 😁

  • @mightyhelper8336
    @mightyhelper8336 19 วันที่ผ่านมา +1

    You basically have a mini compiler frontend.
    Now you gotta make it actually compute...
    Or make a piece of code that generates this based on a generic language grammar.
    This way, if you manage to get the typescript syntax working, you can run typescript from a string, at compile time...
    Thinking about this a bit more, if you add some sort of interface to that ts interpreter, you could produce some actual types at compile time as output of your inline ts code.
    But wait, what if you run this ts compile inside of itself...

    • @Typed-Rocks
      @Typed-Rocks  19 วันที่ผ่านมา

      The possibilities are endless 😁

  • @geeksven
    @geeksven 19 วันที่ผ่านมา +2

    You need help xD But awesome job :)

    • @Typed-Rocks
      @Typed-Rocks  19 วันที่ผ่านมา +1

      All is lost at this point :D. But glad you liked it.

    • @AK-vx4dy
      @AK-vx4dy 18 วันที่ผ่านมา

      Yes... like Big Mike said "Just stop it. Get some help."

  • @snatvb
    @snatvb 19 วันที่ผ่านมา

    how did you check what is the result of type? it's amazing!

    • @Typed-Rocks
      @Typed-Rocks  19 วันที่ผ่านมา

      You mean the //^? Its a plugin for IntelliJ called „WiTT“ I‘ve created. You can download it from The Jetbrains Marketplace for free.

  • @AK-vx4dy
    @AK-vx4dy 18 วันที่ผ่านมา

    I see one problem.... if i'm not wrong, error message will be as "clear" just like C++ template errors...maybe not as bad but still...

    • @Typed-Rocks
      @Typed-Rocks  18 วันที่ผ่านมา

      100%, I would not want that in production code

  • @AK-vx4dy
    @AK-vx4dy 18 วันที่ผ่านมา

    Are you sure this is still TypeScript ? Maybe Prolog or Haskell or Verilog ? ;) I will stay in safe machine code / assembly space.

    • @Typed-Rocks
      @Typed-Rocks  18 วันที่ผ่านมา +1

      Maybe we can program a Haskell compiler in types? 🥹

  • @weeb3277
    @weeb3277 17 วันที่ผ่านมา +2

    this gives me an error:
    -2+2

    • @Typed-Rocks
      @Typed-Rocks  17 วันที่ผ่านมา +1

      I will fix the code on GitHub 🙏

    • @weeb3277
      @weeb3277 14 ชั่วโมงที่ผ่านมา

      😎

  • @mamad-dev
    @mamad-dev 15 วันที่ผ่านมา +3

    jesus, even ai cant generate this

    • @Typed-Rocks
      @Typed-Rocks  15 วันที่ผ่านมา +2

      We should be glad. That means it can‘t create such unreadable code :P

    • @mamad-dev
      @mamad-dev 15 วันที่ผ่านมา +1

      @@Typed-Rocks im actually impressed by your abilities in writing types in typescript, good job man

    • @Typed-Rocks
      @Typed-Rocks  15 วันที่ผ่านมา +1

      @@mamad-dev thanks man, really appreciate it

  • @RutsuKun
    @RutsuKun 19 วันที่ผ่านมา

    Are we already entering an era in which we will take longer to write types than final code?

    • @Typed-Rocks
      @Typed-Rocks  19 วันที่ผ่านมา +3

      It‘s happening as we speak 🤘

  • @AK-vx4dy
    @AK-vx4dy 18 วันที่ผ่านมา

    Seeing all this magic i really don't understand this moaning of libraries authors that they have a problem with TypeScript and types... clearly just skill issue 🤣

    • @Typed-Rocks
      @Typed-Rocks  18 วันที่ผ่านมา +1

      Or maybe they want to keep their sanity 😁