material-components / material-web

Material Design Web Components
https://material-web.dev
Apache License 2.0
9.2k stars 882 forks source link

ReferenceError: FormDataEvent is not defined #3733

Closed justinfagnani closed 12 months ago

justinfagnani commented 1 year ago

FormDataEvent isn't found. Is there a missing lib or an ambient declaration not being included?

/Users/justinfagnani/Projects/WebComponents/webcomponents.org/webcomponents.org/node_modules/@material/web/controller/form-controller.ts:80
  private formDataListener(event: FormDataEvent) {
                                  ^

ReferenceError: FormDataEvent is not defined
    at <anonymous> (/Users/justinfagnani/Projects/WebComponents/webcomponents.org/webcomponents.org/node_modules/@material/web/controller/form-controller.ts:80:35)
justinfagnani commented 1 year ago

Sorry, this isn't a compilation error, it's a runtime error in runtimes that don't have the FormDataEvent class.

A polyfill for that could be listed as a requirement, but it doesn't seem that useful since the class is only used as a value for runtime type metadata emitted by tsc:

In https://unpkg.com/browse/@material/web@0.1.0-alpha.0/controller/form-controller.js :

__decorate([
    bound,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [FormDataEvent]),
    __metadata("design:returntype", void 0)
], FormController.prototype, "formDataListener", null);```

I'm not sure why emitDecoratorMetadata is on but unless something very specific is requiring that at runtime, it's just causing bloat and this error could be avoided by setting emitDecoratorMetadata to false.