| Here are 3 statements that were made in this thread: - typescript is a superset of javascript - superset of objects can only have the same or fewer properties - Typescript contains all the rules of Javascript, and then adds some more Do you see where the confusion is coming from? > that also means the language specification itself is a strict superset of Javascript This is where I disagree. TS as a language has more properties than JS, but less rules. I.e. you can create Javascript language out of Typescript by adding more rules (constraints). But TS as a spec has more rules than JS spec. TS as a language is a superset of JS language. TS as a spec is a rough subset of JS spec. |
For types, just draw the Venn diagrams:
- The set of objects of Type A is entirely within the set of objects of Subtype of A. Subtype of A is the superset.
- the set of things that are Dogs (class or real world) is entirely within the set of things that are Animals.
- the set of things that are Javascript programs is entirely within the set of things that are Typescript programs.