Create type for autocapitalize propertie of input and textarea #21464
Create type for autocapitalize propertie of input and textarea #21464rangzen wants to merge 1 commit intoionic-team:mainfrom
Conversation
There was a problem hiding this comment.
Thanks for the PR! There are a few things that we will need to correct before this gets merged in:
-
autocapitalizeaccepts more values than just"on"or"off": https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autocapitalize. The following strings are accepted:on,off,none,sentences,words,characters. -
The build is failing. When you make your changes you need to run
npm run lint.fixandnpm run buildfrom thecoredirectory. -
The
ion-textareacomponent also has anautocapitalizeproperty, so we should make these changes there as well: https://github.com/ionic-team/ionic/blob/master/core/src/components/textarea/textarea.tsx#L40
When you update the types, you should add it as an AutocapitalizeTypes type in interface.d.ts. See https://github.com/ionic-team/ionic/blob/4fd7c0cc5a6c97100fa380e4ff1be0bb84c7006b/core/src/interface.d.ts#L40 as an example.
So you would do something like:
export type AutocapitalizeTypes = 'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters';Fix ionic-team#21463. Change none to off in textarea for coherence. Didn't use parenthese like in AutocompleteTypes.
f4b28f3 to
1e2eb9d
Compare
https://github.com/ionic-team/ionic/blob/master/core/src/components.d.ts#L2837 implements two interfaces and it seems that there is a conflict with the internal definitions of the DOM in Typescript
Any idea about dealing with that? |
|
There need to be some changes in Stencil in order to account for this, so I will make sure that gets merged first. |
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
|
Thanks for the PR, and apologies for the delay. We appreciate the work you put into creating this PR. However, we are unable to accept the PR at this time. While the experience here is not ideal, the The underlying problem is with how TypeScript types the As shown in the link, the If TypeScript narrows their types, we will be more than happy to reconsider adding this change to Ionic's codebase. I am going to close this, but let me know if you have any questions. Thank you! |
|
Whooo almost 2 years and half :) Thank you for the answer and the links to TypeScript DOM 👍 |
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
In #2509, we changed these types to `any` as suggested by Manu. This was done to fix ionic-team/ionic-framework#21464. Upon further investigation we found that this fix was not correct. The Framework issue had nothing to do with the types on `HTMLStencilElement` and instead were related to the types on `HTMLElement`. It's worth noting we didn't got the route of specifying the allowed strings further to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'` to align with `lib.dom.d.ts` that's shipped with TypeScript, which just types this property as `string` (on `HTMLElement`). Had we done that, we could/would have run into issues where `string` isn't assignable to `'off' | 'on' | 'none' | 'sentences' | 'words' | 'characters'`, as the former is wider than that latter.
Fix #21463
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build) was run locally and any changes were pushednpm run lint) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: #21463
What is the new behavior?
Does this introduce a breaking change?
Probably not cause everybody use 'on' and 'off' already and browser compatibility is poor right now so probably few people use it.
Other information