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

Enable TypeScript strict mode by ignoring lots of errors #1056

Merged
merged 6 commits into from
Feb 11, 2022

Conversation

seancolsen
Copy link
Contributor

@seancolsen seancolsen commented Feb 9, 2022

Fixes #619

In this PR

  • I turned on TypeScript strict mode.
  • About 1/2 of the errors were easy to fix, so I fixed them.
  • I suppressed the remaining errors, linking to Fix all ignored TypeScript errors #1055 for more info. I'll flesh out that ticket after we get this PR merged.
  • I also upgraded TypeScript because the improved control flow analysis in 4.4 helped to eliminate some of the errors in display.ts. I had to upgrade ESLint after upgrading TypeScript.

Notes

  • Unfortunately it seems there is probably no way to suppress TypeScript errors in a Svelte template. So I had to lift some code out of templates and into the script just for the purpose of suppressing the TS error.
  • In addition to TypeScript showing more errors in strict mode, ESLint also shows a (slightly) more errors now because it knows more about the variables. As such, some of the changes I made were necessary to appease ESLint specifically, not TypeScript.

Review tips

  • Look at each commit on its own.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the master branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

- TS 4.4 brings [Improved control flow analysis][1] which eliminates
  several TS strict errors in `display.ts`.
- I had to upgrade ESLint after upgrading TypeScript.

[1]: https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#cfa-aliased-conditions
@seancolsen
Copy link
Contributor Author

@pavish @kgodey Since we have a nice lull in the PR queue right now I think it'd be great if we could get this PR merged before any new front end PRs, otherwise we might end up chasing conflicts for a while like we did with #826. I realize we have a couple full-stack PRs that will contain font-end changes, so I'm open to merging this PR either before or after those.

@seancolsen seancolsen added the pr-status: review A PR awaiting review label Feb 9, 2022
@kgodey
Copy link
Contributor

kgodey commented Feb 9, 2022

@seancolsen I'll leave it to you and @pavish to determine merge order; I don't know enough to have an opinion.

@pavish pavish self-assigned this Feb 10, 2022
@pavish
Copy link
Member

pavish commented Feb 10, 2022

@seancolsen This PR looks good to me!

I think it would be best if we could merge #1041 and #1047 first. Both these PRs seem ready on the backend, and we could add frontend changes there and merge them and handle any new ts error in this PR.

This PR could then be merged right away.

@pavish
Copy link
Member

pavish commented Feb 11, 2022

@seancolsen It looks like #1047 is not ready yet. I'm approving and merging this PR first.


// @ts-ignore: https://github.com/centerofci/mathesar/issues/1055
// eslint-disable-next-line @typescript-eslint/naming-convention
const getLink__withTypeCoercion: (arg0: unknown) => string = getTabLink;
Copy link
Member

@pavish pavish Feb 11, 2022

Choose a reason for hiding this comment

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

I don't like the name of this const because it goes against everything we've established on the frontend. I believe this particular scenario warrants a discussion and some documentation updates.

@pavish pavish enabled auto-merge February 11, 2022 02:42
@codecov-commenter
Copy link

Codecov Report

Merging #1056 (bed3144) into master (d010e11) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1056   +/-   ##
=======================================
  Coverage   92.53%   92.53%           
=======================================
  Files         108      108           
  Lines        3830     3830           
=======================================
  Hits         3544     3544           
  Misses        286      286           
Flag Coverage Δ
pytest-backend 92.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d010e11...bed3144. Read the comment docs.

@pavish pavish merged commit a7d1194 into master Feb 11, 2022
@pavish pavish deleted the 619_ts_strict_with_ignore branch February 11, 2022 02:53
@pavish pavish mentioned this pull request Feb 15, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Enable TypeScript strict mode
4 participants