Earlier quoted context omitted.
> A minifier can't guarantee that such expressions won't be used, so it cannot optimize property accesses. Given TypeScript’s type system is unsound, neither could it even if it tried, right? I guess Flow could, but well, here we are.
What do you mean by unsound exactly. I'm asking because there's no accepted definition of what an unsound type system is. What I often see is that the word unsound is used to mean that a type system can accept types different to what has been declared, and in that case there's nothing unsound about ts since it won't allow you to do so.
Node.js adds experimental support for TypeScript
331–340 of 570 posts
Re: Node.js adds experimental support for TypeScript
#332Earlier quoted context omitted.
> A minifier can't guarantee that such expressions won't be used, so it cannot optimize property accesses. Given TypeScript’s type system is unsound, neither could it even if it tried, right? I guess Flow could, but well, here we are.
What do you mean by unsound exactly. I'm asking because there's no accepted definition of what an unsound type system is. What I often see is that the word unsound is used to mean that a type system can accept types different to what has been declared, and in that case there's nothing unsound about ts since it won't allow you to do so.
Consider this example (https://www.typescriptlang.org/play/?ssl=10&ssc=1&pln=1&pc=1...):
function messUpTheArray(arr: Array): void {
arr.push(3);
}
const strings: Array = ['foo', 'bar'];
messUpTheArray(strings);
const s: string = strings[2];
console.log(s.toLowerCase())
Could you explain how this isn't the type system accepting types "different to what has been declared"? Kinda looks like TypeScript is happy to type check this, despite `s` being a `number` at runtime.Re: Node.js adds experimental support for TypeScript
#333Re: Node.js adds experimental support for TypeScript
#334Earlier quoted context omitted.
Java has type inference. Also if a type alias is just a new name for a existing type, then you can always do something like class MyNewClass extends OldClass {}; (of course it's not just a new name, it's also a new class, but it's also still a OldClass, and you are out of luck if OldClass is final or sealed) Java also has interfaces, of course. And optional properties (using Optional) and strict null checks, when you…
> type inference very limited, for instance you must declare the type of a public method > alias as you point out it's not > Java also has interfaces, of course but you have to implement them explicitly > strict null checks, when you want that, you can use it if we start accepting static analysis tools then C has null checks as well I guess
so what's the difference except the name?
> if we start accepting static analysis tools
I'm not talking about static analysis. In today's Java you can write code that does not accept nulls, if you want to.
Re: Node.js adds experimental support for TypeScript
#335Re: Node.js adds experimental support for TypeScript
#336Earlier quoted context omitted.
Flow (by Facebook) used to be fairly significant in the JavaScript several years ago, but right now it's somewhat clear that TypeScript has won rather handily.
Flow tries to be sound and that makes it infinitely better than TS where the creators openly threw the idea of soundness out the window from the very beginning.
Both choices are reasonable ones to make. Flow has some really cool stuff, and works great for a lot of people.
There’s no denying, though, that there’s TS has done something right (even if you personally dislike it)
Re: Node.js adds experimental support for TypeScript
#337Earlier quoted context omitted.
> drastically different ways to approach types Exactly. > Partial Looking at that it's just what a default POJO (with nullable properties) already is, so I'd see no need to represent that in Java. Looks cool though and I like Typescript; my issue with it is that it needs transpiling to run. If it was a first-class citizen in an environment I would use it for my pet projects.
> it's just what a default POJO (with nullable properties) already is I think you missed the point. Partial is an example of a "mapped type", see the handbook for more explanation: https://www.typescriptlang.org/docs/handbook/2/mapped-types....
Re: Node.js adds experimental support for TypeScript
#338Eventually, node might allow JS to introspect those types. That would be a huge win. Right now in Python, great tools like pydantic exist because Python can introspect said types, and generate checks out of them. This mean you can define simple types, and get: - type checking - run time data check - api generation - api document generation Out of a single, standard notation. Right now in JS, things like zod have to d…
If JS ever adds type checking, I hope it doesn't choose Typescript. We need a type system that is actually sound and TS is intentionally unsound. We need a type system that doesn't allow bad coding practices like TS does. We need a type system that enforces program design that allows programs to be fast. We need a Hindley Milner type system. If you want a module to be typed, add a `"use type"`. This should disallow b…
Re: Node.js adds experimental support for TypeScript
#339Earlier quoted context omitted.
Looks very similar to Reason ML, another language that compiles to Js: https://reasonml.github.io/docs/en/getting-started
ReScript was an outgrowth of ReasonML and basically split the community killing both of them.
Re: Node.js adds experimental support for TypeScript
#340Earlier quoted context omitted.
You can have this now adding types with JSDoc and validating them with typescript without compiling, you get faster builds and code that works everywhere without magic or need to strip anything else than comments. The biggest pain point of using JSDoc at least for me was the import syntax, this has changed since Typescript 5.5, and it's now not an issue anymore.
[flagged]