-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update question about types #1
base: main
Are you sure you want to change the base?
Conversation
That’s not a type system, though. |
"Parsing type signatures, even just to throw them away when the console is closed" (which is currently included in this answer) is not a type system either |
Totally agree. That's why the language won't ever have a type system - it just might have no-op type syntax space. |
I support either merging this PR or deleting the question. It is important that this FAQ doesn’t take sides in an ongoing debate. I agree with the new answer and disagree with the old one. If Jordan disagrees with the new one, I suppose deletion might be the way to go. I really hope we can come up with a neutral, agreeable way to characterize situations like this, though, since it makes the FAQ more useful. |
I don’t disagree with the PR, except that “no” remains the correct answer. |
Would adding "No." at the beginning of the sentence satisfy both? i.e. JS is not getting a type system, but there is the types annotations proposal. |
I think "No" leaves things confusing. Let's just leave this question out of the initial pass of the FAQ, and then we can work on adding text on this topic later. |
That's also fine, but I'm not sure why a correct answer with elaboration after it would be confusing. |
I like the wording @nicolo-ribaudo suggests above (with the leading "No"). I'm not sure how that leaves things confusing, but maybe it would help to make reference to the proposal in that first sentence?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like it as much as the original answer, but I have no problem with this.
may be pedantic, but JS does have a type system. should the question be something more along the lines of "will JS ever support static|strong typing"? |
@ctcpip Using that definition of a type system, there is no language (with more than one term) that doesn't "have a type system", making it meaningless. Let's not go down that rabbit hole. I support merging this PR as-is. |
@michaelficarra either of the suggestions from Jordan or myself seem like improvements to me; I don't think there's any rabbit hole to go down |
That would make more sense for a question like:
Which is actually a common question when people first learn about TypeScript as they read the phrase "TypeScript is a superset of JavaScript." I'd probably include wording like that. "While TypeScript is a superset of JavaScript, ..." and then explain the issues with that direction. (The Type Annotations FAQ has a few of them). I'd then add the second question:
This answer would then explain specifically why implementing "types that would help the engine" will not be included. As someone that's followed this discussion for decades, it generally boils down to:
This might be biased on my part as I maintain a long-term proposal on this topic, but I've been content with those kind of answers. There's probably more that can be included, but simply showing it's not viable for the present future is sufficient. |
@sirisian that would be incorrect, as in no way is TS a superset of JS. |
... TS is definitely a superset of JS? Every syntactically valid JS program is a syntactically valid TS program. "TS programs with no type errors" is not a superset of JS programs, but that's a different claim. |
He might have meant my link was broken. The text was right, but I linked to subset by accident. Meant to link to: https://en.wikipedia.org/wiki/TypeScript which was where that quote is from. |
let a = b < c > (d) Has completely different parsing and runtime semantics in JS and TS |
Sorry, yes, modulo the edge case with generics. I didn't think that's what @ljharb meant, but maybe? |
Yes, that’s what i meant - that edge case means it’s not a syntactic superset. |
OK, well, I think describing it as "almost" a syntactic superset would convey the relevant information equally well, if we wanted to go down that route. |
I don’t want to go down that route; i think the current state of the PR is ideal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. @nicolo-ribaudo @littledan does this work for you, or do you want the qualification I suggested above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the additional text bakkot
suggested, but good as is too.
I continue to think that starting the answer with "No" is confusing. I also disagree with the implication in the first sentence: the reason that a type system would be inferior is because we're not capable of making the sorts of evolving ad-hoc decisions that TS is, not because of engines, though it is true that the types wouldn't be useful for engines. |
Co-authored-by: Nicolò Ribaudo <[email protected]>
Co-authored-by: Jordan Harband <[email protected]>
66f1d5b
to
8d4add8
Compare
@littledan Do you have a concrete suggestion we could move forward with, then? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I continue to think that starting the answer with "No" is confusing.
I agree.
|
||
[Disclaimer: FAQ answers are not endorsed by TC39][] | ||
|
||
No. Types that help the developer (such as those in TypeScript) are not the same types that would help the engine, so a built-in type-checking experience will always provide inferior guarantees compared to what the JavaScript ecosystem is used to. The [type annotations](https://github.com/tc39/proposal-type-annotations) proposal is exploring parsing types with no runtime type-checking, which would be left to other tools. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Types that help the developer (such as those in TypeScript) are not the same types that would help the engine, so a built-in type-checking experience will always provide inferior guarantees compared to what the JavaScript ecosystem is used to. The [type annotations](https://github.com/tc39/proposal-type-annotations) proposal is exploring parsing types with no runtime type-checking, which would be left to other tools. | |
Not a _full_ type system. Types that help the developer (such as those in TypeScript) are not the same types that would help the engine, so a built-in type-checking experience will always provide inferior guarantees compared to what the TypeScript ecosystem is used to. The [type annotations](https://github.com/tc39/proposal-type-annotations) proposal is exploring parsing types without enforcing them, leaving other tools to perform static and/or runtime checking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WFM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be consistent with the question, suggestion:
- _full_ type system
+ _full_ static type system
also can we generalize the language around statically typed supersets (Iinb4 'TS is not a superset') so we don't appear to be favoring any particular one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's "favoring any particular one" to use TypeScript as an example of what developers expect from a type system. Generalising the language would just make it less clear to the kind of reader we're targeting here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i completely agree with you on the first point, but it could give people the wrong impression. I think this is one reason why the annotations proposal uses language like "TypeScript, Flow, and other static typing supersets of JavaScript".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More importantly, @littledan what do you think about the suggested change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not correct - it won't have any kind of static type system. That you can achieve one with external tools doesn't change that JavaScript will never have a static type system.
In other words, "No", full stop, is the only correct answer to this question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, yeah, you could argue Not a _full_ type system
implies it could get some sort of static type system. and that's not what type annotations would be introducing
The committee is actively exploring "parsing types to just throw them away", so saying that it will never happen is misleading.