Skip to content

typedef for simple type aliases #2626

Closed
@rakudrama

Description

@rakudrama

In the dom library there are several types which are sum (union) types.

IDBKey and SerializedScriptValue are two examples - both include numbers, strings and JavaScript arrays (Lists) among other things, and neither includes functions or arbitrary user defined types.

We are forced to use Dynamic for these types.
If typedef could do a simple renaming we could generate more readable interfaces.

e.g.

interface IDBFactory {
   int cmp(Dynamic first, Dynamic second);
}

could become

/** Documentation about IDBKey in one place. */
typedef IDBKey = Dynamic;

interface IDBFactory {
   int cmp(IDBKey first, IDBKey second);   // Tools can navigate to the definition.
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).core-atype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions