|
3 | 3 | * See:
|
4 | 4 | * - https://github.com/microsoft/TypeScript/issues/55919 (generic constructors)
|
5 | 5 | * - https://github.com/microsoft/TypeScript/issues/40451 (generic constructors)
|
| 6 | + * |
| 7 | + * Note: Although the `FormStorageObserver` doesn't necessarily need a generic constructor, we can't |
| 8 | + * rely on the JS file just yet. The reason for this is that we're still dependent on `FormObserver.d.ts` |
| 9 | + * to provide type information that consumers can use (until _true_ generic constructors are _hopefully_ supported in |
| 10 | + * the future). And since the `FormObserver` name is being exposed in 2 ways (as an `interface` _and_ a `constructor`), |
| 11 | + * TypeScript gets confused when it sees something like `FormStorageObserver extends FormObserver`. (For clarity, |
| 12 | + * TypeScript's confusion happens for the `.d.ts` file that it generates. It has no problem with the JS file itself.) |
| 13 | + * So... We're stuck doing some extra TypeScript dancing for the `FormStorageObserver`. And sadly, that will more or |
| 14 | + * less be the case until generic constructors are figured out by the TypeScript team. At least, that's our |
| 15 | + * current understanding. |
| 16 | + * |
| 17 | + * Note that even if we remove generic constructors from the `FormStorageObserver` and the `FormValidityObserver`, |
| 18 | + * TypeScript will still get confused. This is because having a single name (`FormObserver`) for 2 entities is |
| 19 | + * still confusing for TypeScript when the `extends` keyword comes into play. |
| 20 | + * |
| 21 | + * So DON'T run off and try to replace this file with the pure JS file. That won't work because TypeScript gets confused |
| 22 | + * when it generates the `.d.ts` files from the JS files. If TypeScript ever allows JS files to be a source of types, |
| 23 | + * that might be another thing that could help us here besides TypeScript supporting generic constructors... |
6 | 24 | */
|
7 | 25 | import type FormObserver from "./FormObserver.js";
|
8 | 26 | import type { EventType, OneOrMany } from "./types.d.ts";
|
|
0 commit comments