Skip to content
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

[TS] Add types to flash, clean up some logic #1824

Merged
merged 22 commits into from
Feb 23, 2021

Conversation

Krisztiaan
Copy link
Contributor

@Krisztiaan Krisztiaan commented Feb 20, 2021

Resolves: #1217

Added allowJs: false to web, since this was the last piece missing.

This PR does not address the potential for a bug that could happen when a dismiss button on a tree that does not update with the messages array is pressed, thus potentially removing an unintended message.

Namings may seem a bit "weird" considering long standing practice of generic names such as state and payload, but especially in this case, it seems to me as making it just a little bit more elegant.
Disagreement welcome, as in anything else!

@Krisztiaan Krisztiaan changed the title feat: add types to flash, clean up some logic [TS] Add types to flash, clean up some logic Feb 20, 2021
@github-actions
Copy link

github-actions bot commented Feb 20, 2021

📦 PR Packages

Click to Show Package Download Links

https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/create-redwood-app-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-api-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-api-server-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-auth-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-cli-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-core-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-dev-server-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-eslint-config-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-eslint-plugin-redwood-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-forms-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-internal-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-prerender-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-router-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-structure-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-testing-0.25.1-245fa21.tgz
https://rw-pr-redwoodjs-com.s3.amazonaws.com/1824/redwoodjs-web-0.25.1-245fa21.tgz

Install this PR by running yarn rw upgrade --pr 1824:0.25.1-245fa21

packages/web/src/flash/Flash.tsx Outdated Show resolved Hide resolved
packages/web/src/flash/Flash.tsx Outdated Show resolved Hide resolved
packages/web/src/flash/FlashContext.tsx Outdated Show resolved Hide resolved
packages/web/src/flash/FlashReducer.ts Outdated Show resolved Hide resolved
packages/web/src/flash/FlashReducer.ts Outdated Show resolved Hide resolved
packages/web/src/flash/FlashReducer.ts Outdated Show resolved Hide resolved
Krisztiaan and others added 4 commits February 20, 2021 22:26
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Copy link
Member

@Tobbe Tobbe left a comment

Choose a reason for hiding this comment

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

I've suggested removing a bunch of comments.

I like comments that explain potentially confusing code. Or comments that explains the intent of code, if the intent is not immediately obvious from looking at the code itself

In these cases I don't think the comments fit in those criterias. Let me know if you disagree.

And then I added brackets around an if-statement. We like to have those, even for single line if-statements.

packages/web/src/flash/FlashContext.tsx Outdated Show resolved Hide resolved
packages/web/src/flash/FlashContext.tsx Outdated Show resolved Hide resolved
packages/web/src/flash/FlashContext.tsx Outdated Show resolved Hide resolved
packages/web/src/flash/FlashContext.tsx Outdated Show resolved Hide resolved
packages/web/src/flash/FlashContext.tsx Outdated Show resolved Hide resolved
packages/web/src/flash/FlashReducer.ts Outdated Show resolved Hide resolved
packages/web/src/flash/Flash.tsx Outdated Show resolved Hide resolved
Krisztiaan and others added 7 commits February 22, 2021 13:14
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
@Krisztiaan
Copy link
Contributor Author

Krisztiaan commented Feb 22, 2021

@Tobbe fully agree, didn't remove the comments because I was just there to make the TS change (and some other sensible mods).

As for the braces for blocks, this should probably be enforced via eslint, because my (and potentially others') config defaults to one-liners.

@Tobbe
Copy link
Member

Tobbe commented Feb 22, 2021

As for the braces for blocks, this should probably be enforced via eslint, because my (and potentially others') config defaults to one-liners.

💯 I was actually surprised it wasn't already a rule

packages/web/tsconfig.json Outdated Show resolved Hide resolved
Copy link
Collaborator

@dac09 dac09 left a comment

Choose a reason for hiding this comment

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

🔥

packages/web/tsconfig.json Outdated Show resolved Hide resolved
Krisztiaan and others added 2 commits February 22, 2021 23:38
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
@Krisztiaan
Copy link
Contributor Author

The ESlint rule is added in #1836

Copy link
Contributor

@thedavidprice thedavidprice left a comment

Choose a reason for hiding this comment

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

E2E tests = ✅

FYI: I found an unrelated Scaffold Flash error (see #1839). Confirming this PR keeps current behavior and Flash works on Delete.

@thedavidprice thedavidprice merged commit 53bcdb2 into redwoodjs:main Feb 23, 2021
@thedavidprice thedavidprice added this to the next release milestone Feb 23, 2021
@Krisztiaan Krisztiaan deleted the ts/flash branch February 23, 2021 09:19
dac09 added a commit to dac09/redwood that referenced this pull request Feb 23, 2021
…late-and-auth-setup-tests

* 'main' of github.com:redwoodjs/redwood:
  [TS] Add types to flash, clean up some logic (redwoodjs#1824)
  Remove backticks (redwoodjs#1826)
  Add Gravatar to the list of Tom's accomplishments (redwoodjs#1813)
  Don't open storybook when --open=false is given (redwoodjs#1795)
  Passthrough error codes on cli failures (redwoodjs#1791)
  E2E: if path to project given, use the installed packages (redwoodjs#1837)
  Add Cypress Step6 Test (redwoodjs#1780)
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.

Convert @redwoodjs/web to TypeScript
4 participants