-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Design Meeting Notes, 6/21/2019 #32158
Comments
Is TS team going to implement optional chaining soon? (Maybe here is the wrong place to ask, but related issues have been locked :-) |
Well? You may... what? Don't leave us hanging here! 😄 @hax Optional chaining is Stage 2. TS typically doesn't implement proposed syntax until it hits Stage 3. |
Ugh, it's been a week but I assume it's probably just "revisit if we come up with other ideas." @andrewbranch? |
Actually, I thought the trailing "We may" was very Yoda of you.
I'm wondering for the sake of performance, whether it is useful to implement some At least then we might avoid performance issues and the programmer can see the underlying problem rather than a huge jumble of type combinations. |
It's possible, but it could lead to a lot of unexpected results with behavior that's hard to predict. Also, we often don't know that an operation will cause the creation of many types until you perform the operation itself. |
Excess property checking in object literals is a big contributor to this misconception, I’ve found. You would think the existence of intersection types (implying that overlap is possible) would clue people in, but alas... |
To expand on the above point re: closed types, I think the error message for the excess property check is misleading: interface FooBar {
foo: string;
bar: string;
}
let x: FooBar = {
foo: "pig",
bar: "cow",
baz: "ape", // error here
};
let tmp = {
foo: "pig",
bar: "cow",
baz: "ape",
}
let y: FooBar = tmp; // this is fine The error message for the assignment to
"Not assignable" sounds like a blanket statement, but clearly it is assignable, since assigning the exact same type through |
@fatcerberus in a technical sense, the error message is correct - the fresh type We could perhaps say something like
|
I would probably just say |
Sounds right to me 😄 Or possibly it was referring to what I posted in the issue?
|
@DanielRosenwasser Can you point me to discussions on this topic? My intuition would be that an optional call feature would test for callability, not nullability. But I'd love to be convinced otherwise. FYI CoffeeScript's optional call feature tests for callability. |
If optional call tests for callability, then based on the semantics of optional property access, you'd be propagating out In my opinion it makes the most sense to keep optional call consistent with optional property access in that they both only propagate |
Optional Chaining is Stage 3 now. |
@ppjjzz you was faster than me :) Here is the reference : https://github.com/tc39/proposal-optional-chaining |
It is not necessarily a good thing for TS. I don't mind TS to leave it alone (and break the "superset of ecmascript" promise). On the other hand, I'd be very upset if it were introduced in a lousy way. I'm not saying |
As you said, TS is a superset of JavaScript, it does not have to miss futur JS features. |
I respect that. However don't you think the PL guys should consider more than 'people are not forced to use it'? Isn't any feature like that? Here's a simple example: interface Something{
p1: Other
}
interface Other {
p2: string
}
let s: Something = ...
// are you going to let me write this?
// Either way, you are breaking something: the typing or the superset thing
s.p1? .p2? I'd believe the reality would be much more complicated, as this note says. |
@noru As I understand, TS should not allow you write interface Something{
p1?: Other
}
// or
interface Something{
p1: Other | null
}
// or
interface Something{
p1: Other | null | undefined
} |
Yeah I'd like to see that too. But therefore TS goes separate way with js and drop the runtime null-safe guarantee that js provides. |
I'm not sure I understand what you mean. Do you mean |
Again, I agree. But I don't see means to prevent such abuse. That's why I said I don't mind not having it in TS when types already solved 80% of my problems. I think the question is, how to enable full support of |
TypeScript could give tips for such abuse I believe. @noru |
Optional chaining is going to be great, and I look forward to seeing in TypeScript. It will simplify a ton of the code I write in a team every day. |
Definitely. Is it fair to ask whether it is reasonable for us to expect this in 3.6? Or is that too soon? |
Too soon. We cut the 3.6 beta 4 weeks ago, and the RC is in the next few days. |
Optional chaining update and feedback
https://github.com/tc39/proposal-optional-chaining/
tc39/proposal-optional-chaining#59
Issues with narrowing unions by union types
#31156
#31206
string | number
to"hello" | number
.Cat & Mortgage
seems unlikely, but it's indistinguishable fromMixinA & MixinB
.hasType
exhibits some issues here, and the new behavior catches this.The text was updated successfully, but these errors were encountered: