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 ?
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)鈥攅ven 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.)
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.
@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 that sounds related to the work in #15473.
@aluanhaddad Thank you for reference.
You have a point. That PR will help protocol implementation.
Most helpful comment
Note that even if protocols land,
interfaceandprotocolwill remain different things andinterfacewill still be useful (e.g. for describing an extensible type which has a particular shape, and especially for type definitions)鈥攅ven 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.)