PolymerElements / paper-input

A Material Design text field
https://www.webcomponents.org/element/PolymerElements/paper-input
130 stars 162 forks source link

TypeScript error with interface PaperInputElement #685

Closed erwinhalik closed 5 years ago

erwinhalik commented 5 years ago

Description

When using paper-input v3.0.1 with typescript the typescript transpiler shows the error below.

Expected outcome

no output

Actual outcome

node_modules/@polymer/paper-input/paper-input.d.ts:75:11 - error TS2320: Interface 'PaperInputElement' cannot simultaneously extend types 'PaperInputBehavior' and 'HTMLElement'.
  Named property 'autocapitalize' of types 'PaperInputBehavior' and 'HTMLElement' are not identical.

75 interface PaperInputElement extends PaperInputBehavior, IronFormElementBehavior, LegacyElementMixin, HTMLElement {

node_modules/@polymer/paper-input/paper-textarea.d.ts:37:11 - error TS2320: Interface 'PaperTextareaElement' cannot simultaneously extend types 'PaperInputBehavior' and 'HTMLElement'.
  Named property 'autocapitalize' of types 'PaperInputBehavior' and 'HTMLElement' are not identical.

37 interface PaperTextareaElement extends PaperInputBehavior, IronFormElementBehavior, LegacyElementMixin, HTMLElement {

Steps to reproduce

  1. add paper-input to project npm i --save @polymer/paper-input
  2. add import to component: import '@polymer/paper-input/paper-input';
  3. run typescript transpiler tsc
yv989c commented 5 years ago

I'm having the same issue, and it seems that @rictic already worked on a fix: https://github.com/PolymerElements/paper-input/pull/681

The fix haven't been merged due a failed CI test :-(

What I'm doing as a temporary solution is editing my \node_modules\@polymer\paper-input\paper-input-behavior.d.ts file, by changing "autocapitalize: string|null|undefined;" to "autocapitalize: string;".

erwinhalik commented 5 years ago

What I'm doing as a temporary solution is editing my \node_modules\@Polymer\paper-input\paper-input-behavior.d.ts file, by changing "autocapitalize: string|null|undefined;" to "autocapitalize: string;".

Is this a workaround or a viable solution?

It seems to me that this property should be of the same type as the standard HTMLElement property.

yv989c commented 5 years ago

Well, I would say it's temporary, because you are messing up with the node_modules folder, and therefore, you project will fail if you clone it on a different machine, unless you also make the file edit there.

Please keep in mind that this is not a big issue, it's a silly bug that's just making TypeScript's type checking mad.

erwinhalik commented 5 years ago

Well, I would say it's temporary, because you are messing up with the node_modules folder, and therefore, you project will fail if you clone it on a different machine, unless you also make the file edit there.

I'm not talking about the local editing, but changing the type to just string.

Please keep in mind that this is not a big issue, it's a silly bug that's just making TypeScript's type checking mad.

Yes it isn't. Still; if that was a viable solution, I'd suggest to make a pull request out of it.

yv989c commented 5 years ago

Yes, as I mentioned in my initial response, there's already a PR (#681) for this.

I'm having the same issue, and it seems that @rictic already worked on a fix: #681

framled commented 5 years ago

same problem, how can ignore this error??

bicknellr commented 5 years ago

681 has been merged and is available on npm in v3.0.2. I'm going to close this issue, but leave a comment if you still have trouble after updating.