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

Improve PAPI imports #634

Merged
merged 4 commits into from
Nov 9, 2023
Merged

Improve PAPI imports #634

merged 4 commits into from
Nov 9, 2023

Conversation

jolierabideau
Copy link
Contributor

@jolierabideau jolierabideau commented Nov 9, 2023

Add new import path in src/renderer global-this
Add new service for papi-frontent-react.service that exports all of the PAPI hooks
Switches all imports in core to the new

Export parts of PAPI individually in papi-frontend and papi-backend so they can be accessed without destructuring papi. Originally I had a destructured export instead of exporting each const, but when I commit the code I got the error: Split 'const' declarations into multiple statements. I tried to assert as a const, but got another error: A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.

Imports are now done like the screenshots below, and the appropriate JSDOCs display when you hover
Screenshot 2023-11-09 at 9 25 27 AM
Screenshot 2023-11-09 at 9 26 36 AM


This change is Reviewable

Copy link
Member

@tjcouch-sil tjcouch-sil left a comment

Choose a reason for hiding this comment

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

Thank you!! This is so exciting!

Reviewed 25 of 25 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @jolierabideau)


src/extension-host/services/papi-backend.service.ts line 44 at r1 (raw file):

  EventEmitter: PapiEventEmitter,
  /** JSDOC DESTINATION DataProviderEngine */
  DataProviderEngine: dataProviderService.DataProviderEngine,

Looks like this unfortunately got translated into in-line imports in papi.d.ts:
image.png

Would you mind trying type asserting the type with something like this:

DataProviderEngine: dataProviderService.DataProviderEngine as typeof dataProviderService.DataProviderEngine

Or if that doesn't work, you may need to import DataProviderEngine directly from the service and use it in here.


src/renderer/services/papi-frontend.service.ts line 65 at r1 (raw file):

  /** JSDOC DESTINATION projectLookupService */
  projectLookup: projectLookupService as ProjectLookupServiceType,
  /** JSDOC SOURCE papiReact */

Oops! We forgot to fill in this JSDoc. Something like

/**
 * JSDOC SOURCE papiReact
 *
 * React hooks that enable interacting with the `papi` in React components more easily.
 */

Copy link
Contributor Author

@jolierabideau jolierabideau 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: all files reviewed, 2 unresolved discussions (waiting on @tjcouch-sil)


src/extension-host/services/papi-backend.service.ts line 44 at r1 (raw file):

Previously, tjcouch-sil (TJ Couch) wrote…

Looks like this unfortunately got translated into in-line imports in papi.d.ts:
image.png

Would you mind trying type asserting the type with something like this:

DataProviderEngine: dataProviderService.DataProviderEngine as typeof dataProviderService.DataProviderEngine

Or if that doesn't work, you may need to import DataProviderEngine directly from the service and use it in here.

Done.


src/renderer/services/papi-frontend.service.ts line 65 at r1 (raw file):

Previously, tjcouch-sil (TJ Couch) wrote…

Oops! We forgot to fill in this JSDoc. Something like

/**
 * JSDOC SOURCE papiReact
 *
 * React hooks that enable interacting with the `papi` in React components more easily.
 */

Done.

Copy link
Member

@tjcouch-sil tjcouch-sil left a comment

Choose a reason for hiding this comment

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

:lgtm: thanks for the great work!!

Reviewed 4 of 4 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@jolierabideau jolierabideau merged commit 4442995 into main Nov 9, 2023
7 checks passed
@jolierabideau jolierabideau deleted the 549-improve-papi-imports branch November 9, 2023 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.

Improve papi imports like import { useData } from papi-frontend/react
2 participants