Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

In TrackByFn typedef, index parameter should be an int not a num #431

@chalin

Description

@chalin

Under Dart 1.24-dev, when compiling https://github.com/angular-examples/template-syntax using the dartdevc I get this errors:

[error] A value of type '(int, Hero) → int' can't be assigned to a variable of type 'TrackByFn(num, dynamic) → dynamic'. (package:template_syntax/app_component.template.dart, line 4013, col 35)

This is because the app declares the following function used as an argument to an ngFor trackBy:

int trackByHeroes(int index, Hero hero) => hero.id;

But Angular seems to expect the index to be a num; see lib/src/core/change_detection/differs/default_iterable_differ.dart#L10

typedef dynamic TrackByFn(num index, dynamic item);

Should index not just be an int? It seems to only ever be called with an index that is an int.

cc @kwalrath

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions