ryanelian / ts-polyfill

Runtime polyfills for TypeScript libs, powered by core-js! :battery: :nut_and_bolt:
Other
139 stars 7 forks source link

Input event #6

Open akoidan opened 5 years ago

akoidan commented 5 years ago

Prelude: I (and many other developers) rely on this package + target es5 in tsconfig.json that everything would work on ie11, edge 15 and etc, while recklessly developing in Chrome.

The thing that I found out, experimentalDecorators generated InputEvent to the resulting js file. And it just crashed on production in Edge 15, despite I didn't even use the ReflectMetadata package. I blindly did what guide in other libs tell, enabling magic property in tsconfig (experimentalDecorators). I'm telling all of these because that what other devs might face.

Yeah, of course, that happened by my fault because I wrote code, not even expecting that typing could break anything:

class A {
  a(b: InputEvent) {
  }
}

What I propose is to have something like these, to reduce those kinds of risk:


if (!window.InputEvent) {
  console.error('InputEvent is not supported for Edge/IE, stubbing it with mock');
  window.InputEvent = (): void => {};
}
``
ryanelian commented 5 years ago

Hi, thanks for reporting an issue.

Is this something about the DOM library?

https://github.com/ryanelian/ts-polyfill/blob/master/official-lib-declarations/lib.dom.d.ts#L9766-L9770

Unfortunately, my TypeScript lib polyfills do not cover DOM libraries (https://github.com/ryanelian/ts-polyfill/tree/master/src) (for obvious reason: because core-js itself does not ship with DOM polyfills...), which means this issue falls outside the scope of this project.

That said, I'm willing to help you out with this issue. I'm trying to understand what you meant by experimentalDecorators generated InputEvent to the resulting js file because an empty Vue + TypeScript project compiled and bundled (with instapack) has no InputEvent keyword in the resulting JS:

image

akoidan commented 5 years ago

@ryanelian , could you please check vue-webpack-typescript repo. Please do the following

p.s. It's so weird to see white scheme in VsCode :+1: