PolymerElements/paper-input

TypeScript error with interface PaperInputElement

erwinhalik opened this issue · 7 comments

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

I'm having the same issue, and it seems that @rictic already worked on a fix: #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;".

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.

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.

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.

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

same problem, how can ignore this error??

#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.