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

Question: TypeScript and proposal-first-class-protocols #18814

Open
brn opened this Issue Sep 28, 2017 · 5 comments

Comments

Projects
None yet
5 participants
@brn

brn commented Sep 28, 2017

Now proposal-first-class-protocols become stage-1.
TypeScript team track and collaborate this proposal?
This proposal looks like conflict with typescript interface implementation.

I think It's more intuitive to replace interface to protocol in future.
Yes I know this proposal is now stage-1, but I want to know TypeScript-Team how think of about this proposals ?

@chriskrycho

This comment has been minimized.

Show comment
Hide comment
@chriskrycho

chriskrycho Sep 29, 2017

Note that even if protocols land, interface and protocol will remain different things and interface will still be useful (e.g. for describing an extensible type which has a particular shape, and especially for type definitions)—even if some of the scenarios to which interfaces are currently put will be expressible via protocols.

(To be clear: I say this as someone who couldn't possibly be more excited about protocols. I want them yesterday.)

chriskrycho commented Sep 29, 2017

Note that even if protocols land, interface and protocol will remain different things and interface will still be useful (e.g. for describing an extensible type which has a particular shape, and especially for type definitions)—even if some of the scenarios to which interfaces are currently put will be expressible via protocols.

(To be clear: I say this as someone who couldn't possibly be more excited about protocols. I want them yesterday.)

@kitsonk

This comment has been minimized.

Show comment
Hide comment
@kitsonk

kitsonk Sep 29, 2017

Contributor

Yes, I think like classes imply interfaces (two actually), protocol will also imply a specific interface and doesn't supplant interface or type. If adopted, it maybe real world code would use less interface, but as noted, protocol will be a concrete, immutable type once declared, which is contrary to the open ended nature of interface.

Contributor

kitsonk commented Sep 29, 2017

Yes, I think like classes imply interfaces (two actually), protocol will also imply a specific interface and doesn't supplant interface or type. If adopted, it maybe real world code would use less interface, but as noted, protocol will be a concrete, immutable type once declared, which is contrary to the open ended nature of interface.

@brn

This comment has been minimized.

Show comment
Hide comment
@brn

brn Sep 30, 2017

@chriskrycho @kitsonk
Thank you for your views, and I misunderstood about this proposals.
I see detail of that proposal one more time, It's not a simple protocol, it's symbol collections that has implementations.
So it's not become interface, and my view of interface and protocol is not suitable to this proposals.
But, If protocol has landed, protocol typed as like Protocol ?

protocol Foo {
  symbol_1,
  symbol_2,
  defaultImpl() { return 1; }
}
// Foo = Protocol<{
//  symbol_1: symbol,
//  symbol_2: symbol,
//  defaultImpl(): number;
// }>

brn commented Sep 30, 2017

@chriskrycho @kitsonk
Thank you for your views, and I misunderstood about this proposals.
I see detail of that proposal one more time, It's not a simple protocol, it's symbol collections that has implementations.
So it's not become interface, and my view of interface and protocol is not suitable to this proposals.
But, If protocol has landed, protocol typed as like Protocol ?

protocol Foo {
  symbol_1,
  symbol_2,
  defaultImpl() { return 1; }
}
// Foo = Protocol<{
//  symbol_1: symbol,
//  symbol_2: symbol,
//  defaultImpl(): number;
// }>
@aluanhaddad

This comment has been minimized.

Show comment
Hide comment
@aluanhaddad

aluanhaddad Oct 4, 2017

Contributor

@brn that sounds related to the work in #15473.

Contributor

aluanhaddad commented Oct 4, 2017

@brn that sounds related to the work in #15473.

@brn

This comment has been minimized.

Show comment
Hide comment
@brn

brn Oct 5, 2017

@aluanhaddad Thank you for reference.
You have a point. That PR will help protocol implementation.

brn commented Oct 5, 2017

@aluanhaddad Thank you for reference.
You have a point. That PR will help protocol implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment