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

Further work on TypeScript strictNullChecks #1581

Merged
merged 56 commits into from
Mar 18, 2022
Merged

Conversation

corasaurus-hex
Copy link
Contributor

@corasaurus-hex corasaurus-hex commented Mar 6, 2022

What has Changed?

My Calva PR Checklist

I have:

  • Read How to Contribute.
  • Directed this pull request at the dev branch. (Or have specific reasons to target some other branch.)
  • Made sure I have changed the PR base branch, so that it is not published. (Sorry for the nagging.)
  • Updated the [Unreleased] entry in CHANGELOG.md, linking the issue(s) that the PR is addressing.
  • Figured if anything about the fix warrants tests on Mac/Linux/Windows/Remote/Whatever, and either tested it there if so, or mentioned it in the PR.
  • Added to or updated docs in this branch, if appropriate
  • Tests
    • Tested the particular change
    • Figured if the change might have some side effects and tested those as well.
    • Smoke tested the extension as such.
    • Tested the VSIX built from the PR (so, after you've submitted the PR). You'll find the artifacts by clicking Show all checks in the CI section of the PR page, and then Details on the ci/circleci: build test.
  • [~] Referenced the issue I am fixing/addressing in a commit message for the pull request.
    • [~] If I am fixing the issue, I have used GitHub's fixes/closes syntax
    • [~] If I am fixing just part of the issue, I have just referenced it w/o any of the "fixes” keywords.
  • [~] Created the issue I am fixing/addressing, if it was not present.
  • Formatted all JavaScript and TypeScript code that was changed. (use the prettier extension or run npm run prettier-format)
  • Confirmed that there are no linter warnings or errors (use the eslint extension, run npm run eslint before creating your PR, or run npm run eslint-watch to eslint as you go).

Ping @PEZ, @bpringe

@corasaurus-hex corasaurus-hex force-pushed the cora/further-ts-null-checks branch from abe8606 to 822fe17 Compare March 6, 2022 08:15
@corasaurus-hex corasaurus-hex changed the base branch from published to dev March 6, 2022 08:16
corasaurus-hex added a commit that referenced this pull request Mar 7, 2022
corasaurus-hex added a commit that referenced this pull request Mar 7, 2022
@corasaurus-hex corasaurus-hex force-pushed the cora/further-ts-null-checks branch from a5ec5a8 to ff8a168 Compare March 7, 2022 19:30
corasaurus-hex added a commit that referenced this pull request Mar 8, 2022
@corasaurus-hex corasaurus-hex force-pushed the cora/further-ts-null-checks branch from ff8a168 to e9371a3 Compare March 8, 2022 16:03
@corasaurus-hex corasaurus-hex marked this pull request as ready for review March 13, 2022 21:24
@corasaurus-hex corasaurus-hex requested review from PEZ, bpringe and Cyrik March 13, 2022 21:24
@corasaurus-hex
Copy link
Contributor Author

I tried to keep the behavior the same. There are 242 remaining errors (down from 750-ish!). There is probably some more low-hanging fruit remaining if I sift through some more but very soon we'll need to start revamping pieces to support strictNullChecks.

@corasaurus-hex corasaurus-hex changed the title WIP further ts null checks Further work on TypeScript strictNullChecks Mar 14, 2022
@bpringe
Copy link
Member

bpringe commented Mar 17, 2022

I've started reviewing, but need to stop for now. I'll try to finish tomorrow.

@PEZ
Copy link
Collaborator

PEZ commented Mar 17, 2022

Thanks for doing this, @corasaurus-hex ! I get dizzy reading through all the changes and can just imagine what an effort it must be providing.

I get dizzy reading through all the changes. It all looks very sane to me. I only see a few places where I start to worry about the current behaviour being kept. Not because I see any error, but because I can't reason about the changes clear enough to understand the implications from reading. This says much more about the current code than the changes, so there is nothing we can do about it in this PR.

I will run with this VSIX today for work. If that works as usual, then I will vote for merge. And we'll get @bpringe's review results in tomorrow, so hopefully we'll merge tomorrow! 🍾 (I like to celebrate in advance. The worst case scenario there is an extra celebration, right?).

@PEZ
Copy link
Collaborator

PEZ commented Mar 17, 2022

I merged latest dev into this, so that my testing gets more real-world. 😄 I do hope I didn't merge away any of your changes, but it merged pretty cleanly at least.

@@ -86,7 +93,7 @@ function getCurrentArgsRanges(document: TextDocument, idx: number): Range[] {
(previousRangeIndex > 1 &&
['->', 'some->'].includes(previousFunction)) ||
(previousRangeIndex > 1 &&
previousRangeIndex % 2 &&
previousRangeIndex % 2 !== 0 &&
Copy link
Member

Choose a reason for hiding this comment

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

Was this check for the modulus result just missing before?

Copy link
Contributor Author

@corasaurus-hex corasaurus-hex Mar 18, 2022

Choose a reason for hiding this comment

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

yep! it worked before because 0 is false-y. however, we're assigning the result of this condition to a boolean variable with the previous code if the modulus was 0 then the result of this condition would be 0 instead of a boolean

export function isResultsDoc(doc: vscode.TextDocument): boolean {
return doc && path.basename(doc.fileName) === RESULTS_DOC_NAME;
export function isResultsDoc(doc?: vscode.TextDocument): boolean {
return !!doc && path.basename(doc.fileName) === RESULTS_DOC_NAME;
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference in using double negation here vs just doc && ...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

with doc && ... if doc was undefined then this function would return undefined. the function type says it returns a boolean, though, and while we could make it boolean | undefined I prefer to keep the types more constrained and simpler if I can

Copy link
Member

Choose a reason for hiding this comment

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

Ah, thanks!

@corasaurus-hex
Copy link
Contributor Author

@PEZ I checked out the merge, all seems well. thanks for doing that!

@bpringe
Copy link
Member

bpringe commented Mar 18, 2022

TIL what the non-null assertion operator is 😄 . Anyway, let's merge!

@bpringe bpringe merged commit d4336e8 into dev Mar 18, 2022
@bpringe bpringe deleted the cora/further-ts-null-checks branch March 18, 2022 03:28
@bpringe
Copy link
Member

bpringe commented Mar 18, 2022

I will run with this VSIX today for work. If that works as usual, then I will vote for merge.

Whoops. I hope that merge was okay. 😅

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.

3 participants