Live data from Hacker News

Making sense of TypeScript using set theory

blog.thoughtspile.tech

91–94 of 94 posts

Re: Making sense of TypeScript using set theory

#91
post #90
post #89

Earlier quoted context omitted.

So you are saying the implementation of the Typescript language are a subset of all JavaScript implementations? I guess that is true in a certain sense. But this does not contradict the fact that TypeScript as a language is a superset of JavaScript - rather it follows logically. (Although in reality the Typescript implementation is a preprocessor, intended to use together with a regular JavaScript engine.)

Kind of. The language gets confusing because we use subset and superset next to each other, but we put different meaning on them. {foo: number, bar: string} as type is a subset of both {foo: number} and {bar: string}. It requires it's members to have both properties. You can construct this type using intersection: type Foo = {foo: number} type Bar = {bar: string} type FooBar = foo & bar {foo: 1, bar: 'hello'} as obje…

> All JS programs are also TS programs, but not vice versa. There's more JS programs in the world than TS programs.

I think you are confusing terminology, because those two statements are contradictory.

Re: Making sense of TypeScript using set theory

#92
post #91
post #90

Earlier quoted context omitted.

Kind of. The language gets confusing because we use subset and superset next to each other, but we put different meaning on them. {foo: number, bar: string} as type is a subset of both {foo: number} and {bar: string}. It requires it's members to have both properties. You can construct this type using intersection: type Foo = {foo: number} type Bar = {bar: string} type FooBar = foo & bar {foo: 1, bar: 'hello'} as obje…

> All JS programs are also TS programs, but not vice versa. There's more JS programs in the world than TS programs. I think you are confusing terminology, because those two statements are contradictory.

You're absolutely right, last statement should be inverted. I think meant to say something else, but at this point I don't remember what it was.

Re: Making sense of TypeScript using set theory

#93
post #92
post #91

Earlier quoted context omitted.

> All JS programs are also TS programs, but not vice versa. There's more JS programs in the world than TS programs. I think you are confusing terminology, because those two statements are contradictory.

You're absolutely right, last statement should be inverted. I think meant to say something else, but at this point I don't remember what it was.

In any case, the TS spec is a superset of the JS spec, since it incorporates the JS spec. If you don't consider the JS spec as part of the TS spec then they are disjoint sets. But the TS spec cannot be a subset of the JS spec since that would mean it removed some parts of the JS spec, which is not the case.

Re: Making sense of TypeScript using set theory

#94
post #42
post #41

Earlier quoted context omitted.

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…

You are right, the statements are contradictory. It's strange to see how nobody questions marketing buzzwords from Microsoft.

What "marketing buzzwords" are you referring to?
Post reply on HN