News for hackers. Stuff that matters.
Re:What the heck are reverse mapped types? by lupire on Saturday August 17, 2024 @07:13PM (#41278805)
Brendan Eich's bosses would be so proud that after 30 years JavaScript has finally become a true Java script.

What are "reverse mapped types" called in regular computer science type theory?

Re:What the heck are reverse mapped types? by ivanjermakov on Saturday August 17, 2024 @09:37PM (#41279474)
Some context on the term:

> This is the lingo used in the compiler's source code, in the PRs and in the issues on GitHub.

> When you have to infer the T from a MappedType<T>, you are inverting the action of the MappedType. There is a dedicated part in the compiler for doing that.

Source: https://www.reddit.com/r/typescript/comments/1elj65m/comment...

Re:What the heck are reverse mapped types? by zarzavat on Sunday August 18, 2024 @03:57AM (#41280872)
TypeScript has a very different set of axiomatic operations than conventional type theory.

It incorporates concepts from set theory, you have unions T|U, intersections T&U, comprehensions { [T in U]: e(T) }, conditionals (T extends U ? A : B ), pattern matching (infer T), and the typeof operator is like a poor man’s dependent typing.

While you could certainly express all of these concepts in a language with dependent types, you can’t emulate the inference rules (the subject of TFA), so it can be said that TypeScript’s type theory is unique.

Re:What the heck are reverse mapped types? by lifthrasiir on Sunday August 18, 2024 @04:11AM (#41280923)
An inverse function.

While technically used like types, TypeScript "types" are really compile-time values that happen to be also usable for constraining usual run-time values like types. These compile-time values themselves do not have much types, so you can easily get errors from compile-time evaluations (which is different from compile-time type errors!). Likewise, most TypeScript type-level constructs are really long-winded methods to do the compile-time computation and have no straightforward equivalents in type systems that do guarantee the soundness and coherence (which have specific definitions).

Re:What the heck are reverse mapped types? by Kinrany on Monday August 19, 2024 @06:38AM (#41289733)
Since there's no previous stage where compile-time expressions could be type checked, the best they can have is strong dynamic typing, no?
Re:What the heck are reverse mapped types? by lifthrasiir on Monday August 19, 2024 @10:32AM (#41291388)
Not quite, because the previous stage can be dynamically generated as needed.