-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[TS migration] Migrate 'Docs' files to TypeScript #37973
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| function syncSelectors(selectedIndex) { | ||
| function syncSelectors(selectedIndex: number) { | ||
| const allSelects = document.querySelectorAll('select'); | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/prefer-for-of -- for-of doesn't work with this data | ||
| for (let i = 0; i < allSelects.length; i++) { | ||
| allSelects[i].selectedIndex = selectedIndex; | ||
| } | ||
| } | ||
|
|
||
| function selectOption(select) { | ||
| function selectOption(select: HTMLSelectElement) { | ||
| if (!select) { | ||
| return; | ||
| } | ||
|
|
@@ -19,17 +21,21 @@ function selectOption(select) { | |
| allOptions.forEach((option) => { | ||
| if (option.value === selectedValue) { | ||
| const toShow = document.getElementsByClassName(option.value); | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/prefer-for-of -- for-of doesn't work with this data | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should disable this rule?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean on the file level?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have looked through the app and there are not a lot of places where this eslint rule causes problems. Also, this case is kind of specific due to the used data, so I think it's okay to leave it as is
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, let's leave it as is 😄 |
||
| for (let i = 0; i < toShow.length; i++) { | ||
| toShow[i].classList.remove('hidden'); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| const toHide = document.getElementsByClassName(option.value); | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/prefer-for-of -- for-of doesn't work with this data | ||
| for (let i = 0; i < toHide.length; i++) { | ||
| toHide[i].classList.add('hidden'); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| window.onload = selectOption(document.getElementsByClassName('selector')[0]); | ||
| window.onload = () => selectOption(document.getElementsByClassName('selector')[0] as HTMLSelectElement); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious: why doesn't it work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabioh8010 It gives this error
