Closed
Description
I like to be explicit about types everywhere and not rely on inference.
I wish I could do something like the following, where I use a typedef to avoid having to duplicate a record's type, without the typedef having to be far away from the one code block where I use it:
...
case 'create-new-triage-labels':
if (arguments.length != 1) {
print('Usage: dart run github_tools create-new-triage-labels');
exit(1);
}
typedef LabelDescription = ({String name, String color, String description});
final List<LabelDescription> newLabels = <LabelDescription>[];
for (final String team in teams.keys) {
if (team != 'ecosystem' && team != 'infra' && team != 'release' && team != 'google-testing' && team != 'news' && team != 'codelabs') {
newLabels.add((name: 'team-$team', description: 'Owned by ${teams[team]}', color: '198022'));
}
newLabels.add((name: 'triaged-$team', description: 'Triaged by ${teams[team]}', color: 'b8ccba'));
newLabels.add((name: 'fyi-$team', description: 'For the attention of ${teams[team]}', color: '29cc36'));
}
for (final LabelDescription label in newLabels) {
await engine.createLabel(label.name, label.color, label.description);
}
...