Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input event #6

Open
akoidan opened this issue Oct 16, 2019 · 2 comments
Open

Input event #6

akoidan opened this issue Oct 16, 2019 · 2 comments

Comments

@akoidan
Copy link

akoidan commented Oct 16, 2019

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
Copy link
Owner

ryanelian commented Oct 16, 2019

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
Copy link
Author

akoidan commented Oct 16, 2019

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

  • git clone https://github.com/akoidan/vue-webpack-typescript a; cd a
  • git checkout tspoly
  • yarn install
  • yarn run build
  • cat dist/main.js |grep InputEvent

p.s. It's so weird to see white scheme in VsCode 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants