Extension types doc planning #5446
Labels
a.language
Relates to the Dart language tour
dev.interop
Relates to use of native code as part of your Dart app
e3-weeks
Complete in < 4 weeks of normal, not dedicated, work
meta.umbrella
Collects multiple related issues
p1-high
Major but not urgent concern: Resolve in months. Update each month.
Edit: Please refer to #4177 for the new issue tracking this work. Thanks!
This issue outlines the plan for the new extension types language feature in 3.3.
Summary
Extension types are an abstraction that lets you write a new, static-only interface for an existing type. This could mean expanding functionality by declaring new members, or redefining the type's existing members, or enforcing discipline by choosing not to define certain members so that functionality can't be used for instances of the new type.
Extension types enable new JSInterop features, but enable other uses cases as well. This documentation will define their syntax, functionality, and use cases. The full description of JSInterop functionality will reside with the JSInterop documentation (#5438)
Evaluation
The Extension types page will go under the Language (tour) umbrella in the side nav, under the Classes & objects section, after the Extension methods page.
Outline: (some of this information may end up naturally settling in different parts of the page; this is the full topic coverage laid out sequentially)
Intro
Syntax / Functionality
class
this
have the same interaction as with classes(<type> <name>)
(don't actually say "primary constructor", proposal is not accepted yet)Implements
clauseimplements
external
because those are just getters / setters for external objects@redeclare
-- super-interface / sub-interface member declaration (so,implements
cases only)e = <ext type>(<representation object>)
e
is the "receiver" heree.<member>()
)Type stuff
is
/as
casting behaviorUse cases (code examples)
external
members as native JS methods if they have theJSObject
representation typeResources
@redeclare
annotation: [Extension type] Add a@redeclare
annotation sdk#53121The text was updated successfully, but these errors were encountered: