3 ms·
The invisible keyboard of the market... guided by millions of dollars from Microsoft, I assume. > rather than an absolute fact that every type system must not
by ragnese 5y ago
The invisible keyboard of the market... guided by millions of dollars from Microsoft, I assume.
> rather than an absolute fact that every type system must not have any holes and those that do are worthless.
Also, don't straw man me, please.
- jakear 5y ago> So even a basic object field is broken in TypeScript's type system. What the hell are we supposed to do with this? > So a hole exists in TypeScript's type system. What the hell are we supposed to do with this? > So a hole exists in TypeScript's type system. How can this be useful? > A hole exists in TypeScript's type system, therefore it is not useful. > Every type system must not have any holes and those that do are worthless. Where's the straw? Regardless, the issue you pose is solved via generics, which would be the appropriate TS way to model this: https://www.typescriptlang.org/play?#code/MYGwhgzhAECCB2BLAtmE0DeBfAsAKFEhgGEwAXaAUwA8zL4ATGBFNTfaT6ZSgewHcAFAEoAXNABuvRA3Z4uC6MF7wIvEJQB0IXgHNBAIh4CDwjl1x5LhKNAAieqrXpM4SVOgznOAIzAAnAGsRcSkZOUUuZVV1LR19Az8g029oS0t8RHg6fwAzMGBKaAAJSAAFSjIAHgqKAF43VhAAPgiuAAdK8Vr8DLwsnPzCksgHXTbOTrJxMd78fFyAV3hgMkQVbjAkdsXwOlqayoAVAE9O5sFecVKIA9rT8+EJ6F5NKegG+Ep+aFIyETmeHw0QgFCuIwgYw+zym4i+PzGAKs8zwqG2u3IlFqlzMQLwrymmiSwSeAHpSUpeMh2ogNP5oIgYJ08pRViATtAABZgdrtE4AQiAA https://www.typescriptlang.org/play?#code/MYGwhgzhAECCB2BLAt... Similar constructs would solve your proposed Array issues too: https://www.typescriptlang.org/play?#code/MYGwhgzhAECCB2BLAtmE0DeBfAsAKFEhgGEwAXaAUwA8zL4ATGBFNTfaT6ZSgewHcAFAEoAXNABuvRA3Z4uC6MF7wIvEJQB0IXgHNBAIh4CDwjl1x5LhKNAAieqrXpM4SVOgznOAIzAAnAGsRcSkZOUUuZVV1LR19Az8g029oS0t8RHg6fwAzMGBKaAAJSAAFSjIAHgqyABUATwAHIoBeN1YQAD4IrhaycVrGlvwMvCyc-MKSyAddXs5+8TnR-HxcgFd4YDJEFWgwBgZSarqnOkZmdzQuwQD-cTqAbQBdYQWD-39NJo2IAAtBPBKPxoCcRGYrEA https://www.typescriptlang.org/play?#code/MYGwhgzhAECCB2BLAt... TS is explicitly designed to be easy to apply to existing codebases without terribly much work. This means it must allow unsound code in some cases. However, given it also provides mechanisms to make the code sound, I do not see why this must be a dealbreaker to you. I think if you took the time to learn it you'd find the type system is actually quite powerful. (Disclaimer work at MSFT on their TS editor)
- ragnese 5y ago> Where's the straw? Seriously? The very first transformation you did was a straw man. There are two concepts here. Do you understand that two things can have different importance? Do you also understand that some numbers can be larger than others? For example, 10 > 1. So, "basic object field sub-types" is a pretty damn big error. Furthermore, I didn't say that this one issue made it worthless. I do think TypeScript is nearly worthless, but if this issue were the single issue with TypeScript, I might not say it's worthless. However, we have this issue, which is a big deal, and we have MORE than one of these type issues. So, the statement "every type system must not have any holes and those that do are worthless" is not even what I think at all. A small, niche, edge case of a type hole would not make a language as shitty as TypeScript, and therefore would not qualify as a worthless type system, automatically. No, it's the fact that TypeScript's type system has MANY (>1) type soundness/correct issues, and some of them are quite serious and fundamental. Using generics to "fix" the problem is a work around. It does not somehow make TypeScript's compiler correct. The fact is that the type system is broken/incorrect. There should be no need to use generics, and generics aren't somehow more correct in a type-theory sense. > I do not see why this must be a dealbreaker to you. You don't have to. But, I've had to research strange, inconsistent, incorrect behavior in TypeScript way too many times in the last few months. This is a bad language where a signficant amount of the type system is only giving a false sense of security/correctness. > I think if you took the time to learn it you'd find the type system is actually quite powerful. I've spent the last year learning WAY more about TypeScript's type system than I should need to. It isn't powerful at all if it's incorrect. Readonly types don't work, sub-type relationships don't work, generics sometimes don't work right/expectedly- where's the "power" in that?
- jakear 5y agoWell we both know there are only two types of languages, those that no one uses and those that people waste their time bitching about online. Glad to see TS is in the second category or else my day job would be useless :) That ad-homonyms do a good job of convincing me this isn’t a thread worth continuing. I wish you well in finding a powerful, complete, and consistent type system. I’m sure you’ll succeed if you try hard enough.