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

[Dev] Enable compile TypeScript checks; noUnusedLocals, noUnusedParameters, & strictFunctionTypes #1195

Merged
merged 4 commits into from
Sep 23, 2024

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented Sep 21, 2024

Description

One-Line Summary

Enforce some additional Typescript compile errors that were only IDE warnings.

Details

Enable these TS config compile settings. noUnusedLocals, noUnusedParameters, & strictFunctionTypes

Validation

Tests

Info

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Info

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets



This change is Reviewable

No code changes were needed to move strictFunctionTypes=true from a IDE
only setting to a compile settings.
Adjusted a few files that didn't follow this rule to get it to compile.
Copy link
Contributor

@shepherd-l shepherd-l left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: 0 of 9 files reviewed, 1 unresolved discussion (waiting on @emawby, @jkasten2, and @rgomezp)


src/shared/utils/Encoding.ts line 83 at r3 (raw file):

    encodeURIComponent(str).replace(
      /%([0-9A-F]{2})/g,
      function toSolidBytes(_match, p1) {

Should we just remove the method instead? Both base64Encode() and base64Decode()
I don't see them being referenced anywhere and the methods don't look like this in the docs referenced in the comment above: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding

Copy link
Member Author

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 9 files reviewed, 1 unresolved discussion (waiting on @emawby, @rgomezp, and @shepherd-l)


src/shared/utils/Encoding.ts line 83 at r3 (raw file):

Previously, shepherd-l (Shepherd) wrote…

Should we just remove the method instead? Both base64Encode() and base64Decode()
I don't see them being referenced anywhere and the methods don't looking like this in the docs referenced above today: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding

ah good call, didn't look into the usage when I made the change. I confirmed they are not used and just made a commit here ot remove them in this PR.

@jkasten2 jkasten2 merged commit 7ca28ca into main Sep 23, 2024
4 of 5 checks passed
@jkasten2 jkasten2 deleted the dev/enable_more_compile_ts_checks_2024-09-20 branch September 23, 2024 19:04
@shepherd-l shepherd-l mentioned this pull request Sep 30, 2024
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.

2 participants