Skip to content

LG-7291 TypeScript refactoring for 6777#6769

Merged
eric-gade merged 14 commits intomainfrom
eric-LG6777-typescript
Aug 19, 2022
Merged

LG-7291 TypeScript refactoring for 6777#6769
eric-gade merged 14 commits intomainfrom
eric-LG6777-typescript

Conversation

@eric-gade
Copy link
Contributor

What

This PR corresponds to LG-7291.

In the course of making changes for LG-6777 (this PR), we decided to pull out the changes related to TypeScript refactoring and wait until the origin PR had been merged.

These changes refactor all filed affected by LG-6777 from JSDoc type annotations to full TypeScript.

Eric Gade and others added 2 commits August 17, 2022 11:19
-- What
With the addition of new checks for `maxAttemptsBeforeNativeCamera`,
which triggers the use of the native camera after a certain number of
failed Acuant attempts, we needed to update some of the type
definitions.

In addition to doing so, we have converted several of the affected
files to full TypeScript (from JSDoc annotations).
changelog: Improvements, TypeScript, rebasing typescript changes on
main and associated fixes
@eric-gade eric-gade requested a review from a team August 17, 2022 15:32
changelog: Improvements, TypeScript, fixing linting issues
/**
* Image width, or null if unknown
*/
width?: number | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Before, these were number | null, but not optional.

Suggested change
width?: number | null;
width: number | null;

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, I flipped the original non-optionals back to being non-optional in that interface 8d31f0a

eric-gade and others added 5 commits August 17, 2022 13:47
…ture.tsx

Co-authored-by: Andrew Duthie <andrew.duthie@gsa.gov>
…ture.tsx

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
…ture.tsx

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
…ture.tsx

Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
Also switching to the global window object, which already is annotated
with the AcuantJavaScriptWebSdk interface

changelog: Improvements, TypeScript, updating interface property types
@eric-gade eric-gade marked this pull request as ready for review August 17, 2022 18:12
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Couple minor suggestions, but looks great overall!

/**
* @typedef {ImageAnalyticsPayload & _AcuantImageAnalyticsPayload} AcuantImageAnalyticsPayload
*/
type AcuantImageAnalyticsPayload = ImageAnalyticsPayload & _AcuantImageAnalyticsPayload;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a good one-to-one port, but I believe it was implemented the way it was previously due to limitations of a good "extends" mechanism which would be available to us in TypeScript proper, i.e.

interface AcuantImageAnalyticsPayload extends ImageAnalyticsPayload {
  documentType: AcuantDocumentTypeLabel;
  // ...
}

What do you think about making that revision?

@@ -0,0 +1,102 @@
import { createContext, useState } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this file meant to be included?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is, sort of, but I made the jsx -> tsx file rename more explicit now in 6d0a377

eric-gade and others added 6 commits August 18, 2022 15:04
…ture.tsx

Co-authored-by: Andrew Duthie <andrew.duthie@gsa.gov>
…ture.tsx

Co-authored-by: Andrew Duthie <andrew.duthie@gsa.gov>
…ture.tsx

Co-authored-by: Andrew Duthie <andrew.duthie@gsa.gov>
…ture.tsx

Co-authored-by: Andrew Duthie <andrew.duthie@gsa.gov>
Additionally, I have renamed failed-capture-context.jsx to tsx
explicitly

changelog: Improvements, TypeScript, updating type definitions
changelog: Improvements, TypeScript, removing old type definition
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

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

LGTM! Love to see more TypeScript.

isAssessedAsBlurry: boolean;
}

interface FailedCaptureAttemptsContextInterface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong stance either way, and I know there are some conventions incorporating "Interface" in the name, but elsewhere I'd been tending to suffix "Value" for the interface describing the context value shape. I think we should aim to be consistent whichever way we want to go with the naming.

@eric-gade eric-gade merged commit 438de09 into main Aug 19, 2022
@eric-gade eric-gade deleted the eric-LG6777-typescript branch August 19, 2022 17:27
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