Add types to TimelineSyncFunction and Timeline.timeSync; fixes #35509

Bug: https://github.com/dart-lang/sdk/issues/35509
Change-Id: I8bab1c1127d7a5021ff5698a4ae6be8c3730784e
Reviewed-on: https://dart-review.googlesource.com/c/92622
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
diff --git a/sdk/lib/developer/timeline.dart b/sdk/lib/developer/timeline.dart
index 4853f4a..b3075bf 100644
--- a/sdk/lib/developer/timeline.dart
+++ b/sdk/lib/developer/timeline.dart
@@ -8,7 +8,7 @@
     const bool.fromEnvironment("dart.developer.timeline", defaultValue: true);
 
 /// A typedef for the function argument to [Timeline.timeSync].
-typedef dynamic TimelineSyncFunction();
+typedef TimelineSyncFunction<T> = T Function();
 
 // TODO: This typedef is not used.
 typedef Future TimelineAsyncFunction();
@@ -154,7 +154,7 @@
 
   /// A utility method to time a synchronous [function]. Internally calls
   /// [function] bracketed by calls to [startSync] and [finishSync].
-  static dynamic timeSync(String name, TimelineSyncFunction function,
+  static T timeSync<T>(String name, TimelineSyncFunction<T> function,
       {Map arguments, Flow flow}) {
     startSync(name, arguments: arguments, flow: flow);
     try {