☂️ [Extension type] Language feature docs #4177
Labels
a.language
Relates to the Dart language tour
e3-weeks
Complete in < 4 weeks of normal, not dedicated, work
fix.examples
Adds or changes example
meta.umbrella
Collects multiple related issues
p1-high
Major but not urgent concern: Resolve in months. Update each month.
st.triage.ltw
Indicates Lead Tech Writer has triaged
Milestone
Copied from #5446 and closed that issue to consolidate tracking
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>)
(<type> _)
used in JS interop -- not sure what to call it or if it has an application outside of JS interopImplements
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: