News for hackers. Stuff that matters.
Re:TypeScript 4.1 by munificent on Thursday November 19, 2020 @07:46PM (#25156213)
Stage 0: JavaScript without types is too hard to maintain.

Stage 1: Put types into JavaScript.

Stage 2: TypeScript types are not expressive enough.

Stage 3: Put JavaScript into types.

I'm looking forward to stage 4 where the expressions inside TypeScript type annotations get so complex and hard to maintain that someone creates TypeTypeScript that lets you put type annotations inside the code inside type annotations.

Re:TypeScript 4.1 by amw-zero on Thursday November 19, 2020 @08:48PM (#25156564)
Well, in all seriousness that’s basically what dependent types are.
Re:TypeScript 4.1 by quickthrower2 on Thursday November 19, 2020 @10:31PM (#25157083)
It will be like “there is an error compiling your compiler sir”
Re:TypeScript 4.1 by MaxBarraclough on Friday November 20, 2020 @04:37AM (#25158846)
Or even the language. On this point: type systems are hard to get right, we know that the Java type system is unsound, even ignoring its covariant array types.

https://news.ycombinator.com/item?id=13050491

Re:TypeScript 4.1 by peterkelly on Thursday November 19, 2020 @10:32PM (#25157084)
This is called dependent typing, and is supported by some languages such as Idris (https://www.idris-lang.org/)
Re:TypeScript 4.1 by jaequery on Thursday November 19, 2020 @08:12PM (#25156379)
And 10 years later, someone will eventually bring back dynamic typing and every one will go monkeys
Re:TypeScript 4.1 by cryptica on Friday November 20, 2020 @08:06AM (#25160065)
This is the feature of TypeScript that I'm most looking forward to. Default all variable and constant declarations to type 'any' so that TypeScript can look identical to JavaScript. Then we can remove the transpile step from our projects.
Re:TypeScript 4.1 by scotty79 on Friday November 20, 2020 @11:03AM (#25161679)
You can already do exactly that. Just put .js at the end of your filename.

Or set `noImplicitAny` to false if you want to retain some type checking.

Re:TypeScript 4.1 by cryptica on Friday November 20, 2020 @12:15PM (#25162512)
I need to use the '.ts' extension because my boss demands it. TypeScript needs a feature to allow me to fool my boss into thinking that I'm using TypeScript while actually using JavaScript.
Re:TypeScript 4.1 by smt88 on Friday November 20, 2020 @08:01AM (#25160015)
TypeScript has dynamic types. It's a superset of JavaScript, not a separate language.
Re:TypeScript 4.1 by recursive on Thursday November 19, 2020 @09:21PM (#25156742)
It's still there. `any`.
Re:TypeScript 4.1 by baq on Friday November 20, 2020 @04:26AM (#25158783)
but you don't have to type it now! it's literally a revolution in developer efficiency!

...and all the older folks just keep pointing at lisp and shaking their heads.

Re:TypeScript 4.1 by recursive on Friday November 20, 2020 @10:20AM (#25161258)
You don't have to type it in typescript either.

Just don't turn on the `noImplicitAny` compiler option. Yes, that's right. It's the default. https://www.typescriptlang.org/tsconfig#noImplicitAny

Shake away, lisp folks. If you can show me how to run lisp in a browser with tolerable performance and debugging, I might understand why you're shaking your heads.

Re:TypeScript 4.1 by trevyn on Saturday November 21, 2020 @03:01AM (#25168429)
I think the lints are on by default, though, so it'll compile but you still get warned.
Re:TypeScript 4.1 by cryptica on Friday November 20, 2020 @08:12AM (#25160117)
That is ingenious! That would get me excited about TypeScript! Dynamic typing, no cumbersome transpilation step, no source mapping, 100% backward compatibility with JavaScript. That would be a dream come true.

We need a way to go back to JS without hurting the egos of TS community. It will require a massive marketing innovation to achieve this.

Re:TypeScript 4.1 by recursive on Friday November 20, 2020 @10:14AM (#25161190)
As a member of "the TS community", I hereby authorize you to go back to JS. My ego remains un-damaged.
Re:TypeScript 4.1 by cryptica on Friday November 20, 2020 @12:07PM (#25162418)
Thanks but I already took matters into my own hands and quit my last company which forced me to use TypeScript for several years.

Can you tell all the companies to stop obsessing about TypeScript and to allow developers to use JavaScript too? That would be awesome because now it's almost impossible to find a JavaScript job.

I'd rather get social security and live under a bridge than go back to TS. That would be a more productive use of my time.

Re:TypeScript 4.1 by recursive on Friday November 20, 2020 @12:39PM (#25162795)
> Can you tell all the companies to stop obsessing about TypeScript and to allow developers to use JavaScript too?

I don't have that much influence. Most of those companies have come to their own conclusions.

At my company, the reason we wouldn't allow that is that it makes the codebase more difficult to approach for a new developer. Knowing the types accepted and returned is helpful for reading unfamiliar code.

Re:TypeScript 4.1 by CapsAdmin on Friday November 20, 2020 @09:27AM (#25160689)
As a toy project, I'm actually experimenting with this, but instead with Lua.

https://github.com/capsadmin/nattlua

You can see some examples in the readme.

To me it makes sense that the typesystem is basically lua rather than a mathematical ish looking language.

It could prove to be more difficult to work with but I guess I'll find out.

Re:TypeScript 4.1 by Reelin on Friday November 20, 2020 @12:54AM (#25157689)
> Put JavaScript into types.

It's not without precedent - Haskell has a Turing complete type system. (There's also Scala, Rust, and C++ templates which are all arguably Turing tarpits.)

Re:TypeScript 4.1 by smt88 on Friday November 20, 2020 @08:01AM (#25160023)
TypeScript also has a Turing-complete type system, if I remember correctly.
Re:TypeScript 4.1 by WorldMaker on Friday November 20, 2020 @05:49PM (#25166017)
The joke in the release notes here asking developers not to publish Fibonacci computations in the type system to npm is not entirely a joke.
Re:TypeScript 4.1 by trevyn on Thursday November 19, 2020 @07:49PM (#25156233)
So, generics?
Re:TypeScript 4.1 by tasogare on Thursday November 19, 2020 @08:56PM (#25156608)
At some point it would be better to just ditch Javascript, which was a mistake anyway, for Typescript or a (non Google controlled) language as default browser language.