Skip to content

Migrate Layout File to Typescript#2164

Closed
ong6 wants to merge 2 commits intoMarkBind:masterfrom
ong6:ts-migrate-layout
Closed

Migrate Layout File to Typescript#2164
ong6 wants to merge 2 commits intoMarkBind:masterfrom
ong6:ts-migrate-layout

Conversation

@ong6
Copy link
Contributor

@ong6 ong6 commented Feb 13, 2023

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Part of #1913

Overview of changes:
Migrate Layouts file and Layouts Manager to typescript

Anything you'd like to highlight/discuss:
N/A

Testing instructions:
N/A

Proposed commit message: (wrap lines at 72 characters)
(rebase commit)


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

@ong6 ong6 changed the title Migrate Layout File to Typescript [WIP] Migrate Layout File to Typescript Feb 13, 2023
@ong6 ong6 marked this pull request as ready for review February 13, 2023 10:55
@ong6 ong6 changed the title [WIP] Migrate Layout File to Typescript Migrate Layout File to Typescript Feb 13, 2023
@ong6 ong6 force-pushed the ts-migrate-layout branch 2 times, most recently from 88c4681 to 754fd5e Compare February 13, 2023 12:00
@ong6 ong6 requested a review from jovyntls February 13, 2023 12:11
Copy link
Contributor

@jovyntls jovyntls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on the types! Also, why are all the method call params (and anything comma-separated) split into a line of their own? Seems like an unnecessary change 😅

@ong6 ong6 force-pushed the ts-migrate-layout branch from fb51385 to 7a54356 Compare March 16, 2023 12:07
@ong6 ong6 requested a review from jovyntls March 16, 2023 12:09
Copy link
Contributor

@jovyntls jovyntls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @ong6! Can we avoid unnecessary whitespace changes (e.g. putting all variables in a newline)?

@ong6 ong6 force-pushed the ts-migrate-layout branch from 7a54356 to 6236b99 Compare March 17, 2023 02:56
@ong6 ong6 requested a review from jovyntls March 17, 2023 02:56
@ong6 ong6 force-pushed the ts-migrate-layout branch from 6236b99 to 648246d Compare March 17, 2023 04:23
@ong6 ong6 requested a review from raysonkoh March 19, 2023 17:56
Copy link
Contributor

@jovyntls jovyntls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ong6 ong6 force-pushed the ts-migrate-layout branch from 648246d to 4f457f7 Compare March 20, 2023 09:05
@jovyntls jovyntls added this to the v4.1.1 milestone Mar 20, 2023
Copy link
Contributor

@raysonkoh raysonkoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@raysonkoh
Copy link
Contributor

raysonkoh commented Mar 20, 2023

@ong6 could you remove the commit description in your adapt commit?

Copy link
Contributor

@jovyntls jovyntls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ong6 Sorry I missed this earlier - could you update the imports of the files you migrated to use ES6 imports instead of require?

@ong6 ong6 force-pushed the ts-migrate-layout branch 5 times, most recently from a87e0cc to fa7caf3 Compare March 23, 2023 07:39
Copy link
Contributor

@jovyntls jovyntls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a rebase error!

@ong6 ong6 force-pushed the ts-migrate-layout branch 2 times, most recently from d11d771 to a56de11 Compare March 25, 2023 18:02
@ong6 ong6 requested a review from jovyntls March 25, 2023 18:02
Copy link
Contributor

@jovyntls jovyntls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ong6 Please ensure that you've fixed the merge conflicts

@tlylt
Copy link
Contributor

tlylt commented Mar 26, 2023

Almost there now, let's try to get this one merged soon

@ong6 ong6 force-pushed the ts-migrate-layout branch 4 times, most recently from de51a91 to 231d39c Compare March 29, 2023 03:22
Copy link
Contributor

@jovyntls jovyntls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more @ong6 !

@ong6 ong6 force-pushed the ts-migrate-layout branch 4 times, most recently from 19d94b4 to c71bbf9 Compare March 29, 2023 17:11
Comment on lines 443 to 444
const doesLayoutHavePageNav = this.pageConfig.layoutManager.layoutHasPageNav(
this.layout ?? LAYOUT_DEFAULT_NAME);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking, is there a change in behaviour here (and the other uses of ?? LAYOUT_DEFAULT_NAME below)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch. I've adjusted the code for this instance as it may affect the behavior. However, for the instances below, there is no change in the intended behavior as LAYOUT_DEFAULT_NAME is the fallback for those cases regardless.

@ong6 ong6 force-pushed the ts-migrate-layout branch from c71bbf9 to ff8d20c Compare March 31, 2023 15:13
@ong6 ong6 force-pushed the ts-migrate-layout branch from 216c6d3 to 00ada70 Compare March 31, 2023 15:59
@ong6 ong6 force-pushed the ts-migrate-layout branch from 00ada70 to f11595a Compare March 31, 2023 15:59
Copy link
Contributor

@jovyntls jovyntls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ong6, I think you need to fix the rebase - the tests are failing because your .gitignore/.eslintignore are not ignoring the files that they should, probably because of an error when you rebased

Please rebase carefully! Your rebase deleted all of the changes from master in the .gitignore and .eslintignore.

}

return this.layouts[name].insertPage(pageContent, pageNav, pageIncludedFiles);
return this.layouts[name].insertPage(pageContent, pageNav, new Set<string>(pageIncludedFiles));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we create a new instance of pageIncludedFiles here? Is it to avoid passing by reference?

Comment on lines +443 to +444
const doesLayoutHavePageNav = this.layout ? this.pageConfig.layoutManager.layoutHasPageNav(
this.layout) : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can avoid all of these typing issues with this.layout, and the additions of ?? LAYOUT_DEFAULT_NAME below, by asserting that the layout attribute exists with a ! operator.
You'll need to modify this too (just delete the question mark)

Feel free to trace to verify that this is safe!

@lhw-1 lhw-1 removed this from the v4.1.1 milestone Apr 3, 2023
@tlylt tlylt marked this pull request as draft April 10, 2023 10:37
@ong6 ong6 closed this Apr 11, 2023
@ong6
Copy link
Contributor Author

ong6 commented Apr 11, 2023

Will create new PR for this

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

Successfully merging this pull request may close these issues.

5 participants