FYI, Dart won't care whether the function returns a Document or something else. For instance, the following program:

```dart
typedef int intFactory();

foo() => "aa";

main() {
  if (foo is intFactory) {
    print("here");
  }
}
```

will print `here`.