Skip to content

Add TypeScript tooling for JavaScript type-checking#4043

Merged
aduth merged 3 commits intomasterfrom
add-typescript
Aug 11, 2020
Merged

Add TypeScript tooling for JavaScript type-checking#4043
aduth merged 3 commits intomasterfrom
add-typescript

Conversation

@aduth
Copy link
Copy Markdown
Contributor

@aduth aduth commented Aug 11, 2020

Why: To improve confidence in our code. The error fixed in #4040 would have never happened if these changes had been in place.

Applies only to new code in app/javascripts/app/document-capture (the React-based document capture flow).

See also: #4040

This removes prop-types and disables the associated ESLint configuration.

From #4040:

Benefits:

  1. Can be used to provide type checking to surface these sorts of errors
  • Screen Shot 2020-08-11 at 9 42 27 AM
  1. Can be used to provide type checking and props detailed information from rendering parent components
  • Screen Shot 2020-08-11 at 9 41 11 AM
  1. Takes advantage of existing mechanisms for documenting functions using JSDoc
  2. Affords opportunity to describe the purpose of the prop type in the detail of the custom @typedef
  3. Provides an excuse timely and relevant space to describe the purpose of the component
  4. Allows prop validation errors to be checked at build time, rather than at run time (if enabled in build step, see "Downsides")
  5. Ships less code, since propTypes are only relevant for development, but are still shipped to production (unless steps are taken to strip them from production builds)
  6. Removes a dependency (prop-types)
  7. Allows prop defaults to be assigned using language-native defaulting syntax

Copy link
Copy Markdown
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM

aduth added 3 commits August 11, 2020 12:23
**Why:** To take advantage of TypeScript-based type checking.
**Why**: To improve confidence in our component props usage.
**Why**: To prevent errors from being inadvertently introduced.
@aduth aduth merged commit 6f9f872 into master Aug 11, 2020
@aduth aduth deleted the add-typescript branch August 11, 2020 19:27
aduth added a commit that referenced this pull request Aug 12, 2020
**Why**: PropTypes were removed in favor of TypeScript-validated JSDoc

See: #4043
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